Stephan,

REPLACE is logically handled as a DELETE + INSERT, but
internally it is often handled as an UPDATE. Probably
REPLACE is faster than UPDATE / INSERT, because you
save some communications overhead between the client
and the server.

Regards,

Heikki

>On Mon, Aug 20, 2001 at 11:00:59AM +0200, Stephan wrote:
> Hi all,
> 
>> my situation:
> 
>> I generate 300 rows at a time - they should be stored in the a mysql>
table.> 
>> 99 % of the keys of these rows already exist in the table, so these
>> rows need an update.  The remaining 1 % have to be inserted in the> table.> 
>> I was wondering if it is a good idea to to this with 300 UPDATE
>> statements and if one of them fails do an INSERT.  Or if it's
>> recommendable to use a single REPLACE statement.> 
>> My problem with the REPLACE is that the documentation says that a
>> REPLACE always does an DELETE and then an INSERT.  In my case a lot
>> of rows (99%) would be deleted in the index that only need an
>> update.  Is it a good idea to do that much index manipulations that
>> aren't necessary?
>Hmm.  Are you asking for performance reasons or just because one is
>easier to code than the other?
>It shouldn't be hard to benchmark both options.  I'd be curious to
>hear what you find.
>
>Jeremy
>--
>Jeremy D. Zawodny, <[EMAIL PROTECTED]>
>Technical Yahoo - Yahoo Finance
>Desk: (408) 349-7878   Fax: (408) 349-5454   Cell: (408) 685-5936
>MySQL 3.23.41-max: up 3 days, processed 33,485,487 queries (110/sec. avg)



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to