存储过程执行情况
SELECT OBJECT_NAME(object_id, database_id) 存储过程名 ,
d.cached_time 编译时间 ,
d.last_execution_time 最近一次执行时间ms ,
d.total_elapsed_time / 1000 总花费时间ms ,
d.total_elapsed_time / d.execution_count * 1000 AS 平均执行时间ms ,
d.last_elapsed_time 最近一次执行花费时间ms ,
d.execution_count 执行次数
FROM sys.dm_exec_procedure_stats AS d
WHERE OBJECT_NAME(object_id, database_id) IN (
SELECT name
FROM sys.objects
WHERE TYPE = 'p'
AND modify_date > '2008-2-24 17:32:50' )
ORDER BY 6 DESC ;
--存储过程执行情况
SELECT s.name ,
d.total_elapsed_time ,
d.total_elapsed_time / d.execution_count AS [avg_elapsed_time] ,
d.execution_count ,
total_physical_reads ,
total_logical_writes ,
total_logical_reads
FROM sys.procedures s
INNER JOIN sys.dm_exec_procedure_stats d ON s.object_id = d.object_id
ORDER BY d.execution_count DESC ;
GO