Last active
June 23, 2020 15:54
-
-
Save isaaclw/284c16f375a168a13fcd12706c812a05 to your computer and use it in GitHub Desktop.
pg blocking queries #psql #db #postgres #sql
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 blocks.pid, | |
(select query from pg_stat_activity where pid = blocks.pid) as blocked_query, | |
blocks.blocking_pid, | |
(select query from pg_stat_activity where pid = blocks.blocking_pid) AS blocking_query | |
FROM ( | |
SELECT pid, unnest(pg_blocking_pids(pid)) AS blocking_pid | |
FROM pg_locks | |
WHERE granted = false | |
) AS blocks; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment