Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YcYjn-0008JS-E9 for pgsql-jdbc@arkaria.postgresql.org; Mon, 30 Mar 2015 12:24:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YcYjl-0001cj-Kf for pgsql-jdbc@arkaria.postgresql.org; Mon, 30 Mar 2015 12:24:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YcYjj-0001ca-N3 for pgsql-jdbc@postgresql.org; Mon, 30 Mar 2015 12:24:11 +0000 Received: from plane.gmane.org ([80.91.229.3]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YcYje-0003VM-LF for pgsql-jdbc@postgresql.org; Mon, 30 Mar 2015 12:24:09 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YcYjb-0005Gs-8O for pgsql-jdbc@postgresql.org; Mon, 30 Mar 2015 14:24:03 +0200 Received: from 185.40.248.10 ([185.40.248.10]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 30 Mar 2015 14:24:03 +0200 Received: from spam_eater by 185.40.248.10 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 30 Mar 2015 14:24:03 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Thomas Kellerer Subject: Re: Resurrected thread: Speed improvement - Group batch Insert - Rewrite the INSERT at the driver level (using a parameter) Date: Mon, 30 Mar 2015 14:23:55 +0200 Lines: 12 Message-ID: References: <55130DC8.2070508@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 185.40.248.10 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 In-Reply-To: <55130DC8.2070508@redhat.com> X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Jeremy Whiting schrieb am 25.03.2015 um 20:34: > "If your use case is just "I want to do bulk inserts as fast as possible" then perhaps the newly merged COPY suport is a better way to go." I wonder if it is possible to silently "rewrite" a batched statement to use the CopyManager. Very(!) roughly speaking: when the first call to addBatch() is made, initialize the CopyManager and provide a a Reader implementation that acts as a bridge between the PreparedStatement.setXXX()/addBatch() statements and the CopyManager. Something like a producer/consumer pattern. The setXXX() calls would prepare a single "line" and the addBatch() would then "send" this to the CopyManager which is blocked on the Read.readLine() call. But I have no clue if this would even be possible (blocking Reader.readLine() but sill allowing calls to addBatch() in the same Thread seems a major roadblock to me) or - if possible - how much work it would be. It would definitely require parsing the insert statement passed to the prepareStatement() clause, but as the syntax of a plain insert statement isn't that complicated, I think that should be doable - especially because we wouldn't need to worry about literals as only placeholders will be (must be?) used. Thomas -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc