KARPACH

WEB DEVELOPER BLOG

How to measure stored procedure execution time?

You can use SET STATISTICS TIME ON, but it would return a timing for all single queries inside of your stored procedure. If you have a bunch of queries inside then it might be not very convenient. Here is a little code snippet alternative to STATISTICS TIME:

Declare @d datetime
Set @d = CURRENT_TIMESTAMP
 
-- Your stored procedure call goes here
 
SELECT DATEDIFF(ms,@d,CURRENT_TIMESTAMP)

Use DBCC DROPCLEANBUFFERS to clear SQL Server cache for the cache-independent time measurement.

Posted on February 15, 2012 by

Comments

Posted on 3/26/2012 02:42:03 AM by Kaia

That’s a crackerjack answer to an interesting qeutosin