Skip to content

Instantly share code, notes, and snippets.

@SqREL
Forked from tokenvolt/postgres_drop_connections
Last active August 29, 2015 14:17
Show Gist options
  • Save SqREL/a70dcc187cebbc18b9b8 to your computer and use it in GitHub Desktop.
Save SqREL/a70dcc187cebbc18b9b8 to your computer and use it in GitHub Desktop.
Drop postgres 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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment