I started by googling, and found this article which talks about mutex tables.
I have a table with ~14 million records. If I want to add more data in the same format, is there a way to ensure the record I want to insert does not already exist without using a pair of queries (ie, one query to check and one to insert is the result set is empty)?
Does a unique
constraint on a field guarantee the insert
will fail if it's already there?
It seems that with merely a constraint, when I issue the insert via php, the script croaks.
on duplicate key update, or insert ignore can be viable solutions with MySQL.
Example of on duplicate key update update based on mysql.com
Example of insert ignore based on mysql.com
Or:
Or:
Try the following:
Try:
Or you can do:
This method is fast and easy. For improve the speed of the query in your big table INDEX columns 'xxx' ( In my example ).