Telemetry
Interactive SaaS SQL Lab

Database reliability · Intermediate

Rank database lock waits and deadlocks

Which transaction families cause the longest waits and deadlocks?

Aggregate lock events by blocked operation to prioritize the most disruptive contention.

Reviewed by the Telemetry product team on . Read-only SQL, connected-table grain, deterministic result, visualization, and interpretation boundaries. Review standards and ownership

Runs against one versioned 15-table dataset

Edit and execute the query locally in your browser, then download the same synthetic schema and rows for DuckDB.

Database reliabilityIntermediate

Rank database lock waits and deadlocks

Which transaction families cause the longest waits and deadlocks?

Aggregate lock events by blocked operation to prioritize the most disruptive contention.

The dataset and query remain in this browser.

Published expected result

Longest lock wait by operation

blocked_operationwait_eventsmax_wait_msdeadlocks
ledger_rollup26,2001
payment_update34,2001
account_update14000

How to read the query

  • The blocked operation identifies the user-facing work delayed by contention.
  • Maximum wait exposes severe tail behavior that an average can hide.
  • Deadlock counts identify transaction pairs that need ordering or scope changes.

Decisions the SQL cannot make

  1. 1Inspect transaction order for operation families with deadlocks.
  2. 2Reduce transaction scope or batch size where waits are long but eventually resolve.
  3. 3Preserve the blocking-operation field in alerts so responders know where to start.

Continue from this lesson