Created
April 10, 2024 09:51
-
-
Save Apurer/9b8ca330ef21f5036ad772a4368d18c5 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 10 | |
qs.total_elapsed_time / qs.execution_count AS average_execution_time, | |
qs.execution_count, | |
qs.total_logical_reads / qs.execution_count AS average_logical_reads, | |
qs.total_physical_reads / qs.execution_count AS average_physical_reads, | |
SUBSTRING(qt.text, (qs.statement_start_offset/2) + 1, | |
((CASE qs.statement_end_offset | |
WHEN -1 THEN DATALENGTH(qt.text) | |
ELSE qs.statement_end_offset | |
END - qs.statement_start_offset)/2) + 1) AS query_text, | |
qp.query_plan | |
FROM sys.dm_exec_query_stats qs | |
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) qt | |
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp | |
ORDER BY average_execution_time DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment