a guest Jul 15th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # PostgreSQL
  3. How to find and kill a hanging query
  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. ```
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand