sys.dm_exec_procedure_stats
The sys.dm_exec_procedure_stats DMV is like sys.dm_exec_query_stats in that it contains cumulative execution statistics for query plans in the cache, but at the stored procedure level rather than the query level. Stored procedures may contain T-SQL code constructs other than queries, such as conditional logic, variable assignments, and function calls. These constructs consume resources, but they aren't accounted for in sys.dm_exec_query_stats because they aren't queries. This DMV can be used to determine the total resource consumption of the procedure as a whole, including code that is not accounted for in sys.dm_exec_query_stats.
The following example shows a stored procedure that contains some conditional logic ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access