Skip to content

Instantly share code, notes, and snippets.

@marcotc
Last active September 25, 2017 16:53
Show Gist options
  • Save marcotc/6aff8740ad259366df63cd2ef969f6fb to your computer and use it in GitHub Desktop.
Save marcotc/6aff8740ad259366df63cd2ef969f6fb to your computer and use it in GitHub Desktop.
Retrieve and kill current Postgres queries
SELECT pid, age(query_start, clock_timestamp()), state, query FROM pg_stat_activity WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' and state = 'active' ORDER BY age(query_start, clock_timestamp());
--select pg_cancel_backend(123456);-- Kill by PID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment