Answer the question
In order to leave comments, you need to log in
How can I speed up an UPDATE query in MySQL?
There is a database for 357751 lines, you need to update all lines (UPDATE position SET allow = 'N' WHERE is_client IN ( 'Y', 'N' )). Initially, it took ~6.4 seconds, after removing the allow index, the update took 5.2 seconds. Is there any other way to speed up this query? The table is MyISAM, there are already 10 other indexes, but they do not concern the fields that are in the update (allow, I erased).
Answer the question
In order to leave comments, you need to log in
As an experiment
UPDATE position SET allow = 'N' WHERE allow <> 'N' AND is_client IN ( 'Y', 'N' )
+ add paired index (allow, is_client)
1. Create index for is_client
2. Replace query with
UPDATE `position` SET `allow`='N' WHERE `is_client`='Y'
, if there are no other values in the is_client field except Y and NDidn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question