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:
- pg_locks for the meaning of each column.
- explicit locking for more information on the lock mode.
P.S. Without the "relname not in" part, it would always display the locks created by the query itself
Written by Jordi Pradel
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Posgresql
Authors
conornash
1.816K
agile_jordi
1.259K
Related Tags
#posgresql
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#