First time running queries in rails console...
I had a query run accidentally: something like this
User.where(:location => 'US'))
which apparently is pulling me quite amount of data.
Now the query is still hanging there. I know I could just close this session and restart another. But I just would like to know the safest way to kill a query. Is there something similar like in mysql :
show full processlist
and
kill #
When I want to stop a long running query, I typically just go up the chain of interrupts.
ctrl c
will send SIGINT and hopefully just take you out of the current query or loop in the console. But, sometimes, this won't work so I go up a step to
ctrl \
which will send SIGQUIT to quit the current process. This command will exit out of the rails console and back in to the terminal (assuming you launched the console from rails c
)
As a worst case scenario I will go to use ctrl z
which will suspend the process allowing you to find the process ID (using top
or ps
or whatever else) and then use kill
on that pid. If that doesn't work the final thing to use is kill -9
which will kill the process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With