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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Performance of sequences as primary key generators.

Re: Performance of sequences as primary key generators.

From: Richard J Woodland <richwoodland_at_interfacefamily.com>
Date: 1997/06/24
Message-ID: <33B04E4D.1F1B@interfacefamily.com>#1/1

Ben Harmon wrote:
>
> A sequence, as I understand it, is actually just another table that is being
> incremented by a procedure that is run when the NEXTVAL statement is issued.
> Is it correct to say that the following are issued when a sequence is utilized
> to generate a primary key?
>
> 1) The original "INSERT" statement is issued to 'emp' table.
> 2) The SQL is stored in the SGA while
> 3) A trigger is called which
> 4) Performs a "SELECT" from the emp.sequence table and
> 5) Performs an "UPDATE" to the emp.sequence table and
> 6) Writes the NEXTVAL value to the emp table and THEN
> 7) The original SQL is executed, involving yet another write.
>
> I realize this is crude, but is it roughly correct? This seems like a lot of
> overhead. Does anybody have any input on this? I am a beginner, and am very
> open to new information.
>
> If there is another way to generate primary keys for a table, I would love to
> hear it.
>
> Thanks,
>
> ________________________________________________
> Ben Harmon
> ben_at_dascom.com.nospam
> **Please remove .nospam suffix if you want to mail me**
> ________________________________________________

Dunno how it works, but it's certainly not a slow operation. I often stick the reference to the sequence in an INSERT trigger, then just forget about it. Any way other than a sequence is unlikely to be much faster. Received on Tue Jun 24 1997 - 00:00:00 CDT

Original text of this message

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