Re: Guidance on INSERT RETURNING order

From: Thorsten Glaser <tg(at)evolvis(dot)org>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Guidance on INSERT RETURNING order
Date: 2023-04-11 22:20:56
Message-ID: 2b8d529a-0ec-4e8f-26d3-2ef2881a2d49@evolvis.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 :-)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mike Bayer 2023-04-11 23:05:10 Re: Guidance on INSERT RETURNING order
Previous Message Federico 2023-04-11 22:02:34 Re: Guidance on INSERT RETURNING order