How would you debug a sudden, unexplained throughput drop in a high-performance PostgreSQL database under concurrent write-heavy workloads?
Write a PostgreSQL query over the diagnostic snapshots to identify current lock contention and compare each affected query's current five-minute call rate with its preceding five-minute rate.
Output
- One row per currently blocked session and matching blocker.
- Include
blocked_pid, blocker_pid, lock_key, blocked_seconds, blocked_query, blocker_query, query_id, current_calls, previous_calls, and throughput_ratio.
- Include only current blocked sessions with a known blocker. Sort by
blocked_seconds descending, then both process IDs ascending.