public inbox for [email protected]  
help / color / mirror / Atom feed
From: Campbell, Lance <[email protected]>
To: [email protected] <[email protected]>
Subject: Sequence Cycle question
Date: Thu, 23 Jan 2025 17:13:05 +0000
Message-ID: <SJ0PR11MB562940815F89B85D4FF64D25DEE02@SJ0PR11MB5629.namprd11.prod.outlook.com> (raw)

PostgreSQL 16

Question on how Cycle works with example:

I have table X with a primary key ID which is an integer that uses a sequence.

Sequence Settings:
start_value=1
min_value=1
max_value=1,000,000
cycle=true

Use Case:
Table X has records that have been removed over time randomly.  There are IDs that cover a wide range of values between 1 and 1,000,000.

When the primary key ID, which is a sequence, reaches 1,000,000 then the next sequence value will start back at 1.

What would happen if I had a primary key for ID of 5 still in use?  When I reach 5 will the sequence skip that number and go to 6 instead?

Could you please add some text in the documentation to explain this Use Case? It seems very important.

Thanks,

Lance


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: Sequence Cycle question
  In-Reply-To: <SJ0PR11MB562940815F89B85D4FF64D25DEE02@SJ0PR11MB5629.namprd11.prod.outlook.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox