pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: postgresql <pgsql@symcom.com>
Cc: Jan Wieck <JanWieck@Yahoo.com>
Cc: PgSQL-SQL <pgsql-sql@postgresql.org>
Subject: Re: creating "job numbers"
Date: Fri, 23 Mar 2001 10:56:23 -0500
Message-ID: <18064.985362983@sss.pgh.pa.us> (raw)
In-Reply-To: <200103231307.f2ND7qw49017@mail.postgresql.org>
References: <200103231307.f2ND7qw49017@mail.postgresql.org>

"postgresql" <pgsql@symcom.com> writes:
> Using the serial data type... I don't understand when the backend 
> would skip a number.

The value returned by a nextval() call will not be returned again by
other nextval() calls, even if the surrounding transaction is later
rolled back.  Agreed, this isn't in line with full transactional
semantics, but it was deemed the more useful thing to do precisely
because of that.  If you want the other behavior you can build it
yourself, whereas there's no way to build the actual behavior of
sequence objects in plain SQL.

The reason why this is more useful is that with this behavior,
acquirers of serial numbers don't need to wait for each other.  A
no-skipped-numbers implementation requires each would-be acquirer to
block waiting to see if previous acquirers commit or not.  You get no
concurrency at all if you build your system like that.

			regards, tom lane



view thread (9+ messages)  latest in thread

Message-ID: <18064.985362983@sss.pgh.pa.us>
Permalink:  ../18064.985362983@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/18064.985362983@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql@symcom.com, JanWieck@Yahoo.com
  Subject: Re: creating "job numbers"
  In-Reply-To: <18064.985362983@sss.pgh.pa.us>
  References: <200103231307.f2ND7qw49017@mail.postgresql.org> <18064.985362983@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox