Last active
September 25, 2017 16:53
-
-
Save marcotc/6aff8740ad259366df63cd2ef969f6fb to your computer and use it in GitHub Desktop.
Retrieve and kill current Postgres queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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