Optimization Tips in sql
| (1)Always try to use views and stored procedures instead of doing work with heavy queries. (2)Make a habit to use constraints instead of triggers whenever it is possible. (3)When you need n number of row from database try to use top keyword or SET ROWCOUNT statement (4)Always use table variables in place of temporary tables. (5)Avoid Union and try to use UNION ALL statement. (6)Always avoid using the DISTINCT clause, whenever possible. (7)Always try to avoid using SQL Server cursors. (8)Always try to avoid the HAVING clause. (9)Donot use select count(*) to get number of rows (10)Try to include SET NOCOUNT ON statement into your stored procedures to stop the message indicating the number of rows affected by a T-SQL statement. (11)Always use file system to store large binary objects and use the file path in database. (12)Sometimes we may have to apply more than one subqueries in our main query. Try to minimize the number of subquery block in your query. (13)Try to use column name insted of * |
|
