Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sGq5M-000A7A-0a for pgsql-general@arkaria.postgresql.org; Tue, 11 Jun 2024 01:14:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sGq5K-000dVL-Ip for pgsql-general@arkaria.postgresql.org; Tue, 11 Jun 2024 01:14:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sGq5K-000dVB-83 for pgsql-general@lists.postgresql.org; Tue, 11 Jun 2024 01:14:03 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sGq5E-000iSU-LG for pgsql-general@lists.postgresql.org; Tue, 11 Jun 2024 01:14:01 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id B91902A2B7C for ; Mon, 10 Jun 2024 18:13:55 -0700 (PDT) Date: Mon, 10 Jun 2024 18:13:55 -0700 (PDT) From: Rich Shepard To: pgsql-general@lists.postgresql.org Subject: Re: Gaps in PK sequence numbers In-Reply-To: Message-ID: References: <35fd10ab-5f7f-7a57-9cc5-c03d81476d13@appl-ecosys.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 10 Jun 2024, David G. Johnston wrote: > For efficiency the only thing used to determine the next value of a > sequence is the stored value of the last sequence value issued. Where that > value may have been used, in a table as a PK or some other purpose, does > not enter into it. Using a sequence as a default does indeed become > problematic if you don't use it exclusively. If you do use it exclusively > usually you just set the last value to be the maximum needed and use it > going forward. The numbers from deleted rows simply remain missing in the > table. David, Thanks for the explanation. I had entered PKs without using the sequence. Regards, Rich