Skip to content

Instantly share code, notes, and snippets.

@sasha-id
Created August 2, 2022 19:35
Show Gist options
  • Save sasha-id/a87bb7ea05aa76a9704b73d6c1656675 to your computer and use it in GitHub Desktop.
Save sasha-id/a87bb7ea05aa76a9704b73d6c1656675 to your computer and use it in GitHub Desktop.
Query to find locking pids
select pid,
usename,
pg_blocking_pids(pid) as blocked_by,
query as blocked_query
from pg_stat_activity
where cardinality(pg_blocking_pids(pid)) > 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment