RE: Stupidity or sequences?

From: Powell, Mark <mark.powell2_at_hp.com>
Date: Tue, 23 Apr 2013 18:33:58 +0000
Message-ID: <1E24812FBE5611419EFAFC488D7CCDD1186A97BA_at_G6W2491.americas.hpqcorp.net>



I think the line " CURRVAL won't actually serialize access to the object" probably indicates the following is understood but just in case:

currval is a session specific function and does not need to access data outside the current session. It is unaware of sequence usage by other sessions!

"To use or refer to the current sequence value of your session, reference seq_name.CURRVAL. CURRVAL can only be used if seq_name.NEXTVAL has been referenced " http://docs.oracle.com/cd/E11882_01/server.112/e25494/views002.htm#ADMIN11800

-----Original Message-----
From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Dba DBA Sent: Tuesday, April 23, 2013 10:05 AM
To: ORACLE-L
Subject: Re: Stupidity or sequences?

ok. So CURRVAL won't actually serialize access to the object? 1 session can execute a CURRVAL and another can execute a NEXTVAL simulatenously? That makes sense. This tells me that the 'latch' is on the SET function and not on the struct itself. As far as the latching goes, I would guess it just uses the C language built in for this. I forget the syntax, but every low level language can serialize access. _at_wblanchard: Yeah thanks. I think most languages have that. That being said, you generally have more application servers than you do database servers, so you would need to instantiate an object for each application server. I think this would be the same thing that RAC does. With an index setting of cache 500, each RAC server reserves 500 concurrent numbers. So if you have 10 application servers, each one would need its own object.

I don't think this would take alot of fancy code to re-create. That being said, it is still extra code and only worth the effort if you sell some kind of off the shelf application that runs on client databases and for business reasons you don't want to restrict yourself to clients who only use oracle. I agree with the original poster that the implementation that most of these java guys come up with are pathetic. They don't appear competent enough to do this well. There is a very good software blog called 'joelonsoftware.com'. There is an older blog post called 'The Plight of Java Schools', where he argues that developers should learn C in school and you can learn java later on. Java guys don't learn these kinds of algorithms and are not qualified to implement them. When I work with C programmers they tend to have the same complaints about java developers that DBAs do.

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_at_gmail.com>
> To: "ORACLE-L" <oracle-l_at_freelists.org>
> 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
> |
> |
> | --
> | http://www.freelists.org/webpage/oracle-l
> |
> |
>
> --
> http://www.freelists.org/webpage/oracle-l
>
>
>

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


--
http://www.freelists.org/webpage/oracle-l
Received on Tue Apr 23 2013 - 20:33:58 CEST

Original text of this message