Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # PostgreSQL
- How to find and kill a hanging query
- First, check all the processes that are running:
- ```
- SELECT * FROM pg_stat_activity WHERE state = 'active';
- ```
- So you can identify the PID of the hanging query you want to terminate, run this:
- ```
- SELECT pg_cancel_backend(PID);
- ```
- This query might take a while to kill the query, so if you want to kill it the hard way, run this instead:
- ```
- SELECT pg_terminate_backend(PID);
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement