0

So I currently am trying to insert a row into a MEMORY table but only if the primary key doesn't already exist.

I'm using INSERT IGNORE but I was reading, much to my surprise, that INSERT IGNORE is actually slower than INSERT ... ON DUPLICATE KEY, but that letting the regular INSERT just fail is faster than both of them.

In this particular case, it's a MEMORY table (as mentioned), and I am expecting the primary key already exists 90% of the time. In that case, does it make more sense to use INSERT and let the MySQL error out as opposed to using INSERT IGNORE? Are there any other things I need to consider here, such as a write in the file system error log no longer making it faster than INSERT IGNORE?

2
Contributors
1
Reply
32
Views
3 Years
Discussion Span
Last Post by pritaeas
0

does it make more sense to use INSERT and let the MySQL error out as opposed to using INSERT IGNORE?

I've used this once in the past on a separate DB, so I had the option to turn error logging off. Is hard to time, but log writes are slow, especially when using a memory table.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.