Skip to content

Instantly share code, notes, and snippets.

@erichummel
Created April 24, 2015 14:14
Show Gist options
  • Save erichummel/c4ab294d0db7601a5fe9 to your computer and use it in GitHub Desktop.
Save erichummel/c4ab294d0db7601a5fe9 to your computer and use it in GitHub Desktop.
SQL for identifying/killing hanging queries
select count(*) from pg_stat_activity where state = 'active' and query not ilike '%stat_activity%';
SELECT pg_cancel_backend(pid) FROM pg_stat_activity where state='active' and query not ilike '%stat_activity%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment