SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE pid <> pg_backend_pid()
AND state = 'idle'
AND state_change < current_timestamp - INTERVAL '5' MINUTE;
Created
December 5, 2014 09:48
-
-
Save danishabdullah/315c74101f3d10283599 to your computer and use it in GitHub Desktop.
Kill Idle Connections in Postgresql
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment