Created
February 27, 2022 02:40
-
-
Save ricardopadua/392a3dd9e0d102aa367ac7120a600813 to your computer and use it in GitHub Desktop.
kill all 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
-- identify all connection in host | |
select datname, | |
pid, | |
usename, | |
application_name, | |
client_addr, | |
client_hostname, | |
backend_start | |
from pg_stat_activity | |
-- kill single connection parse pid | |
select pg_terminate_backend(pid); | |
-- kill all connections | |
select pg_terminate_backend(pid) | |
from pg_stat_activity | |
where pid pg_backend_pid(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment