Here are some ways to speed up your UPDATES .
When you UPDATE , the table entries are simply overwritten with the new data. And all this needs to be done again at INSERT . That is why you should always use INSERT ... ON DUPLICATE KEY UPDATE instead of REPLACE .
The first UPDATE operation in case of a key violation, and the second - DELETE / INSERT
Here is an example INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1; Read more about it here .
UPDATE1: It is recommended that you do your insertions in a single query. This should speed up your UPDATES . See here for how to do this.
UPDATE2: Now I had the opportunity to read your other questions. Here is what I know -
- and not in a loop, try to execute all
UPDATE in one sql and single commit. - Not sure if that will make a difference.
SQL more important. - Now you can experiment with this. Rate it. It depends on the size of
TABLE and INDEXES , plus INNODB or MYISAM . - I donβt know about that.
- refer to the first point.
- Yes, it can speed things up a bit. Also check if
slow_query_log is slow_query_log . This writes all slow requests to a separate log file. Turn it off. - Again. refer to the first point.
source share