Created
August 28, 2015 17:16
-
-
Save skehlet/fbf5f52e18149e14e520 to your computer and use it in GitHub Desktop.
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 | |
COALESCE(blockingl.relation::regclass::text,blockingl.locktype) as locked_item, | |
blockeda.procpid AS blocked_pid, | |
blockeda.current_query as blocked_query, | |
blockedl.mode as blocked_mode, | |
blockinga.procpid AS blocking_pid, | |
blockinga.current_query as blocking_query, | |
blockingl.mode as blocking_mode | |
FROM pg_catalog.pg_locks blockedl | |
JOIN pg_stat_activity blockeda ON blockedl.pid = blockeda.procpid | |
JOIN pg_catalog.pg_locks blockingl ON ( | |
( blockingl.transactionid=blockedl.transactionid | |
OR | |
(blockingl.relation=blockedl.relation AND blockingl.locktype=blockedl.locktype) | |
) | |
AND blockedl.pid != blockingl.pid | |
) | |
JOIN pg_stat_activity blockinga ON blockingl.pid = blockinga.procpid | |
WHERE NOT blockedl.granted; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment