Last active
November 21, 2019 11:15
-
-
Save fljdin/ba29a78f6456cf3e6782baa94cf7e3f8 to your computer and use it in GitHub Desktop.
Detect blocked and blocking sessions in PostgreSQL 9.6+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT pid, state, | |
CASE WHEN wait_event is not null | |
THEN concat(wait_event, ' (', wait_event_type, ')') | |
ELSE NULL::text END AS lock_intel, | |
pg_blocking_pids(pid) AS blocked_by, | |
substr(query, 1, 20) | |
FROM pg_stat_activity | |
WHERE state IS NOT NULL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment