From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-jdbc@postgresql.org
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
Message-ID: <mfbf8s$797$1@ger.gmane.org> (raw)
In-Reply-To: <55130DC8.2070508@redhat.com>
References: <55130DC8.2070508@redhat.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
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
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: spam_eater@gmx.net
Subject: Re: Resurrected thread: Speed improvement - Group batch Insert - Rewrite the INSERT at the driver level (using a parameter)
In-Reply-To: <mfbf8s$797$1@ger.gmane.org>
References: <55130DC8.2070508@redhat.com> <mfbf8s$797$1@ger.gmane.org>
* 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