Skip to content

Instantly share code, notes, and snippets.

@jpbruinsslot
Last active August 23, 2018 13:33
Show Gist options
  • Select an option

  • Save jpbruinsslot/e3842793d25d9f6320dd9eb0c150bc5a to your computer and use it in GitHub Desktop.

Select an option

Save jpbruinsslot/e3842793d25d9f6320dd9eb0c150bc5a to your computer and use it in GitHub Desktop.
Close postgres idle connection
-- Get pid
SELECT
pid
,datname
,usename
,application_name
,client_hostname
,client_port
,backend_start
,query_start
,query
FROM pg_stat_activity
WHERE state <> 'idle'
AND pid<>pg_backend_pid();
-- Close pid
SELECT pg_terminate_backend(PID);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment