Re: Guidance on INSERT RETURNING order

Поиск
Список
Период
Сортировка
От Federico
Тема Re: Guidance on INSERT RETURNING order
Дата
Msg-id CAN19dyfcF3=sR8WWyVWQdukc-pdz9Fib2Lt29a5LV1d7FaqJNw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Guidance on INSERT RETURNING order  (Thorsten Glaser <tg@evolvis.org>)
Ответы Re: Guidance on INSERT RETURNING order  (John Howroyd <jdhowroyd@googlemail.com>)
Список pgsql-general
On Wed, 12 Apr 2023 at 11:46, Thorsten Glaser <tg@evolvis.org> wrote:
>
> 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.)

That's kind of the point for this question, to see if that's correct or not.

> >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?

No, not by a long shot. Sending thousands of single inserts
sequentially over the network requires a lot more time even when doing
that on localhost.
Using a single statement is many times faster.

Federico

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



В списке pgsql-general по дате отправления:

Предыдущее
От: Fabrice Chapuis
Дата:
Сообщение: pg_basebackup / recovery
Следующее
От: David Rowley
Дата:
Сообщение: Re: parallel aggregation