Useful Queries

* To see which postgres transactions are blocked on which postgres transactions: SELECT DISTINCT a.procpid, a.current_query, 'is waiting on' AS "is waiting on", d.procpid, d.current_query FROM pg_stat_activity a join pg_locks b ON (a.procpid = b.pid) JOIN pg_locks c ON (b.relation = c.relation) JOIN pg_stat_activity d ON (c.pid = d.procpid) WHERE a.waiting = 't' AND b.granted = 'f' AND c.granted = 't'