Home > Backend Development > PHP Tutorial > Which of the following 3 options is the fastest_PHP Tutorial

Which of the following 3 options is the fastest_PHP Tutorial

WBOY
Release: 2016-07-13 10:51:20
Original
990 people have browsed it

D0000D sent to the forum section--------------------------------------------- -------------
No.0 plate dedecms
D8888D post title------------------------------------------------- ----------
Which of the following three options is the fastest?
D8888D main post content------------------------------------------------- ----------


mysql table
a, b, c, d, e, f fields

a is the primary key, type is vachar(20)

Now we need to update, there are 10,000 records in total
To execute the following statement 10,000 times without using transactions

Option 1:
UPDATE table SET b = 222, c = 333, d = 444 WHERE a = xx

Option 2:
REPLACE INTO table VALUES($a,$b,$c,$d,$e,$f)

Option 3:
Waiting for you to write

Let me answer




D8888D reply content------------------------------------------------- ----------
1.

D8888D reply content------------------------------------------------- ----------
I also want to know about this issue, please help me.

D8888D reply content------------------------------------------------- ----------
Option 3! ~[img]http://www.phpchina.com/bbs/images/smilies/default/victory.gif[/img]

D8888D reply content------------------------------------------------- ----------
There should be no difference, right?

D8888D reply content------------------------------------------------- ----------
The author seems to be working on data synchronization.
There are three requirements for data synchronization: addition, deletion, and modification.
Option 1 only meets the needs for modification.
Option 2 meets the needs for additions and modifications.

D8888D reply content------------------------------------------------- ----------
It may be more efficient to encapsulate it into a REPLACE INTO statement, because you only need to send an instruction to the database server once, like this:

REPLACE INTO table VALUES (1, 1, 1, 1),(2, 1, 1, 1),(3, 1, 1, 1),(4, 1, 1, 1);

D8888D reply content------------------------------------------------- ----------
[url=http://bbs.phpchina.com/redirect.php?goto=findpost&pid=1067540&ptid=126860]Link tag 6#[/url] faallan

Yes!

But I only need to change it, not add anything.

D8888D reply content------------------------------------------------- ----------
[url=http://bbs.phpchina.com/redirect.php?goto=findpost&pid=1067568&ptid=126860]Link tag 7#[/url] Road Trip Baby

replace into is actually a secondary query, first delete and then add
But the advantage is that you can merge several sentences at a time when you are not using the transaction
Since we delete first and then add, I don’t know what will happen under high concurrency. We need to take care of reading
I haven’t actually tested it yet, so I don’t know how much faster it can be


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632569.htmlTechArticleD0000D sent to the forum section ------------------- ------------------------------------ No.0 plate dedecms D8888D post title ------ ------------------------------------------------- the following ...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template