Skip to content

Instantly share code, notes, and snippets.

@source-c
Created September 22, 2022 12:36
Show Gist options
  • Save source-c/6d390eda41f952fdd8fad7961183d9ba to your computer and use it in GitHub Desktop.
Save source-c/6d390eda41f952fdd8fad7961183d9ba to your computer and use it in GitHub Desktop.
PG list blocked queries/clients
SELECT
activity.pid,
activity.usename,
activity.query,
blocking.pid AS blocking_id,
blocking.query AS blocking_query
FROM pg_stat_activity AS activity
JOIN pg_stat_activity AS blocking ON blocking.pid = ANY(pg_blocking_pids(activity.pid));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment