mysql -- most efficient way to batch process UPDATES
Hey all. I currently have a program that can be launched by the user of which does processing on their records specific. Part of the process is to select out specific records and make an update to them with the recently pulled ID.
Currently I am running the program to batch update in groups of 25. I will select 25 records that need updated, and once they are all pulled in, update each specific row with its new data.
The problem this poses is that I do not want to try and do this as efficiently as possible (since it is an unknown as to how many users may launch this at anyone time).
Doing a UPDATE query call for each iteration is unacceptable (I think anyways).
and for some reason, mysqli_multi_query took almost twice the amount of time as an acutal individual call to each update.
Does anyone know the basics behind how transactions work? If i loop over the updates within a transaction, then call a commit at the end does this force it to truely be done within 1 call? or does will it still make 25 seperate calls to the database for the update?
Can you give us the specifics of the query itself? In other words, is it something like your example where you're setting the same value for every record that match on a set of record ID values?
If that's the case, then use a single query referencing a list of ID values using the IN operator, e.g.
InnoDB -- I need the huge maximum record count as well as row level locking for speed.
Right ~ These updates are unique values to each row pulled from another source, so the above will not work.
Each row will be updated based on the WHERE clause to single it down... however the values being updated are completely irrelevant from one row to another.
Anyone have any insight or tips into this? I tried searching around, but am not getting a very definative answer on how transactions are processed with multiple queries. I know there will be 25 seperate queries fired off... however I am curious as to whether or not it sends the query with each request, or will wait for the final commit to be made. Obviously before the commit happens, the changes wont happen yet... however I think they go to some type of staging area in the table with each request? Am I way off on this one?
|All times are GMT. The time now is 09:14 PM.|
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0