Use SPI_exec... to insert multiples rows in C

Поиск
Список
Период
Сортировка
От Ian Campbell
Тема Use SPI_exec... to insert multiples rows in C
Дата
Msg-id CA+0FpjVxUJNqJe0x6-Q-A34r4-F=i5v02WvN+wvYbBpMqWJVYA@mail.gmail.com
обсуждение исходный текст
Список pgsql-general
I need to insert up to 12 rows (bulk). Basically, new row #1's ID is the table sequence nextval and parent = null; #2 is nextval + 1 and parent = row #1's ID, etc. A hierarchy.

I figured the most performant way to do this is to have the sequence increment by the max bulk insert quantity, 12. This way I can insert all rows in one statement, which I am sure is faster that 12 insert statements (I already tried that).

Ideally, I'd like to write this in C using SPI_exec(INSERT...)  (or one of its siblings). I figured it would be most efficient to write the rows to be inserted into a tuplestore and then insert them somehow. But I don't know how to do this and cannot find any examples.

Could someone point the way for me.

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

Предыдущее
От: Charles Clavadetscher
Дата:
Сообщение: Re: Question on replace function [solved]
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Question on replace function [solved]