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?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.