"INSERT IGNORE" vs "INSERT ... ON DUPLICATE KEY UPDATE"
Asked 07 September, 2021
Viewed 673 times
  • 57
Votes

While executing an INSERT statement with many rows, I want to skip duplicate entries that would otherwise cause failure. After some research, my options appear to be the use of either:

  • ON DUPLICATE KEY UPDATE which implies an unnecessary update at some cost, or
  • INSERT IGNORE implies an invitation for other kinds of failure to slip in unannounced.

Am I right in these assumptions? What's the best way to simply skip the rows that might cause duplicates and just continue on to the other rows?

12 Answer