SQL Query Performance Optimization using SET Statistics in SQL Server
SQL query performance optimization in SQL Server is a vital task for SQL developers and SQL Server database administrators.
Especially if the database application is showing poor performance, for sql performance optimization database professionals should use helping tools to identify poor code, bottlenecks and missconfigured objects in the SQL database.
Configuring database statistics using "SET STATISTICS" is one of the easiest methods and database tools for developers trying to seek what is causing slow performance of a T-SQL code.
Either a t-sql script, or a SQL Server object like an SQL view or SQL Server stored procedure the following script will give starting tips for sql query performance optimization task.
Enalbe time, I/O and profile statistics using the following Set Statistics commands.
Then execute the target sql script or sql procedure which you want to optimize.
Then revert back the configuration settings back to original values.
set statistics time on
set statistics io on
set statistics profile on
--- Execute SQL Query or SQL Stored Procedure
set statistics time off
set statistics io off
set statistics profile off
Here is one of the simplest sql query performance optimization tricks that SQL Server developers can use during their daily t-sql tasks.