Which of the following three solutions is the fastest. D1_d is sent to Forum section ------------------------------------------------------- Section No. No0 dedecmsD8888D. the following d1_d is sent to Forum section -------------------------------------------------------
Section No0 dedecms
D8888D post title -------------------------------------------------------
Which of the following three solutions is the fastest?
D8888D Main Post content -------------------------------------------------------
Mysql table
Fields a, B, c, d, e, and f
A is the primary key and the type is vachar (20)
Update now, with a total of 10 thousand records
Execute the following statement 10 thousand times without using transactions
Solution 1:
UPDATE table SET B = 222, c = 333, d = 444 WHERE a = xx
Solution 2:
Replace into table VALUES ($ a, $ B, $ c, $ d, $ e, $ f)
Solution 3:
Wait for you to write
Let me answer
D8888D reply content -------------------------------------------------------
1.
D8888D reply content -------------------------------------------------------
I also want to know this question.
D8888D reply content -------------------------------------------------------
Solution 3 !~ [Img] http://www.phpchina.com/bbs/images/smilies/default/policy.gif#/img]
D8888D reply content -------------------------------------------------------
Should there be no difference?
D8888D reply content -------------------------------------------------------
The landlord seems to be working on data synchronization.
There are three requirements for data synchronization: add, delete, and modify.
Solution 1 only meets the needs of the change.
Solution 2 meets the needs for addition and modification.
D8888D reply content -------------------------------------------------------
Encapsulation INTO a replace into statement may be more efficient, because you only need to send a command once to the database server, as shown in the following code:
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 Mark 6 # [/url] faallan
Well!
However, I only need to change it and do not need to add it.
D8888D reply content -------------------------------------------------------
[Url = http://bbs.phpchina.com/redirect.php? Goto = findpost & pid = 1067568 & ptid = 126860] link Mark 7 # [/url] Luyou baby
Replace into is actually a secondary query, which is deleted before being added.
However, you can merge a few sentences at a time without a transaction.
Because deletion is performed before addition, I don't know what will happen in high concurrency, so I need to take care of the Read
No actual tests yet. I don't know how fast it can be.
Notice No0 plate dededecms D8888D sub-title --------------------------------------------------------- below...