# Stored procedure performance metrics

I am taking over a new project which is having ~2500 SPs! and would like to know at current state what is the maximum / minimum time taken by each of the stored procs. Also IO, Logical Reads used by each of the SPs. Would like to benchmark it that way. After each new drop would use this benchmark to compare whether the changes done has helped or not.

Can DMVs or Extended Events be of help here? or do i need to run a trace covering my complete work load to capture this?

-

## migrated from stackoverflow.comFeb 16 '13 at 21:48

This question came from our site for professional and enthusiast programmers.

SQL Server Profiler is your friend - msdn.microsoft.com/en-us/library/ms181091.aspx. While you can trace individual queries running analysis on the whole system under real load is more useful as it helps identify locking contention and other perf issues that isolated testing might not find –  Offbeatmammal Feb 16 '13 at 4:11

This will get you the top 100 with the highest average duration since the last service restart. This DMV is reset when SQL Server restarts, so if you need to go beyond that, you'll need to trace, use extended events, use auditing of some kind (built-in or manual), or invest in a 3rd party monitoring tool.

You can adjust that obviously, or go after different metrics such as physical or logical reads...

USE [Your Database Name];
GO

SELECT TOP (100)
OBJECT_SCHEMA_NAME([object_id]),
OBJECT_NAME([object_id]),
type_desc,
cached_time,
last_execution_time,
execution_count,
total_worker_time,
last_worker_time,
min_worker_time,
max_worker_time,
total_logical_writes,
last_logical_writes,
min_logical_writes,
max_logical_writes,