Fwd: [GENERAL] Does PG support bulk operation in embedded C

From: Steve Midgley <science(at)misuse(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Fwd: [GENERAL] Does PG support bulk operation in embedded C
Date: 2015-05-20 18:11:45
Message-ID: CAJexoS+hHw7NfL2btSDJ=W8gEf9Jr4tOy9jQStC1-tBV7Gtj5Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

You can do in-memory transfers using 'copy' - you do that with the stdout
option. Performance is very good if you're on the same machine as the sql
server. As far as I could see the transfer never touched the disk (once I
loaded the data into memory from a file) and I was getting blistering
insert speeds (this was back in 2009 but if I remember right, the copy
speed using this method was 50x the speed of a traditional insert command,
even when a bunch of inserts were wrapped in a transaction).

I dug up the code I used back then - it's in Ruby, using ActiveRecord, and
is from 2009 (hasn't been used since). But maybe it is useful for porting
to your environment: https://gist.github.com/science/15e97e414d5666c2f486

Obviously network is a likely bottleneck if you're not on the same box.

On May 20, 2015 8:24 AM, "Ravi Krishna" <srkrishna(at)gmx(dot)com> wrote:

>
> > Anyway, taking the function name 'bulk' into account - I think you want
> > find the best way to to insert a large number of row/records.
> >
> > Review the 'copy' command to populate a database:
> > http://www.postgresql.org/docs/9.1/static/populate.html - read
> > carefully as it will increase performance in a dramatic way.
>
> I am aware of the copy command, but we are talking about application
> inserting rows from a C++ task
> with values coming in variables. Does COPY handle that? COPY looks more
> closer to sqlloader of Oracle.
>
> DB2 Bulkcopy API is damn good. We have applications inserting tens of rows
> in one single call.
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Swartz 2015-05-20 19:23:09 Enum in foreign table: error and correct way to handle.
Previous Message Michael Nolan 2015-05-20 17:44:41 Re: Consistent state for pg_dump and pg_dumpall

Browse pgsql-sql by date

  From Date Subject
Next Message Suresh Raja 2015-05-21 16:27:33 extracting PII data and transforming it across table.
Previous Message Steve Midgley 2015-05-20 15:43:50 Re: [GENERAL] Does PG support bulk operation in embedded C