Re: Stupidity or sequences?

  • From: "Jonathan Lewis" <jonathan@xxxxxxxxxxxxxxxxxx>
  • To: "ORACLE-L" <oracle-l@xxxxxxxxxxxxx>
  • Date: Tue, 23 Apr 2013 07:47:34 +0100

That looks like it's in the right ballpark.

Then there's the "sequence cache" latch to protect (all) the in-memory 
sequence structures on a call to nextval, and the relevant "row cache 
objects" latch when the read or write to the data dictionary row has to 
take place.

CURRVAL, however, won't access the SGA structure, it will need to reference 
the local memory location populated by the previous call by the session to 
NEXTVAL.


Regards

Jonathan Lewis
http://jonathanlewis.wordpress.com/all-postings

Author: Oracle Core (Apress 2011)
http://www.apress.com/9781430239543

----- Original Message ----- 
From: "Dba DBA" <oracledbaquestions@xxxxxxxxx>
To: "ORACLE-L" <oracle-l@xxxxxxxxxxxxx>
Sent: Monday, April 22, 2013 9:29 PM
Subject: Re: Stupidity or sequences?


| does anyone know what oracle does under the covers to guarantee 
uniqueness
| of the sequence? When you cache sequence values in memory (say 500) per
| node... I am guessing they use a struct to store the current value. In
| java/c there is a way to make a method/class/struct serialized so only 1
| session at a time can get the value. I doubt its anything fancy.
| I am guessing the basic algorithm for a sequence with cache 500
|
| Pseudo code below
| select sequence_value
| from sequence_table_in_data_dictionary
| where sequencename = ....
|
| update sequence_table_in_data_dictionary
| set sequence_value = old_value+500
| where sequence_name  = ....
| commit;
|
| Then in memory, each sequence gets its own C Struct (below SQL layer)
| struct SequenceName serial -- don't remember the C syntax for a Struct or
| to serialize a struct
| {
|   current_value number;
|   max_value number --when this hits, find the new value and increment the
| sequence value in the DB\
| }
|
| Then getter function for CURRVAL and setter function for NEXTVAL
|
|
| --
| //www.freelists.org/webpage/oracle-l
|
|

--
//www.freelists.org/webpage/oracle-l


Other related posts: