How to benchmark a SQL Server Query? How to benchmark a SQL Server Query? database database

How to benchmark a SQL Server Query?


set showplan_text on will show you the execution plan (to see it graphically use CTRL + K (sql 2000) or CTRL + M (sql 2005 +)

set statistics IO onwill show you the reads

set statistics time onwill show you the elapsed time


Use SQL Profiler.

For .NET applications, filter that Application name by '.NET%' and you'll omit other extraneous queries.


+1 on the execution plan. From here you can see where all the time is being spent in your particular query. Eg. 85% of the time is spent table scanning a particular table, can you put an index on that table to improve it? etc etc.