MCITP

MCITP

Thursday, April 7, 2011

Wait Search Query

SELECT
ws.wait_type,
ws.waiting_tasks_count,
CASE WHEN ws.waiting_tasks_count = 0 THEN 0 ELSE ws.wait_time_ms / ws.waiting_tasks_count END as average_wait_time_ms,
ws.wait_time_ms as total_wait_time_ms,
CONVERT(DECIMAL(12,2), ws.wait_time_ms * 100.0 / SUM(ws.wait_time_ms) OVER()) as wait_time_proportion,
ws.wait_time_ms - signal_wait_time_ms as total_wait_ex_signal_time_ms,
ws.max_wait_time_ms,
ws.signal_wait_time_ms as total_signal_wait_time_ms
FROM
sys.dm_os_wait_stats ws
WHERE
-- Restrict results to requests that have actually occured.
ws.waiting_tasks_count > 0
ORDER BY
ws.wait_type

No comments:

Post a Comment