Answer the question
In order to leave comments, you need to log in
How to speed up Update in a loop on a large table?
There is a table table1 with 3 million rows. There is an index on id.
It is necessary to update one field by id in a cycle in php for all rows in sequence.
I wrote a script in php, everything is fine, but every 1000 update is processed in 8 seconds. So I will wait until tomorrow)
Explain looked, the index is used. What could be the problem?
innodb table
Answer the question
In order to leave comments, you need to log in
Maybe I misunderstood, but why run a cycle here if the entire table is updated, where all IDs are sorted sequentially.
It's just possible
UPDATE table1
SET field = 'value'
1. create temporary table t_tmp ...
2. insert into t_tmp values (...), (...), ...
3. update ...
4.drop temporary table t_tmp
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question