I have a very slow query that I need to run on a MySQL database from time to time.
I've discovered that attempts to update the table that is being queried are blocked until the query has finished.
I guess this makes sense, as otherwise the results of the query might be inconsistent, but it's not ideal for me, as the query is of much lower importance than the update.
So my question really has two parts:
1) Out of curiosity, what exactly does MySQL do in this situation? Does it lock the table for the duration of the query? Or try to lock it before the update?
2) Is there a way to make the slow query not blocking? I guess the options might be: i) Kill the query when an update is needed. ii) Run the query on a copy of the table as it was just before the update took place iii) Just let the query go wrong.
Anyone have any thoughts on this?
Thanks,
Ben