Skip to content

Instantly share code, notes, and snippets.

@akleandrov
Created December 14, 2016 10:08
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 akleandrov/1b2d9b79f765019eda7c42ecc4c13c19 to your computer and use it in GitHub Desktop.
Save akleandrov/1b2d9b79f765019eda7c42ecc4c13c19 to your computer and use it in GitHub Desktop.
Postgres util-requests
Drop all connections
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'TARGET_DB'
AND pid <> pg_backend_pid();
Show all connections
select *
from pg_stat_activity
where datname = 'mydatabasename'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment