Skip to main content

Posts

Showing posts with the label PostgreSQL

Tips to increase your Transact-SQL efficiency Part 1.

Given below are little known tips that you can use to ensure your Transact-SQL queries are performing in the  most efficient manner possible. 1. Avoid '*' in select query.      Restrict the queries result set by returning only the particular columns from the table and not all the  table's columns. The sql query becomes faster if you use the actual column names in SELECT  statement instead of than '*'. 2. Avoid COUNT(*) in select statement to check the existence of records in table.       Instead use IF EXISTS() to check records. - Write the query as: IF EXISTS (SELECT * FROM table_name WHERE column_name = ‘xxx’) - Instead of : SELECT COUNT(*) FROM table_name WHERE column_name = ‘xxx’ 3. Use alternate of SELECT COUNT(*).      Use an alternative way instead of the SELECT COUNT(*) statement to count the number     of records in  table.         - SELECT CO...

Stored Procedure

Introduction A stored procedure is a subroutine available to applications that access a relational database system. A stored procedure (sometimes called a proc , sproc , StoPro , StoredProc , sp or SP ) is actually stored in the database data dictionary. Typical use for stored procedures include data validation (integrated into the database) or access control mechanisms . Furthermore, stored procedures can consolidate and centralize logic that was originally implemented in applications. Extensive or complex processing that requires execution of several SQL statements is moved into stored procedures, and all applications call the procedures. One can use nested stored procedures by executing one stored procedure from within another. Stored procedures are similar to user-defined functions (UDFs). The major difference is that UDFs can be used like any other expression within SQL statements, whereas stored procedures must be invoked using the CALL statement. SQL Dialect...