Re: sequence increment jumps?

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
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 18:34:50
Message-ID: b42b73150701251034k30b59445yb3ca803f8de49481@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1/25/07, 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?

if you absolutely must have gapless identifiers in your database,
follow this procedure:
http://www.varlena.com/GeneralBits/130.php

as others have stated, sequences are (much) faster than rule/trigger
based solutions and have better concurrency.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2007-01-25 18:35:56 Re: Stats collector frozen?
Previous Message Thorsten Körner 2007-01-25 18:00:46 Re: Problem with result ordering