Last active
January 27, 2016 21:12
-
-
Save rafaelbernard/69b567c1c5709607d716 to your computer and use it in GitHub Desktop.
PostgreSQL - Deadlock Info
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.locktype AS waiting_locktype,w.relation::regclass AS waiting_table,w.transactionid | |
, substr(w_stm.query,1,20) AS waiting_query | |
, w.mode AS waiting_mode,w.pid AS waiting_pid,other.locktype AS other_locktype | |
,other.relation::regclass AS other_table,other_stm.query AS other_query | |
,other.mode AS other_mode,other.pid AS other_pid,other.granted AS other_granted | |
FROM pg_catalog.pg_locks AS w | |
JOIN pg_catalog.pg_stat_activity AS w_stm ON (w_stm.pid = w.pid) | |
JOIN pg_catalog.pg_locks AS other | |
ON ((w.database = other.database AND w.relation = other.relation) OR w.transactionid = other.transactionid) | |
JOIN pg_catalog.pg_stat_activity AS other_stm ON (other_stm.pid = other.pid) WHERE NOT w.granted AND w.pid <> other.pid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment