Re: Gaps in PK sequence numbers [RESOLVED]

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Gaps in PK sequence numbers [RESOLVED]
Date: 2024-06-11 01:10:49
Message-ID: f9ab3b2b-508-ddcf-f01c-3c805242ee3@appl-ecosys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 10 Jun 2024, Christophe Pettus wrote:

> Strictly speaking, the sequence underlying nextval() has no idea what
> primary keys are or are not in use. It's just a transaction-ignoring
> counter that increases with each nextval() call. The only reason that
> you'd get duplicate key errors in this case are:
>
> 1. The sequence was reset to a different, lower value.
> 2. Rows were inserted that didn't use the sequence to select a primary key.

Thanks, Christophe. Is there a way to reset the sequence to the maximum
number +1? I don't recall seeing this in the postgres docs but will look
again.

Regards,

Rich

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2024-06-11 01:13:55 Re: Gaps in PK sequence numbers
Previous Message Tom Lane 2024-06-10 23:49:25 Re: libpq v17 PQsocketPoll timeout is not granular enough