List:General Discussion« Previous MessageNext Message »
From:Tonu Samuel Date:January 20 2003 7:54am
Subject:Re: What is the best known practice for insertion...?
View as plain text  
On Mon, 2003-01-20 at 09:15, Zysman, Roiy wrote:
> Hi All,
> I'm trying to insert multiple lines to a table with 3 col. All 3 of them
> are a part of the primary key.
> But while inserting the data , sometime occurs the situation where I
> want to insert an already exist entry with the same keys. And mysql
> barfs out that this key already exist in the table.
> The solution to it would be probably to query for each entry that I'm
> about to insert if that entry exists , but it looks like it would be an
> enormous overhead. I'm asking this question on a _performance_ context .
> What is the best way , ignore the error messages mysql barfs out or
> query each entry for existences before inserting it ?

If SQL is well optimized, then parsing of SQL commands is most time
consuming task and can't be well optimized. To avoid this you must
reduce number of SQL commands to SQL server.

This is why I suggest trying INSERT and check for result. Double queries
mean half speed. 

Another way is of course using replicated copy where to run queries and
INSERT data on master. 

  Tõnu

Thread
What is the best known practice for insertion...?Roiy Zysman20 Jan
  • RE: What is the best known practice for insertion...?Daevid Vincent20 Jan
    • Re: What is the best known practice for insertion...?Sean Burlington20 Jan
      • Re: What is the best known practice for insertion...?Paul DuBois20 Jan
  • Re: What is the best known practice for insertion...?Tonu Samuel20 Jan
  • Re: What is the best known practice for insertion...?Sasha Pachev20 Jan
RE: What is the best known practice for insertion...?Roiy Zysman20 Jan
Re: What is the best known practice for insertion...?Steve Edberg20 Jan