Re: Behavior of identity columns

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: "sivapostgres(at)yahoo(dot)com" <sivapostgres(at)yahoo(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Behavior of identity columns
Date: 2022-08-04 10:32:32
Message-ID: CA+bJJbyiMovsrqZmouLMSbFviVkteJdMTEGnRCwZ_w2Gk1icEg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 4 Aug 2022 at 10:52, sivapostgres(at)yahoo(dot)com
<sivapostgres(at)yahoo(dot)com> wrote:
> I see 'identity' column values increment even when some error(s) occurs while inserting data. Is that a known bug or known behavior?

Known behaviour, explained thousand of times over the years. Identity
is not a way to generate consecutive values, not ever guaranteed
ascending values, it is for generating unique values. The
implementation burn the values before commit/rollback for better
concurreency, search archives or docs for details. In your example, id
is allocated and burnt to generate the complete failing row, when it
fails it is gone. Search lists, google, the docs, its been explained
ad nauseam.

Francisco Olarte.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2022-08-04 12:28:07 Re: Index only scans for expressional indices when querying for the expression
Previous Message Ron 2022-08-04 10:22:52 Re: How to choose new master from slaves.?