Performance Tuning
1. Do not use * with select statement
--Bad practice
SELECT * FROM Table1--Good practice
SELECT Column1, Column2, Column3 FROM Table12. Use EXISTS instead of IN
--Bad practice
SELECT Column1, Column2, Column3 FROM Table1 WHERE Column1 IN (SELECT Column1 FROM Table2)--Good practice
SELECT Column1, Column2, Column3 FROM Table1 WHERE EXISTS (SELECT Column1 FROM Table2 Where Table2.Column1 = Table1.Column1)3. Select Appropriate Data Type of table columns
4. Use proper join type
5. Use Indexed Views
6. Do not use Count (*)
7. Avoid use of cursors
8. Use a Table variable or CTE (Common Table Expression) instead of Temp Table whenever possible
9. Use SET NOCOUNT ON in Stored Procedure
10. Do not use "SP_" prefix with any user define Stored Procedure name
11. Use Stored Procedure for Complex Query and frequently used query
12. Use Parameterized Query
13. Use Try...Catch Block whenever required
14. Select appropriate life of transaction (Try to Avoid long running transaction)
15. Use proper Isolation level
16. Do not use function in WHERE Clauses
17. Try to avoid Expensive operators such as "LIKE", "NOT LIKE", Not equal to (<> or! =)
18. Define Relationships and Constraints whenever required
19. Create Index on All Foreign Keys
20. Create Index whenever required
21. Avoid Table and Index Scans
22. Use multiple small indexes rather than a few wide indexes
23. Create indexes on columns used in "WHERE", "ORDER BY", "GROUP BY" and "DISTINCT" clauses
24. Remove unused indexes
25. Use ITW (Index Tuning Wizard)
26. Avoid long actions in triggers
27. Estimate the Hash Joins
Last updated