Re: sequence advances on failed insert

From: David Fetter <david(at)fetter(dot)org>
To: Matthew Terenzio <matt(at)jobsforge(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: sequence advances on failed insert
Date: 2005-04-08 00:16:42
Message-ID: 20050408001642.GA6193@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Apr 07, 2005 at 07:59:52PM -0400, Matthew Terenzio wrote:
> I'm noticing that a sequence is advancing even if the insertion
> fails. Is this weird or expected?

It's expected. Sequences are guaranteed to generate unique IDs.
These happen to be an increasing sequence of integers, but there is no
attempt to make this a gap-free sequence, and your apps should not
depend on the actual value of said ID.

HTH :)

Cheers,
D
--
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778

Remember to vote!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Smith 2005-04-08 00:27:00 Re: using limit with delete
Previous Message Matthew Terenzio 2005-04-07 23:59:52 sequence advances on failed insert