Created
October 19, 2015 05:07
-
-
Save smarenich/b98e718b19b3555f708c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT top 30 total_worker_time/execution_count AS AvgCPU | |
, total_worker_time AS TotalCPU | |
, total_elapsed_time/execution_count AS AvgDuration | |
, total_elapsed_time AS TotalDuration | |
, (total_logical_reads+total_physical_reads)/execution_count AS AvgReads | |
, (total_logical_reads+total_physical_reads) AS TotalReads | |
, execution_count | |
, SUBSTRING(st.TEXT, (qs.statement_start_offset/2)+1 | |
, ((CASE qs.statement_end_offset WHEN -1 THEN datalength(st.TEXT) | |
ELSE qs.statement_end_offset | |
END - qs.statement_start_offset)/2) + 1) AS txt | |
, query_plan | |
FROM sys.dm_exec_query_stats AS qs | |
cross apply sys.dm_exec_sql_text(qs.sql_handle) AS st | |
cross apply sys.dm_exec_query_plan (qs.plan_handle) AS qp | |
where SUBSTRING(st.TEXT, (qs.statement_start_offset/2)+1 | |
,((CASE qs.statement_end_offset WHEN -1 THEN datalength(st.TEXT) | |
ELSE qs.statement_end_offset | |
END - qs.statement_start_offset)/2) + 1) like '%' | |
ORDER BY 4 DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment