0% found this document useful (0 votes)
41 views1 page

SQL Server Optimization Tips

The document provides several tips for optimizing SQL Server performance: 1) Restrict queries to return only required rows and columns to reduce network traffic. 2) Use stored procedures instead of complex queries as stored procedures are compiled and optimized. 3) Avoid cursors and instead fetch records set-based to improve performance.

Uploaded by

brandnewindian
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
41 views1 page

SQL Server Optimization Tips

The document provides several tips for optimizing SQL Server performance: 1) Restrict queries to return only required rows and columns to reduce network traffic. 2) Use stored procedures instead of complex queries as stored procedures are compiled and optimized. 3) Avoid cursors and instead fetch records set-based to improve performance.

Uploaded by

brandnewindian
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 1

SQL Server Optimization Tips are as follows: By Nishant Kumar

Restrict Query Result for performance optimization


Restricting query result means return of required rows instead of all rows of the table. This helps in reducing network traffic.
Restrict columns in the SQL query
Never try to return all the columns of the table when you require only a few of them. This helps in reducing network traffic.
Use stored procedure instead of heavy duty queries
Stored procedure exists as compiled objects on disk. Moreover, SQL server also keeps optimized execution plan for stored procedure.
This really saves time and speeds up execution.
Avoid SQL cursor for optimal performance
You should avoid using SQL cursor since it has adverse effect on SQL servers performance. It fetches the records row by row which
results in repeated network round trips.
Use constraints instead of trigger
Trigger runs every time data gets updated even when it is not required. This adds overhead on the system.
Use table variable instead of temporary tables.
When you create a temporary table (#TABLE) it physically creates the table in tempdb. It is an added overhead to create table. A table
variable doesnt need to be created in the database, it can stay in memory and go out of scope immediately after the batch ends, just
like regular variables.
Avoid using Having clause
Try to use where as far as possible instead of Having clause.
Include SET NOCOUNT ON in the stored procedure.
This prevents stored procedure to send messages indicating number of rows affected thus saves network traffic.
Sql server - SQL Server Optimization Tips - Feb 11, 2010 at 11:55 AM by Shuchi Gauri

SQL Server Optimization Tips


SQL Server optimization tips:
Provide appropriate resources to schema design.
Separate OLAP and OLTP workloads.
Normalize and then denormalize later for performance.
Define clearly all primary and foreign key relationships.
Define all constraints; unique and check both.
Choose datatypes wisely.
Partition tables horizontally as well as vertically.
Monitor and tune major queries
Return specific and needed rows and columns from queries.
Avoid complex operators like NOT LIKE
Use locking and isolation level hints to minimize locking.
Use stored procedures efficiently
Use temporary tables efficiently.
Created indexes based on use
Clustered indexed keys should be small.
Create index on all foreign keys
Remove unused indexes if any.
Keep transactions short.
Avoid table/index scans

You might also like