Skip to content

Add top blocking query finding to sp_HumanEventsBlockViewer#760

Merged
erikdarlingdata merged 1 commit intodevfrom
feature/block-viewer-top-blocking-query
Apr 10, 2026
Merged

Add top blocking query finding to sp_HumanEventsBlockViewer#760
erikdarlingdata merged 1 commit intodevfrom
feature/block-viewer-top-blocking-query

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

  • Adds check 9 ("Top Blocking Query") to the findings result set
  • Extracts the blocker's sql_handle + statement offsets from the BPR execution stack, sums wait time inflicted on blocked sessions
  • Deduplicates across monitor loops (MAX wait per victim transaction before summing) to avoid inflating numbers
  • Reports: total wait time caused, percentage of total blocking, count of distinct blocked sessions
  • 10% cutoff — only queries responsible for >= 10% of total blocking wait time are shown
  • Query text in object_name is newline-stripped and truncated to 200 chars

Test plan

  • Deployed to SQL2022, generated blocking with concurrent sessions, verified check 9 output
  • Percentages sum correctly and align with check 1000 totals
  • NULL sql_handle rows (sleeping/background blockers) excluded cleanly
  • Proc compiles without errors

🤖 Generated with Claude Code

Surfaces which queries caused the most blocking damage by extracting
the blocker's sql_handle from the execution stack and summing the wait
time inflicted on blocked sessions. Groups by (database, sql_handle,
statement offsets), deduplicates across monitor loops via MAX per victim
transaction, and reports each query's percentage of total blocking wait
time. Only queries responsible for >= 10% of total are shown.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 618d798 into dev Apr 10, 2026
5 checks passed
@erikdarlingdata erikdarlingdata mentioned this pull request Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant