From: Tom Lane <tgl@sss.pgh.pa.us>
To: André Hänsel <andre@webkr.de>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Issues with upserts
Date: Wed, 13 Jul 2022 11:06:20 -0400
Message-ID: <2230612.1657724780@sss.pgh.pa.us> (raw)
In-Reply-To: <034701d896c8$fe2edfa0$fa8c9ee0$@webkr.de>
References: <032201d896bd$7a948a10$6fbd9e30$@webkr.de>
<CAM8SmLX7HMEdWX_fejgrcO4JtANRJqBmFgcALrzvnnbtHekfrQ@mail.gmail.com>
<034701d896c8$fe2edfa0$fa8c9ee0$@webkr.de>
=?utf-8?Q?Andr=C3=A9_H=C3=A4nsel?= <andre@webkr.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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, andre@webkr.de
Subject: Re: Issues with upserts
In-Reply-To: <2230612.1657724780@sss.pgh.pa.us>
References: <032201d896bd$7a948a10$6fbd9e30$@webkr.de> <CAM8SmLX7HMEdWX_fejgrcO4JtANRJqBmFgcALrzvnnbtHekfrQ@mail.gmail.com> <034701d896c8$fe2edfa0$fa8c9ee0$@webkr.de> <2230612.1657724780@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox