0% found this document useful (0 votes)
21 views

Op Tim Ization

1. There are several best practices for optimizing SQL queries for performance. This includes ensuring tables have primary keys and indexes, indexes are created based on query criteria, views are replaced with tables when possible, unnecessary joins and columns are removed, and stored procedures are used instead of ad hoc queries or triggers. 2. Following practices like ensuring adequate free disk space, avoiding cursors, and moving logic from functions to stored procedures can also help optimize query performance. Hardware upgrades may further help but are not always quick solutions. 3. The article focuses on simple techniques database administrators can use to immediately improve query performance without extensive analysis or system changes.

Uploaded by

Salauddin Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Op Tim Ization

1. There are several best practices for optimizing SQL queries for performance. This includes ensuring tables have primary keys and indexes, indexes are created based on query criteria, views are replaced with tables when possible, unnecessary joins and columns are removed, and stored procedures are used instead of ad hoc queries or triggers. 2. Following practices like ensuring adequate free disk space, avoiding cursors, and moving logic from functions to stored procedures can also help optimize query performance. Hardware upgrades may further help but are not always quick solutions. 3. The article focuses on simple techniques database administrators can use to immediately improve query performance without extensive analysis or system changes.

Uploaded by

Salauddin Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

http://www.csharpcorner.

com/UploadFile/john_charles/QueryoptimizationinSQLServe
r200512112007154303PM/QueryoptimizationinSQLServer2005.aspx

SQL SERVER Rules for Optimizining Any Query Best Practices for
Query Optimization
January 20, 2009 by pinaldave

This subject is very deep subject but today we will see it very quickly and most important points. May
be following up on few of the points of this point will help users to right away improve the
performance of query. In this article I am not focusing on in depth analysis of database but simple
tricks which DBA can apply to gain immediate performance gain.
1.

Table should have primary key

2.

Table should have minimum of one clustered index

3.

Table should have appropriate amount of non-clustered index

4.

Non-clustered index should be created on columns of table based on query which is running

5.

Following priority order should be followed when any index is created a) WHERE clause, b)
JOIN clause, c) ORDER BY clause, d) SELECT clause

6.

Do not to use Views or replace views with original source table

7.

Triggers should not be used if possible, incorporate the logic of trigger in stored procedure

8.

Remove any adhoc queries and use Stored Procedure instead

9.

Check if there is atleast 30% HHD is empty it improves the performance a bit

10. If possible move the logic of UDF to SP as well


11. Remove * from SELECT and use columns which are only necessary in code
12. Remove any unnecessary joins from table
13. If there is cursor used in query, see if there is any other way to avoid the usage of this
(either by SELECT INTO or INSERT INTO, etc)
There are few hardware upgrades can be considered as well like separating index on different disk
drive or moving tempdb to another drive. However, I am not suggesting them here as they are not
quick way to improve the performance of query.

You might also like