Skip to content

Instantly share code, notes, and snippets.

@bassu
Created August 20, 2018 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bassu/67733fc891afc2c8c8516f8a289791e0 to your computer and use it in GitHub Desktop.
Save bassu/67733fc891afc2c8c8516f8a289791e0 to your computer and use it in GitHub Desktop.
pgsql locks monitoring
SELECT a.datname,
c.relname,
l.transactionid,
l.mode,
l.GRANTED,
a.usename,
a.query,
a.query_start,
age(now(), a.query_start) AS "age",
a.pid
FROM pg_stat_activity a
JOIN pg_locks l ON l.pid = a.pid
JOIN pg_class c ON c.oid = l.relation
ORDER BY a.query_start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment