Skip to content

Instantly share code, notes, and snippets.

@devzer01
Created February 14, 2020 07:24
Show Gist options
  • Save devzer01/95e6b3ef65b0c88fa6be404ee760ebae to your computer and use it in GitHub Desktop.
Save devzer01/95e6b3ef65b0c88fa6be404ee760ebae to your computer and use it in GitHub Desktop.
killing postgresql sessions
-- this query kills any active session attached to the 'dbname' database, which can prevent you from
-- running certain administrative operations on the database
select pg_terminate_backend(pid)
from pg_stat_activity
where pid IN (select pid from pg_stat_activity where datname = 'dbname');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment