3

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.

Community
  • 1
  • 1
David542
  • 104,438
  • 178
  • 489
  • 842

1 Answers1

2

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

Yves M.
  • 29,855
  • 23
  • 108
  • 144
gtzinos
  • 1,205
  • 15
  • 27
  • You can read this link too : http://www.eddieoneverything.com/programming/mysql-performance-tip-on-duplicate-key-is-faster-than-insert-ignore-but-failing-with-a-duplicate-key-error-is-a-lot-faster.php – gtzinos May 18 '15 at 19:53