Thread: Re: sequences

Re: sequences

From
"K Parker"
Date:
Perhaps I was too brief before, wanting to spare folks long quotes from the manual that we all have, but here goes
(quotingfrom http://www.postgresql.org/users-lounge/docs/7.0/postgres/sql-createsequence.htm): 

"After a sequence is created, you may use the  function nextval(seqname) to get a new number from the sequence. The
functioncurrval('seqname') may be used to determine the number returned by the last call to nextval(seqname) for the
specifiedsequence _in the current session_".  [emphasis added] 

"Unexpected results may be obtained if a cache setting greater than one is used for a sequence object that will be used
 concurrently by multiple backends. Each backend will allocate and cache successive sequence values during one access
to
 the sequence object and increase the sequence object's last_value accordingly. Then, the next cache-1 uses of nextval
within
 that backend simply return the preallocated values without touching the shared object. So, numbers allocated but not
usedin 
 the current session will be lost. __Furthermore, although multiple backends are guaranteed to allocate distinct
sequencevalues, 
 the values may be generated out of sequence when all the backends are considered.__" [again, emphasis added].


Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at http://www.eudoramail.com