Here is a script to check table level locks
SELECT act1.query as blocking_query, act2.query as blocked_query, l1.pid AS blocked_pid, l2.pid AS blocking_pid, l1.relation :: regclass FROM pg_locks l1, pg_locks l2, pg_stat_activity act1, pg_stat_activity act2 WHERE l1.granted = true AND l2.granted = false AND l1.pid = act1.pid AND l2.pid = act2.pid AND l1.relation = l2.relation;
Cheers!
Leave a Reply