Gaps in PK sequence numbers - Mailing list pgsql-general

From Rich Shepard
Subject Gaps in PK sequence numbers
Date
Msg-id 35fd10ab-5f7f-7a57-9cc5-c03d81476d13@appl-ecosys.com
Whole thread Raw
Responses Re: Gaps in PK sequence numbers
Re: Gaps in PK sequence numbers
List pgsql-general
Over the years I've deleted rows from tables leaving gaps in the PK sequence
numbers. I've now learned that using nextval('sequencename') finds those
gaps and tells me that the value after the gap is already assigned.

I found a web page that explains how to find the gaps in a sequence, yet I
want to understand why nextval() doesn't begin with the max(FK)+1 value.

When I tried inserting new rows in the companies table psql told me that PK
value 2310 already existed. Selecting max(PK) returned 2341. When entering
multiple new rows is there a way to ignore gaps?

TIA,

Rich



pgsql-general by date:

Previous
From: Rich Shepard
Date:
Subject: Re: Multiple tables row insertions from single psql input file [RESOLVED]
Next
From: Thomas Munro
Date:
Subject: Re: libpq v17 PQsocketPoll timeout is not granular enough