my question is: what is the fastest way to do the work?
i dont know ... have anyone do something like this? what is the best practise? i need to run it as fast as possible ...
Here's some ways you could speed up your UPDATES
.
When you UPDATE
, the table records are just being rewritten with new data. And all this must be done again on INSERT
. That's why you should always use INSERT ... ON DUPLICATE KEY UPDATE
instead of REPLACE
.
The former one is an UPDATE
operation in case of a key violation, while the latter one is DELETE / INSERT
Here's an example INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1;
More on this here .
UPDATE1: It's a good idea to do your inserts all in a single query. This should speed up your UPDATES
. See here on how to do that.
UPDATE2: Now that I have had a chance to read your other sub-questions. Here's what I know-
UPDATE
in a single sql & single commit. SQL
queries are more important. TABLE
& the INDEXES
you have, plus INNODB or MYISAM
. slow_query_log
turned on. This logs all slow queries to a separate logfile. Turn this off too. query execution process: Server first parsing your query then execute you need to analysis
the query
then server take less time to parse then he execute faster instead of slow in other way
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.