Re: sequence increment jumps?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: John Smith <jayzee(dot)smith(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: sequence increment jumps?
Date: 2007-01-25 17:56:07
Message-ID: 20070125175607.GC7220@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jan 25, 2007 at 12:33:51 -0500,
John Smith <jayzee(dot)smith(at)gmail(dot)com> wrote:
> guys,
> i inserted 1 record into my database (default
> nextval('sequencename'::regclass) where (start 1 increment 1)). then i
> tried to insert 1 other record twice but both those inserts failed
> because of a domain check ("ERROR: value too long for type character
> varying(X)". when i was finally able to insert that record the
> sequence jumped 2 places. seems like it counted the failed inserts?

That is how sequences work. All your are guaranteed globally is that they
are unique. You can't rely on getting a sequence without gaps. Within a single
session you can get a guaranty that the values increase monotonicly if you
disallow wrap around for the sequence.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thorsten Körner 2007-01-25 18:00:46 Re: Problem with result ordering
Previous Message Douglas McNaught 2007-01-25 17:53:57 Re: sequence increment jumps?