Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a table which might be causing excessive delays during insertion of new records. I'd like to run a test against the database, measuring how long it takes to select, insert, and delete from the table.

Are there any built-in tools to do this against an SQL Server database table?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Simple down to 3ms accuracy:

SELECT GETDATE();
-- run query
SELECT GETDATE();

On SQL Server 2008 and above you can use SYSDATETIME() which has much greater accuracy.

You can also set a variable equal to the current time, run your query, and use DATEDIFF to determine the delta in whatever granularity makes sense (however this won't work across batches).

Other options:

SET STATISTICS TIME ON;
SET STATISTICS IO ON;

You can also look at the execution plans to determine where a specific query might have a bottleneck. I might recommend the free Plan Explorer for this (disclaimer: I work for SQL Sentry). If you generate actual plans from within the tool, it will show you actual runtime metrics for each query (everything shown above, without the work).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.