Last active
February 19, 2018 17:51
-
-
Save bradurani/49c727b7dd997ce62009d0fb972b0229 to your computer and use it in GitHub Desktop.
cancel old 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 | |
pg_cancel_backend(pid), | |
now()-pg_stat_activity.query_start AS duration, | |
query, | |
state | |
FROM pg_stat_activity | |
WHERE (now()-pg_stat_activity.query_start) > interval '1 day'; | |
SELECT pg_sleep(30); | |
SELECT | |
pg_terminate_backend(pid), | |
now()-pg_stat_activity.query_start AS duration, | |
query, | |
state | |
FROM pg_stat_activity | |
WHERE (now()-pg_stat_activity.query_start) > interval '1 day'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment