Skip to content

Instantly share code, notes, and snippets.

@joshwiens
Created January 6, 2017 22:06
Show Gist options
  • Save joshwiens/36044676d1941f1192da9320edfba459 to your computer and use it in GitHub Desktop.
Save joshwiens/36044676d1941f1192da9320edfba459 to your computer and use it in GitHub Desktop.
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE datname = 'regress'
AND pid <> pg_backend_pid()
AND state = 'idle'
AND state_change < current_timestamp - INTERVAL '1' MINUTE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment