Обсуждение: Does PG support bulk operation in embedded C
To explain pls refer to this for DB2 http://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.apdv.cli.doc/doc/r0002329.html Essentially in one single sql call, we can do -- Add new rows -- Update a set of rows where each row is identified by a bookmark -- Delete a set of rows where each row is identified by a bookmark -- Fetch a set of rows where each row is identified by a bookmark This gives tremendous performance benefits as the network round trip is avoided for each sql. I am looking for an equivalent of this in PG and C language. Thanks.
On 05/19/2015 04:47 PM, Ravi Krishna wrote: > > To explain pls refer to this for DB2 > > http://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.apdv.cli.doc/doc/r0002329.html > > > Essentially in one single sql call, we can do > -- Add new rows > -- Update a set of rows where each row is identified by a bookmark > -- Delete a set of rows where each row is identified by a bookmark > -- Fetch a set of rows where each row is identified by a bookmark > > This gives tremendous performance benefits as the network round trip is > avoided for each sql. > > I am looking for an equivalent of this in PG and C language. For embedded C, I believe you are looking for: http://www.postgresql.org/docs/9.4/static/ecpg.html > > Thanks. > > > -- Command Prompt, Inc. - http://www.commandprompt.com/ 503-667-4564 PostgreSQL Centered full stack support, consulting and development. Announcing "I'm offended" is basically telling the world you can't control your own emotions, so everyone else should do it for you.
Not sure whether I am understanding this. I checked embedded C and did not find any section which describes what I have asked, that is the ability to do multiple inserts, or updates or deletes in one sql call. For example, if my application does the following
BEGIN TRANSACTION
INSERT INTO TABLE_A
UPDATE TABLE_B
INSERT INTO TABLE_C
BEGIN TRANSACTION
INSERT INTO TABLE_A
UPDATE TABLE_B
INSERT INTO TABLE_C
COMMIT TRANSACTION
DB2 provides to combine the three sql operations into an array and make a call to DB2 which executes the array (that is all 3 sqls as one single call).
I am looking for something similar in PG.
thanks
Sent: Tuesday, May 19, 2015 at 8:13 PM
From: "Joshua D. Drake" <jd@commandprompt.com>
To: "Ravi Krishna" <srkrishna@gmx.com>, pgsql-sql@postgresql.org
Cc: pgsql-general@postgresql.org
Subject: Re: [SQL] [GENERAL] Does PG support bulk operation in embedded C
From: "Joshua D. Drake" <jd@commandprompt.com>
To: "Ravi Krishna" <srkrishna@gmx.com>, pgsql-sql@postgresql.org
Cc: pgsql-general@postgresql.org
Subject: Re: [SQL] [GENERAL] Does PG support bulk operation in embedded C
On 05/19/2015 04:47 PM, Ravi Krishna wrote:
>
> To explain pls refer to this for DB2
>
> http://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.apdv.cli.doc/doc/r0002329.html
>
>
> Essentially in one single sql call, we can do
> -- Add new rows
> -- Update a set of rows where each row is identified by a bookmark
> -- Delete a set of rows where each row is identified by a bookmark
> -- Fetch a set of rows where each row is identified by a bookmark
>
> This gives tremendous performance benefits as the network round trip is
> avoided for each sql.
>
> I am looking for an equivalent of this in PG and C language.
For embedded C, I believe you are looking for:
http://www.postgresql.org/docs/9.4/static/ecpg.html
>
> Thanks.
>
>
>
--
Command Prompt, Inc. - http://www.commandprompt.com/ 503-667-4564
PostgreSQL Centered full stack support, consulting and development.
Announcing "I'm offended" is basically telling the world you can't
control your own emotions, so everyone else should do it for you.
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
On 05/19/2015 05:27 PM, Ravi Krishna wrote: > Not sure whether I am understanding this. I checked embedded C and did > not find any section which describes what I have asked, that is the > ability to do multiple inserts, or updates or deletes in one sql call. > For example, if my application does the following > > BEGIN TRANSACTION > INSERT INTO TABLE_A > UPDATE TABLE_B > INSERT INTO TABLE_C > COMMIT TRANSACTION Well PostgreSQL certainly supports the above. > > DB2 provides to combine the three sql operations into an array and make > a call to DB2 which executes the array (that is all 3 sqls as one single > call). You can do this with inserts using multivalue. INSERT INTO TABLE_A VALUES (), (), (); I am not sure about UPDATE or DELETE, I know you can use WITH on DELETE which gives you some flexibility. I don't think you will get a one to one comparison but you should be able to get close. JD -- Command Prompt, Inc. - http://www.commandprompt.com/ 503-667-4564 PostgreSQL Centered full stack support, consulting and development. Announcing "I'm offended" is basically telling the world you can't control your own emotions, so everyone else should do it for you.
On Wed, May 20, 2015 at 8:47 AM, Ravi Krishna <srkrishna@gmx.com> wrote: > Essentially in one single sql call, we can do > -- Add new rows > -- Update a set of rows where each row is identified by a bookmark > -- Delete a set of rows where each row is identified by a bookmark > -- Fetch a set of rows where each row is identified by a bookmark > > This gives tremendous performance benefits as the network round trip is > avoided for each sql. > > I am looking for an equivalent of this in PG and C language. What you are looking at could be accomplished with a user-defined function: http://www.postgresql.org/docs/devel/static/xfunc.html Perhaps you are looking for something in C, now it would be less complex to do it for example with pl/pgsql or another language, and call it from a C client with a correct set of arguments satisfying your needs. -- Michael