Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: select + insert vs. insert and catching exception
"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 ServiceReceived on Sat Sep 28 2002 - 19:53:22 CDT