Last active
August 29, 2015 14:01
-
-
Save pshen/5a6e92aa20d8c091821d to your computer and use it in GitHub Desktop.
Who is blocking? PG>9.2
This file contains hidden or 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 | |
w.query as waiting_query, | |
w.pid as w_pid, | |
w.usename as w_user, | |
l.query as locking_query, | |
l.pid as l_pid, | |
l.usename as l_user, | |
t.schemaname || '.' || t.relname as tablename | |
from pg_stat_activity w | |
join pg_locks l1 on w.pid = l1.pid and not l1.granted | |
join pg_locks l2 on l1.relation = l2.relation and l2.granted | |
join pg_stat_activity l on l2.pid = l.pid | |
join pg_stat_user_tables t on l1.relation = t.relid | |
where w.waiting; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment