Created
February 11, 2019 00:16
-
-
Save Dombo/cec92c099c2b09f670528003d37dc138 to your computer and use it in GitHub Desktop.
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
WITH longrunners AS ( | |
SELECT pid, age(query_start, clock_timestamp()), query_start, usename, query | |
FROM pg_stat_activity | |
WHERE | |
now() - query_start > '3 minutes'::interval | |
AND | |
query NOT ILIKE '%vacuum%' | |
ORDER BY query_start desc | |
) | |
SELECT pg_cancel_backend(pid) | |
--- SELECT pg_terminal_backend(pid) if they do not yield | |
FROM longrunners; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment