Last active
May 1, 2018 07:00
-
-
Save dcragusa/12bf05e0c98a6c6f6ae8843f9f82fa63 to your computer and use it in GitHub Desktop.
View and deal with stuck queries on Postgres
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
-- View activity | |
select datname,usename,pid,client_addr,waiting,query_start,query from pg_stat_activity; | |
-- View locks | |
select * from pg_locks where relation=(select oid from pg_class where relname='tablename_str'); | |
select pg_cancel_backend(pid_int); -- ask nicely | |
select pg_terminate_backend(pid_int); -- rude |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment