Created
April 14, 2022 20:36
-
-
Save akramarev/892a813c3103608e78d299fa48ab5561 to your computer and use it in GitHub Desktop.
[kill connections in postgres]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = 'database_name' | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment