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

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Re: Resurrected thread: Speed improvement - Group batch Insert - Rewrite the INSERT at the driver level (using a parameter)
Date: 2015-03-30 12:29:16
Message-ID: CADK3HHLtGc2qSN+MVqgUUQxRLH=UJaRg=R+f7emegV74KC=4Bg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On 30 March 2015 at 08:23, Thomas Kellerer <spam_eater(at)gmx(dot)net> wrote:

> 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.
>

copy doesn't invoke rules... not that I think rules are a great thing. I
imagine some folks might have an issue.

>
> 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
>
>

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message lpintodacosta 2015-04-02 12:57:01 BUG on postgresql-9.4-1201-jdbc41 ...
Previous Message Thomas Kellerer 2015-03-30 12:23:55 Re: Resurrected thread: Speed improvement - Group batch Insert - Rewrite the INSERT at the driver level (using a parameter)