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?