Created
April 23, 2015 20:09
-
-
Save hanleybrand/6083357f491ee1e0d0be to your computer and use it in GitHub Desktop.
Expensive queries ordered by CPU
This file contains hidden or 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
| /* Expensive queries ordered by CPU */ | |
| SELECT TOP 20 | |
| st.text, | |
| --qp.query_plan, | |
| qs.execution_count, | |
| qs.total_worker_time AS Total_CPU, | |
| total_CPU_inSeconds = --Converted from microseconds | |
| qs.total_worker_time/1000000, | |
| average_CPU_inSeconds = --Converted from microseconds | |
| (qs.total_worker_time/1000000) / qs.execution_count, | |
| qs.total_elapsed_time, | |
| total_elapsed_time_inSeconds = --Converted from microseconds | |
| qs.total_elapsed_time/1000000, | |
| qs.total_logical_reads, qs.last_logical_reads, | |
| qs.total_logical_writes, qs.last_logical_writes | |
| 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 | |
| ORDER BY qs.total_worker_time DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment