Top 10 Queries by Total CPU Time
A query that lists the top ten queries by total CPU time with per-execution averages.
The cumulative CPU heavyweight list: this query joins dm_exec_query_stats to the SQL text and plan, computes elapsed time per execution, and returns the top ten - with statement text extracted from each batch. Since these numbers are cumulative since the last cache clear, they highlight the queries that have burned the most CPU overall.
SELECT TOP 10
SUBSTRING(text, (statement_start_offset/2) + 1, ((CASE statement_end_offset
WHEN -1 THEN DATALENGTH(text) ELSE statement_end_offset
END - statement_start_offset)/2) + 1) AS query_text,
total_elapsed_time/execution_count AS cpu_per_exec,
*
FROM
sys.dm_exec_query_stats
CROSS APPLY
sys.dm_exec_sql_text(sql_handle)
CROSS APPLY
sys.dm_exec_query_plan(plan_handle)
ORDER BY
total_elapsed_time/execution_count DESC;