Last Updated: February 25, 2016
·
1.26K
· agile_jordi

Monitor PostgreSQL locks

This query allows you to see the current PosgreSQL locks:

select l.locktype, t.relname, l.page, l.virtualtransaction, l.pid, l.mode, l.granted from pg_locks l, pg_stat_all_tables t where l.relation=t.relid and t.relname not in ('pg_class','pg_index','pg_namespace') order by relation asc;
  • See PosgreSQL documentation:

P.S. Without the "relname not in" part, it would always display the locks created by the query itself