Re: sequences

From: "K Parker" <kparker(at)eudoramail(dot)com>
To: pgsql-general(at)hub(dot)org
Subject: Re: sequences
Date: 2000-09-21 17:18:51
Message-ID: BFLLMHFDNEPNCAAA@shared1-mail.whowhere.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Perhaps I was too brief before, wanting to spare folks long quotes from the manual that we all have, but here goes (quoting from 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 function currval('seqname') may be used to determine the number returned by the last call to nextval(seqname) for the specified sequence _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 used in
the current session will be lost. __Furthermore, although multiple backends are guaranteed to allocate distinct sequence values,
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

Browse pgsql-general by date

  From Date Subject
Next Message Adam Lang 2000-09-21 17:41:36 Fw: replication
Previous Message Stephan Szabo 2000-09-21 17:06:27 Re: Re: sequences