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
DO $$DECLARE row record; | |
BEGIN | |
FOR row IN SELECT pid, query FROM pg_stat_activity WHERE query_start < NOW() - interval '30 minutes' LOOP | |
RAISE NOTICE 'Killing query: %s', row.query; | |
PERFORM pg_cancel_backend(row.pid); | |
END LOOP; | |
END$$; |