pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Maciek Sakrejda <msakrejda@truviso.com>
To: Craig Ringer <craig@postnewspapers.com.au>
Cc: Vaibhav Patil <infovaibhav@yahoo.com>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: COPY using Hibernate
Date: Fri, 15 Jan 2010 08:42:28 -0800
Message-ID: <895e58dd1001150842g6c9784c8r9bf78f5a7ce6f033@mail.gmail.com> (raw)
In-Reply-To: <4B50986B.4090806@postnewspapers.com.au>
References: <170472.26453.qm@web94901.mail.in2.yahoo.com>
	<491f66a51001150400sf2c6b04l840af9f01c3e55bb@mail.gmail.com>
	<4B5066B1.6050709@postnewspapers.com.au>
	<82F2099D-4E4C-4073-A900-56A08DDEFD34@mchange.com>
	<399131.1865.qm@web94904.mail.in2.yahoo.com>
	<4B50986B.4090806@postnewspapers.com.au>

The driver supports COPY as of 8.4-701. I finally (after much too long
a delay; I apologize again) made good on my promise to clean up Kalle
Hallivuori's patch with Truviso's internal fixes, and worked with Kris
to get it accepted last spring. The final version came out in July.

It looks like it's not there in the main documentation, but it *is* in
the javadoc. PGConection.getCopyAPI() is the entry point.
---
Maciek Sakrejda | Software Engineer | Truviso

1065 E. Hillsdale Blvd., Suite 230
Foster City, CA 94404
(650) 242-3500 Main
(650) 242-3501 F
msakrejda@truviso.com
www.truviso.com



On Fri, Jan 15, 2010 at 8:31 AM, Craig Ringer
<craig@postnewspapers.com.au> wrote:
> Vaibhav Patil wrote:
>
>> The other way I am trying is the pg/plsql stored procedure. As per the
>> requirement, I have to insert around a million integers in a table
>> having just one column. I am not aware of how to use "COPY FROM STDIN"
>> using pg/plsql. I'll pass these integers as array to stored procedure. I
>> want to avoid dependency of file, otherwise it could have been done
>> easily using "COPY FROM file". Looking for more information on internet
>> to solve the issue. If anybody aware of the way, please help me.
>
> It's a real pity the JDBC driver doesn't support the COPY protocol so
> you could just do this via PGConnection. There have been patches around
> for ages ... though I presume there are good reasons why they haven't
> been merged.
>
> Do check to make sure that the stored proc approach is actually faster
> than just doing batched multi-valued INSERTs. Open a transaction, then
> prepare a statement like this:
>
> INSERT INTO sometable VALUES (?),(?),(?),(?),(?);
>
> (but with say 20 parameters - you'll need to play around and see how
> many is optimal), then add a series of invocations of the prepared
> statement to a JDBC batch insert/update and execute it.
>
> I wouldn't be surprised if that was quite a bit faster than doing it
> with an array and PL/PgSQL.
>
> --
> Craig Ringer
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>



view thread (10+ messages)  latest in thread

Message-ID: <895e58dd1001150842g6c9784c8r9bf78f5a7ce6f033@mail.gmail.com>
Permalink:  ../895e58dd1001150842g6c9784c8r9bf78f5a7ce6f033@mail.gmail.com/
Also on:    postgresql.org/message-id/895e58dd1001150842g6c9784c8r9bf78f5a7ce6f033@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: msakrejda@truviso.com, craig@postnewspapers.com.au, infovaibhav@yahoo.com
  Subject: Re: COPY using Hibernate
  In-Reply-To: <895e58dd1001150842g6c9784c8r9bf78f5a7ce6f033@mail.gmail.com>
  References: <170472.26453.qm@web94901.mail.in2.yahoo.com> <491f66a51001150400sf2c6b04l840af9f01c3e55bb@mail.gmail.com> <4B5066B1.6050709@postnewspapers.com.au> <82F2099D-4E4C-4073-A900-56A08DDEFD34@mchange.com> <399131.1865.qm@web94904.mail.in2.yahoo.com> <4B50986B.4090806@postnewspapers.com.au> <895e58dd1001150842g6c9784c8r9bf78f5a7ce6f033@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox