Skip to content

Instantly share code, notes, and snippets.

View dcragusa's full-sized avatar

David Ragusa dcragusa

  • L4 Software Engineer at Google
  • San Mateo
View GitHub Profile
@dcragusa
dcragusa / stuck.sql
Last active May 1, 2018 07:00
View and deal with stuck queries on Postgres
-- 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