Blocking statistics


Job details

Name: Blocking statistics
Platform: Sqlserver
Category: Performance
Description: Collects and evaluates current blocking sessions from master..sysprocesses. Raises WARNING or ALARM when blocking wait times exceed configured thresholds, and writes qualifying events to history tables.
Long description: The procedure scans master..sysprocesses for active blockers (blocked <> 0 and waittype <> 0×0000), materializes results into a temp table, and iterates the rows to evaluate wait time (in minutes). If any session’s blocking duration meets or exceeds the warning or alarm thresholds, the job records a history event with severity and context (SPID/ECID, wait type, database, status, program, command, login). Optionally, via a capture threshold, the job can persist sub-threshold (short-lived) blocking to enable trend analysis even when no alert would fire.
Version: 2.01
Default schedule: 0,5,10,15,20,25,30,35,40,45,50,55 * * *
Requires engine install: Yes
Compatibility tag: .
.[type=‘instance’ & databasetype=‘sqlserver’]/instance[maj_version > ‘2000′ & hasengine=‘YES’ & (engine_edition = ‘Microsoft SQL Server’
engine_edition = ‘Azure SQL Managed Instance’)]

Parameters

Name Default value Description
warning threshold 5 The maximum number of minutes a session can be blocked before a warning is triggered.
alarm threshold 30 The maximum number of minutes a session can be blocked before an alarm is triggered.
capture threshold 0 Persist blocking sessions even when they do not reach warning/alarm. Any block with duration ≥ this value (minutes) is written to history with OK status. Default: 0 = disabled (legacy behavior; only warning/alarm events are stored). If set below “warning threshold”, you’ll capture short-lived blocks for trending. If set ≥ “warning threshold”, it is effectively redundant (alerts already persist data).

Job Summary

Purpose

Importance

Manual Checking

SELECT * FROM master.dbo.sysprocesses WHERE blocked != 0;

Implementation Details

Table Name Description
dbw_blocked_tab Temporary storage for current blocked sessions
dbw_blocked_histr_tab History storage for blocked sessions
dbw_blocking_tab Temporary storage for sessions that are causing the blocking
dbw_blocking_histr_tab History storage for sessions that have caused blocking

Procedures Used

Dependencies and Maintenance

Upgrade Notes

Reporting Features

Example Report Query for Blocked Sessions:

SELECT t1.spid as "Session ID", t1.blocked as "Blocked by", t2.name as "Database", t1.waittime as "Wait Time" FROM master.dbo.sysprocesses t1 JOIN master.dbo.sysdatabases t2 ON t1.dbid = t2.dbid WHERE t1.blocked != 0 ORDER BY t1.waittime DESC;

Scheduling

Acknowledgements