To answer the question in terms of performance, I did a test using both methods
Replace Into includes: 1. Try to paste on the table
2. If 1 fails, delete the line and insert a new line
Paste into Duplicate Key Update includes: 1. Try to paste on the table
2. If 1 fails, update the line
If all steps include inserts, there should be no difference in performance. The speed should depend on the number of updates used. Worst case - when all statements are updated
I tried both statements in my InnoDB table including 62,510 records (updates only). At spreading speeds:
Replace: 77.411 seconds
Insert in renewal key update: 2.446 seconds
Insert on Duplicate Key update is almost 32 times faster.
Table size: 1,249,250 rows with 12 columns on Amazon m3.medium
katrix Jan 15 '15 at 15:28 2015-01-15 15:28
source share