Re: Resurrected thread: Speed improvement - Group batch Insert - Rewrite the INSERT at the driver level (using a parameter) - Mailing list pgsql-jdbc

From Thomas Kellerer
Subject Re: Resurrected thread: Speed improvement - Group batch Insert - Rewrite the INSERT at the driver level (using a parameter)
Date
Msg-id mfbf8s$797$1@ger.gmane.org
Whole thread Raw
In response to Resurrected thread: Speed improvement - Group batch Insert - Rewrite the INSERT at the driver level (using a parameter)  (Jeremy Whiting <jwhiting@redhat.com>)
Responses Re: Re: Resurrected thread: Speed improvement - Group batch Insert - Rewrite the INSERT at the driver level (using a parameter)  (Dave Cramer <pg@fastcrypt.com>)
List pgsql-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
isa 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
implementationthat acts as a bridge between the PreparedStatement.setXXX()/addBatch() statements and the CopyManager.
Somethinglike 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
thesame 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
aplain insert statement isn't that complicated, I think that should be doable - especially because we wouldn't need to
worryabout literals as only placeholders will be (must be?) used. 

Thomas

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: Resurrected thread: Speed improvement - Group batch Insert - Rewrite the INSERT at the driver level (using a parameter)
Next
From: Dave Cramer
Date:
Subject: Re: Re: Resurrected thread: Speed improvement - Group batch Insert - Rewrite the INSERT at the driver level (using a parameter)