Postgres locks explorer
leontrolski.github.io
leontrolski.github.io
- https://wiki.postgresql.org/wiki/Lock_Monitoring
- https://wiki.postgresql.org/wiki/Lock_dependency_information
The "Recursive view of blocking" on the second page has been extremely helpful to me. You don't ever want to need this query but if you do, it's great. You should follow the page's recommendation and set it up as a view you can use if shit ever hits the fan.
...although you may want to show all the locks each pid has acquired, instead of the summary the query gives as written, by modifying it to use
array_to_string(locks_acquired, E'\n')
instead of array_to_string(locks_acquired[1:5] ||
CASE WHEN array_upper(locks_acquired,1) > 5
THEN '... '||(array_upper(locks_acquired,1) - 5)::text||' more ...'
END,
E'\n ')