Skip to content

Instantly share code, notes, and snippets.

@shantanusingh
shantanusingh / deadlock-detection.md
Created June 28, 2012 20:01
Debugging Deadlocks in PostgreSQL

Queries For Deadlock Detection

select pg_class.relname,pg_locks.* from pg_class,pg_locks where pg_class.relfilenode=pg_locks.relation;

select * from pg_locks;

select * from pg_locks where granted = 'f' //the query that is waiting
select * from pg_locks where transactionid = 'xx' // queries running in a transaction
select * from pg_stat_activity