Skip to content

Instantly share code, notes, and snippets.

@bonyiii
Created May 13, 2011 10:49
Show Gist options
  • Select an option

  • Save bonyiii/970337 to your computer and use it in GitHub Desktop.

Select an option

Save bonyiii/970337 to your computer and use it in GitHub Desktop.
forcibly kill idle postgresql process
http://www.postgresql.org/docs/current/static/functions-admin.html#FUNCTIONS-ADMIN-SIGNAL-TABLE
http://www.postgresql.org/docs/current/static/monitoring-stats.html#MONITORING-STATS-VIEWS
http://stackoverflow.com/questions/727194/force-client-disconnect-using-postgresql
SELECT pg_stat_get_backend_pid(s.backendid) AS procpid,
pg_stat_get_backend_activity(s.backendid) AS current_query
FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s;
# OR
SELECT procpid,current_query from pg_stat_activity WHERE current_query LIKE '<IDLE>';
SELECT procpid, (SELECT pg_terminate_backend(procpid)) as got_killed from pg_stat_activity WHERE current_query LIKE '<IDLE>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment