Tuesday, June 5, 2012

SQL Server - Optimizing query performance

PROBLEM:
How to optimize SQL Server query performance?

SOLUTION:
1. Turn on the execution plan, and statistics
2. Use Clustered Indexes
3. Use Indexed Views
4. Use Covering Indexes
5. Keep your clustered index small
6. Avoid cursors
7. Archive old data
8. Partition your data correctly
9. Remove user-defined inline scalar functions
10. Use APPLY
11. Use computed columns
12. Use the correct transaction isolation level
More details..

1. Aim for the ideal of only one single sql call per page request
2. Turn on SQL Profiler
3. Preprocess expensive queries
4. Review query plans to ensure optimally performing sql statements
5. Identify table scans or index scans
6. Identify key lookups
7. Check the order of columns in your where clause
8. Ensure the where clause is ordered most restrictive to least restrictive
9. Remove CTEs
10. Remove Temp Tables
11. Remove Cursors
12. Reduce the number of joins in your queries
13. Remove all declared variables
More details..

If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!


No comments:

Post a Comment