Re: Problems with sequences

From: "Kelly Burkhart" <kelly(at)kkcsm(dot)net>
To: "Arturo Perez" <aperez(at)hayesinc(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problems with sequences
Date: 2006-09-07 17:56:42
Message-ID: fa1e4ce70609071056q407364cah74a049ffdd6514c2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9/6/06, Arturo Perez <aperez(at)hayesinc(dot)com> wrote:
> What happens is that if I do a select nextval('seq') I get a number
> that's lower than the
> max primary key id. This is inspite of my doing
> SELECT setval('seq', ((SELECT MAX(seq_ID) FROM table)+1))
> ALTER SEQUENCE seq RESTART WITH <max + 1>;
> select pg_catalog.setval(seq, <max+1>, true);

Your sequence was probably created with the CACHE parameter. This
will cause each session to cache n values from the sequence.
Resetting the sequence from another session will not affect the others
until they've gone through all their cached values.

-K

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marc G. Fournier 2006-09-07 18:09:48 Re: Majordomo drops multi-line Subject:
Previous Message Alvaro Herrera 2006-09-07 17:24:26 Re: AYUDA POR FAVOR