Skip to content
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 . We checked the read-only SQL, table joins, sample results and chart, and what the results mean. Who reviews this page

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.

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.

How to interpret the results

  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.

Related lessons

Keep the result

Run this query on your own events

Create a free workspace only when you are ready to save the query, connect real events, and monitor the result. No credit card is required.

Save with my events