MySQL Forums
Forum List  »  InnoDB

what is the best way to handle duplicate inserts?
Posted by: Matt Dunlap
Date: September 07, 2006 02:02PM

we have a blog reader that checks blogs every couple hours. It inserts new posts into our database.

I set up a unique identifier for the database table so we cannot insert duplicate posts. I think this is causing a large overhead on the server.

I tried to run a delete transaction on the table and it took forever to complete.

Should I do a select statment first and check to see if the record exists, and if it does, skip it, or am I doing it correctly with the current setup.

The current set-up basically tries to insert the data, but returns an error that it is a duplicate entry, which I ignore since it is a cron job.

basically I remove the 'or die' statment from my php
$result = mysql_query($sql) or die ("SQL Error".mysql_error());

Options: ReplyQuote


Subject
Views
Written By
Posted
what is the best way to handle duplicate inserts?
2528
September 07, 2006 02:02PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.