Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id E4D1C632E17 for ; Fri, 15 Jan 2010 12:32:08 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 33768-01 for ; Fri, 15 Jan 2010 16:31:57 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by mail.postgresql.org (Postfix) with ESMTP id 71C1E632DE1 for ; Fri, 15 Jan 2010 12:31:57 -0400 (AST) Received: from localhost (access [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id E54BC1E044A; Sat, 16 Jan 2010 00:31:54 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (access.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id OjYoiY6eTP1U; Sat, 16 Jan 2010 00:31:53 +0800 (WST) Received: from [10.1.1.5] (203-206-118-60.dyn.iinet.net.au [203.206.118.60]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 49B6D1E0449; Sat, 16 Jan 2010 00:31:53 +0800 (WST) Message-ID: <4B50986B.4090806@postnewspapers.com.au> Date: Sat, 16 Jan 2010 00:31:39 +0800 From: Craig Ringer User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Vaibhav Patil CC: "pgsql-jdbc@postgresql.org" Subject: Re: COPY using Hibernate 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> In-Reply-To: <399131.1865.qm@web94904.mail.in2.yahoo.com> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.337 tagged_above=-10 required=5 tests=AWL=0.262, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201001/27 X-Sequence-Number: 20223 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