From: | Ian Campbell <ianrc72(at)gmail(dot)com> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Use SPI_exec... to insert multiples rows in C |
Date: | 2016-09-25 15:00:23 |
Message-ID: | CA+0FpjVxUJNqJe0x6-Q-A34r4-F=i5v02WvN+wvYbBpMqWJVYA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2016-09-25 15:27:21 | Re: Question on replace function [solved] |
Previous Message | Charles Clavadetscher | 2016-09-25 12:45:10 | Re: Question on replace function [solved] |