Re: Issues with upserts

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: André Hänsel <andre(at)webkr(dot)de>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Issues with upserts
Date: 2022-07-13 15:06:20
Message-ID: 2230612.1657724780@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

=?utf-8?Q?Andr=C3=A9_H=C3=A4nsel?= <andre(at)webkr(dot)de> writes:
> This will yield “8”, showing that new sequence numbers have been generated for each attempt.

Well, yeah, because the INSERT has to be attempted first, and
that includes forming the whole candidate row including the
nextval() result. If you're expecting a serial ID column to not
have holes in the sequence of values, you're going to be sadly
disappointed, whether you use ON CONFLICT UPDATE or not.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2022-07-13 15:06:46 Re: Issues with upserts
Previous Message André Hänsel 2022-07-13 14:58:20 RE: Issues with upserts