Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

INSERT IGNORE & UPDATE VS INSERT...ON DUPLICATE KEY UPDATE [duplicate]

Tags:

mysql

Is there any different in performance between the following:

(1) Two statements

INSERT IGNORE...
UPDATE...

(2) One statement

INSERT INTO...ON DUPLICATE KEY UPDATE

Note that while this question "INSERT IGNORE" vs "INSERT ... ON DUPLICATE KEY UPDATE" asks about the difference between INSERT IGNORE and INSERT...ON DUPLICATE KEY UPDATE I'm more concerned about which of the above two patters (using one statement, or two) would perform better.

like image 660
David542 Avatar asked Jun 06 '26 16:06

David542


1 Answers

ON DUPLICATE KEY is faster than INSERT IGNORE, but failing with a duplicate key error is a lot faster

like image 95
gtzinos Avatar answered Jun 10 '26 15:06

gtzinos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!