Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. # PostgreSQL
  2.  
  3. How to find and kill a hanging query
  4.  
  5. First, check all the processes that are running:
  6. ```
  7. SELECT * FROM pg_stat_activity WHERE state = 'active';
  8. ```
  9. So you can identify the PID of the hanging query you want to terminate, run this:
  10. ```
  11. SELECT pg_cancel_backend(PID);
  12. ```
  13. This query might take a while to kill the query, so if you want to kill it the hard way, run this instead:
  14. ```
  15. SELECT pg_terminate_backend(PID);
  16. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement