pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thorsten Glaser <tg@evolvis.org>
To: pgsql-general@lists.postgresql.org
Subject: Re: Guidance on INSERT RETURNING order
Date: Wed, 12 Apr 2023 00:20:56 +0200 (CEST)
Message-ID: <2b8d529a-0ec-4e8f-26d3-2ef2881a2d49@evolvis.org> (raw)
In-Reply-To: <CAN19dycSeCqyWbS0Ytj82ThS3XK_YuvYyNHOOiSr0DfubvGr+Q@mail.gmail.com>
References: <CAN19dycS0oUorLOGgjxMX8NZq-hOA1RJrzwC4L3FxpMf4BQbBQ@mail.gmail.com>
	<95fbd8c8-2f7a-38a1-4a41-b2ac3763d89c@aklaver.com>
	<CAN19dyed0o5eCUYSEq30q39SpFmeZ7WSEHBfR042YYTVoipHcg@mail.gmail.com>
	<a29ad53f-90ed-2e50-a28a-f3f15f3ddddc@evolvis.org>
	<CAN19dydW+f2iQ4b0XrMWeoJBNMQMosWjbLc3uthZ=aG+EsuyCA@mail.gmail.com>
	<3b1117cc-fe46-1ca0-d0f-92304c6fc79@evolvis.org>
	<CAN19dyfhqBhsiDDUyQCAyjm_OC=SMo+wGrE7W84RiJOvAPCr7g@mail.gmail.com>
	<8a57a79b-6e73-99b4-8f3a-859fccb5eb3b@evolvis.org>
	<CAN19dycSeCqyWbS0Ytj82ThS3XK_YuvYyNHOOiSr0DfubvGr+Q@mail.gmail.com>

On Tue, 11 Apr 2023, Federico wrote:

>My understanding was that they are generated in select order

But are they? (I don’t know, but I’d not assume that.)

>If my understanding is incorrect, would this alternative guarantee the above

>    INSERT INTO t(id, data)
>    SELECT nextval(pg_get_serial_sequence('t', 'id')) data
>    FROM (VALUES ('a', 1), ('b', 2), ('c', 3)) as vv(data, num)
>    ORDER BY num
>    RETURNING id

Wouldn’t, at that point, it be better to just send multiple
individual INSERT statements? The overhead (on both sides)
for all mentioned… workarounds… surely is larger than that?

bye,
//mirabilos
-- 
15:41⎜<Lo-lan-do:#fusionforge> Somebody write a testsuite for helloworld :-)





view thread (56+ messages)  latest in thread

Message-ID: <2b8d529a-0ec-4e8f-26d3-2ef2881a2d49@evolvis.org>
Permalink:  ../2b8d529a-0ec-4e8f-26d3-2ef2881a2d49@evolvis.org/
Also on:    postgresql.org/message-id/2b8d529a-0ec-4e8f-26d3-2ef2881a2d49@evolvis.org

 · 

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 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: tg@evolvis.org
  Subject: Re: Guidance on INSERT RETURNING order
  In-Reply-To: <2b8d529a-0ec-4e8f-26d3-2ef2881a2d49@evolvis.org>
  References: <CAN19dycS0oUorLOGgjxMX8NZq-hOA1RJrzwC4L3FxpMf4BQbBQ@mail.gmail.com> <95fbd8c8-2f7a-38a1-4a41-b2ac3763d89c@aklaver.com> <CAN19dyed0o5eCUYSEq30q39SpFmeZ7WSEHBfR042YYTVoipHcg@mail.gmail.com> <a29ad53f-90ed-2e50-a28a-f3f15f3ddddc@evolvis.org> <CAN19dydW+f2iQ4b0XrMWeoJBNMQMosWjbLc3uthZ=aG+EsuyCA@mail.gmail.com> <3b1117cc-fe46-1ca0-d0f-92304c6fc79@evolvis.org> <CAN19dyfhqBhsiDDUyQCAyjm_OC=SMo+wGrE7W84RiJOvAPCr7g@mail.gmail.com> <8a57a79b-6e73-99b4-8f3a-859fccb5eb3b@evolvis.org> <CAN19dycSeCqyWbS0Ytj82ThS3XK_YuvYyNHOOiSr0DfubvGr+Q@mail.gmail.com> <2b8d529a-0ec-4e8f-26d3-2ef2881a2d49@evolvis.org>

* 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