Re: guaranteeing that a sequence never skips - Mailing list pgsql-general

From Scott Marlowe
Subject Re: guaranteeing that a sequence never skips
Date
Msg-id 1096824098.32732.16.camel@localhost.localdomain
Whole thread Raw
In response to guaranteeing that a sequence never skips  (David Garamond <lists@zara.6.isreserved.com>)
Responses Re: guaranteeing that a sequence never skips  ("Uwe C. Schroeder" <uwe@oss4u.com>)
List pgsql-general
On Sun, 2004-10-03 at 08:58, David Garamond wrote:
> Am I correct to assume that SERIAL does not guarantee that a sequence
> won't skip (e.g. one successful INSERT gets 32 and the next might be 34)?
>
> Sometimes a business requirement is that a serial sequence never skips,
> e.g. when generating invoice/ticket/formal letter numbers. Would an
> INSERT INTO t (id, ...) VALUES (SELECT MAX(col)+1 FROM t, ...) suffice,
> or must I install a trigger too to do additional checking?

You will have to lock the whole table and your parallel performance will
be poor.


pgsql-general by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: GnuPG / PGP signed checksums for PostgreSQL 7.4.5, 7.4.4, 7.3.7, 7.3.6, 7.3.5. 7.2.5
Next
From: "Scott Marlowe"
Date:
Subject: Re: [HACKERS] OT moving from MS SQL to PostgreSQL