This
script produces a list of queries, the max and average execution time
plus the number of executions since the last DBCC call.
SELECT DISTINCT TOP
10
t.
TEXT AS
QueryName
,
s.execution_count
AS
ExecutionCount
,
s.max_elapsed_time
AS
MaxElapsedTime
,
ISNULL
(
s.total_elapsed_time
/
1000
/
NULLIF
(
s.execution_count
,
0
),
0
)
AS A
vgElapsedTime
,
s.creation_time
AS
LogCreatedOn
,
ISNULL
(
s.execution_count
/
1000
/
NULLIF
(
DATEDIFF
(
s
,
s.creation_time
,
GETDATE
()),
0
),
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
,
ExecutionCount
DES
C
GO
No comments:
Post a Comment