1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
WITH
CTE_WAIT AS
(
SELECT wait_type,
wait_time_ms / 1000.0 AS wait_time_s,
100.0 * wait_time_ms / SUM(wait_time_ms) OVER() AS pct,
ROW_NUMBER() OVER(ORDER BY wait_time_ms DESC) AS n
FROM sys.dm_os_wait_stats
WHERE wait_type NOT IN
(
'CLR_SEMAPHORE', 'LAZYWRITER_SLEEP', 'RESOURCE_QUEUE'
, 'SLEEP_TASK', 'SLEEP_SYSTEMTASK', 'SQLTRACE_BUFFER_FLUSH'
, 'WAITFOR', 'CLR_AUTO_EVENT', 'CLR_MANUAL_EVENT'
)
)
SELECT W.wait_type,
CAST(W.wait_time_s AS decimal(12,2)) AS wait_time_s,
CAST(W.pct AS decimal(4,2)) AS pct,
CAST(SUM(W2.pct) AS decimal(12,2)) AS running_pct
FROM CTE_WAIT AS W
INNER JOIN CTE_WAIT AS W2 ON W2.n <= W.n
GROUP BY W.n,
W.wait_type,
W.wait_time_s,
W.pct
HAVING SUM(W2.pct) - W.pct < 95 |
Partager