SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
-- don't kill my own connection!
pid <> pg_backend_pid()
-- don't kill the connections to other databases
AND datname = 'databasename';
Created
May 13, 2016 15:29
-
-
Save scisco/879c9827912dd59c5ff2ee58ff6e87a6 to your computer and use it in GitHub Desktop.
Terminate an unresponsive Postgres session
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment