Cheapest way to insert unique rows in MySQL?

I have a table with columns defined under a unique index. When pasting data into a table, I currently do not check if a suitable row already exists, instead allowing MySQL to process it.

Is this the preferred approach? I mean, I could add a SELECT to check the dupe strings before inserting, but it seems to be more expensive in terms of performance, since maybe 5-10% of the inserts will be cheating.

+3
source share
2 answers

Yes, just let MySQL understand it. He already knows what the next possible value is and will choose it much faster than you can.

select , . , , .

+2

All Articles