Skip to content

Instantly share code, notes, and snippets.

@QuittyMR
Created July 17, 2020 09:33
Show Gist options
  • Save QuittyMR/9dc337908eb449faef66caeb3e3418c2 to your computer and use it in GitHub Desktop.
Save QuittyMR/9dc337908eb449faef66caeb3e3418c2 to your computer and use it in GitHub Desktop.
Retrieve locks from a Postgres DB
SELECT pg_stat_activity.pid,
pg_stat_activity.usename,
pg_blocking_pids(pg_stat_activity.pid) AS blocked_by,
pg_stat_activity.query AS blocked_query
FROM pg_stat_activity
WHERE cardinality(pg_blocking_pids(pg_stat_activity.pid)) > 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment