Solved

How to find the Avg Stored Procedure execution.

Posted on 2010-08-17
5
337 Views
Last Modified: 2012-05-10
how to find the average execution time of stored procedures during yesterday.
I would need a script that would list the number of executions and average time of execution of all the procedures.
0
Comment
Question by:dba2dba
5 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
Comment Utility
unless you log, in the procedure itself, the start/stop times, your only method would be to run a trace, and do the calculations from there ...
0
 
LVL 11

Expert Comment

by:rajvja
Comment Utility
Hi,

  Create a table with SP_Name, Start, End, Date

In the SPROC, at the begining store the current time in the table and also at the end of SPROC
0
 
LVL 1

Expert Comment

by:zimbix
Comment Utility
Could you interface with Sysinternals Process Explorer?
0
 
LVL 3

Assisted Solution

by:PrakashRaoBS
PrakashRaoBS earned 250 total points
Comment Utility
If you are using SQL Server 2008 the Following query will work,
select 

OBJECT_NAME(object_id) as 'Procedure Name',

execution_count,

min_elapsed_time,

max_elapsed_time 

from sys.dm_exec_procedure_stats

where DB_NAME(database_id) = ' DatabaseName '

Open in new window

0
 
LVL 3

Expert Comment

by:PrakashRaoBS
Comment Utility
If you are using SQL server 2005, then the following query will work,
select execution_count,

min_worker_time,

max_worker_time,

min_elapsed_time,

max_elapsed_time, text from sys.dm_exec_query_stats

cross apply sys.dm_exec_sql_text(sql_handle)

where text like '%procedure name%' and

text not like '%sys.dm_exec_query_stats%'

Open in new window

0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
back end of ssas cube views or tables? 2 24
Need Counts 11 40
The duplicate key value is (<NULL>) 14 43
Complex SQL 10 32
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now