MySQL — issuing low priority updates


Is there a way to execute low priority updates in mysql?

I am running a very high load application where there may easily be literally thousands of users trying to concurrently update the same data records. This is mostly session-based statistical information, much of which could be ignored in case there is a wait time associated with the request. I'd like to be able to check whether some table/row is locked, and if so just not pass an update query to the server. Is that possible?

Best Answer

What database engine are you using? MyISAM or InnoDB? If it's MyISAM, you can use the following command to view locks:


Source: How can I show mysql locks?

However, I would recommend that you take a different approach. Instead of having a single point of contention, simply insert a new row for every data-point with INSERT DELAYED. Then at the end of the day, or whenever you need the data, you can batch-process everything. Note that this only works for the MyISAM, MEMORY, and ARCHIVE engine types.


I think this question belongs over at Stack Overflow. You will probably get a better response there.

-Geoffrey Lee

Related Topic