How to measure stored procedure execution time?

You can use SET STATISTICS TIME ON, but it would return you timing for all single queries inside of your stored procedure. If you have bunch of queries inside then it might be not really 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 cache independent time measurement.


Posted on Wednesday, February 15, 2012 by | Comments (1) | Add Comment

Comments

Gravatar

Re: How to measure stored procedure execution time?

That's a crackerjack answer to an interesting qeutosin

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

New Comment

Your Name:
Email (for internal use only):
Comment:
 
Code above:

Categories

Recent Tweets

  • Simon Ince's Blog: Hierarchies with HierarchyID in SQL 2008 http://t.co/xSDwiF6rRS.
  • Visual Studio 2010 WAS painfully slow - CodeProject http://t.co/Usba1x6CZy

Valid HTML5