Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: select + insert vs. insert and catching exception

Re: select + insert vs. insert and catching exception

From: <ctcgag_at_hotmail.com>
Date: 29 Sep 2002 00:53:22 GMT
Message-ID: <20020928205322.448$tv@newsreader.com>


"Christoph Seidel" <chris666.seidel_at_gmx.de> wrote:
> what is better in respect of performance?
>
> select by primary key, if not found insert
>
> or
>
> insert and catch exception if primary key exists
>
> the table is quite small, less than 100 rows

It seems to me the first option necessarily includes the second.

The select followed by a insert if necessary sets up a race condition, (two transactions do the same select, both come up empty then both try to do the insert), thus catching the exception will be necessary anyway.

But I would expect doing all three (select, insert, catch) would be best for performance. If the table is < 100 rows, there probably aren't that many inserts going on.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
                    Usenet Newsgroup Service
Received on Sat Sep 28 2002 - 19:53:22 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US