Re: Guidance on INSERT RETURNING order - Mailing list pgsql-general

From Thorsten Glaser
Subject Re: Guidance on INSERT RETURNING order
Date
Msg-id 2b8d529a-0ec-4e8f-26d3-2ef2881a2d49@evolvis.org
Whole thread Raw
In response to Re: Guidance on INSERT RETURNING order  (Federico <cfederico87@gmail.com>)
Responses Re: Guidance on INSERT RETURNING order
List pgsql-general
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 :-)



pgsql-general by date:

Previous
From: Federico
Date:
Subject: Re: Guidance on INSERT RETURNING order
Next
From: "Mike Bayer"
Date:
Subject: Re: Guidance on INSERT RETURNING order