List:General Discussion« Previous MessageNext Message »
From:Jay Miller Date:August 24 1999 9:30pm
Subject:RE: update? insert? Perl script
View as plain text  
In a case like this we are using REPLACE, which performs a DELETE and
INSERT.  This is easier than checking first and either UPDATEing or
INSERTing.  I'm sure it places a higher load on the MySQL server, but it
takes some off of the client and possibly reduces some network traffic.

Any thoughts?

-----Original Message-----
From: Paul DuBois [mailto:paul@stripped]
Sent: Tuesday, August 24, 1999 4:24 PM
To: Dan Ray; Paul DuBois; gl3; mysql@stripped
Subject: RE: update? insert? Perl script


At 4:55 PM -0400 8/24/99, Dan Ray wrote:
>Paul wrote:
>> if (defined ($yes)) # row exists
>> {
>> 	update
>> }
>> else                # row does not exist
>> {
>> 	insert
>> }
>
>I believe I may have stumbed across a better strategy than this. Anybody
got
>any reason this wouldn't work?
>
>update
>get rows affected
>if (! rows affected) {
>	insert
>}
>
>In otherwords, just updating blindly, checking for effects, and inserting
>based on that. It's one fewer queries, certainly. Any downside to this?

Thread
update? insert? Perl scriptgl324 Aug
  • Re: update? insert? Perl scriptJeff Beard24 Aug
  • Re: update? insert? Perl scriptPaul DuBois24 Aug
    • RE: update? insert? Perl scriptDan Ray24 Aug
      • Re: update? insert? Perl scriptThimble Smith24 Aug
      • RE: update? insert? Perl scriptgl324 Aug
      • Re: update? insert? Perl scriptScott Hess24 Aug
      • RE: update? insert? Perl scriptPaul DuBois24 Aug
        • RE: update? insert? Perl scriptJay Miller24 Aug
          • RE: update? insert? Perl scriptMichael Widenius29 Aug
        • RE: update? insert? Perl scriptDan Ray25 Aug
  • Re: update? insert? Perl scriptB.W. McAdams24 Aug