Created
June 1, 2012 17:20
-
-
Save cypres/2853771 to your computer and use it in GitHub Desktop.
top 10 longest running mssql queries
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
-- Clear query stats: DBCC FREEPROCCACHE | |
SELECT DISTINCT TOP 10 | |
t.TEXT QueryName, | |
s.execution_count AS ExecutionCount, | |
s.max_elapsed_time AS MaxElapsedTime, | |
ISNULL(s.total_elapsed_time / s.execution_count, 0) AS AvgElapsedTime, | |
s.creation_time AS LogCreatedOn, | |
ISNULL(s.execution_count / CAST(DATEDIFF(s, s.creation_time, GETDATE()) AS FLOAT), 0) AS FrequencyPerSec | |
FROM sys.dm_exec_query_stats s | |
CROSS APPLY sys.dm_exec_sql_text( s.sql_handle ) t | |
ORDER BY | |
s.max_elapsed_time DESC | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment