This file contains hidden or 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
| -- Queries running longer than 2 mins | |
| SELECT pid, now() - query_start as "runtime", usename, datname, state, now() - state_change as "state_changed_age", wait_event_type, wait_event, query | |
| FROM pg_stat_activity | |
| WHERE now() - query_start > '2 minutes'::interval and state = 'active' | |
| ORDER BY runtime DESC; | |
| -- Query to kill queries | |
| SELECT pg_cancel_backend(pid) | |
| FROM pg_stat_activity | |
| WHERE now() - query_start > '2 minutes'::interval and state = 'active' |