Created
June 7, 2017 11:45
-
-
Save dapi/2ac868d605416921e251163a9955ce3a to your computer and use it in GitHub Desktop.
Finding and killing long running queries on PostgreSQL
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, now() - query_start as duration, query, state FROM pg_stat_activity WHERE now() - query_start > interval '5 minutes'; | |
;; cancel | |
SELECT pg_cancel_backend(__pid__); | |
;; kill stucked | |
SELECT pg_terminate_backend(__pid__); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment