I have this temp table that holds the data to be modified in table1, to update table1 I use the query:
UPDATE table1 pr
INNER JOIN tmpTable tmp
ON (pr.product_id = tmp.product_id)
SET pr.isactive = tmp.isactive
But since tmpTable holds huge amount of data to update, my query sometimes ending up to ‘timeout’. So my question is, what’s basically the simplest way to update my data by batch? say, by 10K.
Thanks in advance!
You tagged this in PHP so I’m assuming you’re willing to do some work with in there and not just in a single query. Run the query multiple times. Something like
If you’re running MyISAM you risk things ending up in a partially completed state this way or yours. If your running innodb and want to maintain the all or nothing aspecs of a transaction you’ll have to wrap that loop in a begin/commit. But, then you’ll have the deal with the fallout of having potentially overlly large transactions.
If you can provide more details on your specifics I can go deeper down that route.