Skip to content

Instantly share code, notes, and snippets.

@songpon
Created March 2, 2017 05:40
Show Gist options
  • Save songpon/8853e48652d6faea0762fdde46c104d0 to your computer and use it in GitHub Desktop.
Save songpon/8853e48652d6faea0762fdde46c104d0 to your computer and use it in GitHub Desktop.
postresql kill all process
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