Re: Batches of single-insert statements vs batches of multi-insert statements

From: Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com>
To: Christopher Deckers <chrriis(at)gmail(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Batches of single-insert statements vs batches of multi-insert statements
Date: 2016-06-05 18:33:46
Message-ID: CAB=Je-FLY9U4wfK_csoZH2cPSrna5EhZMsCUK+aE=8iwOyfbBA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi Christopher,

>Could someone educate me as to what happens internally to the JDBC
single-insert batch that makes it so different from a multi-insert batch?

There are significant overheads at the database level itself to initialize
and cleanup resources required for a "insert values" statement.
This is a known issue for backend developers, however it does not seem to
have easy solution.
See
https://www.postgresql.org/message-id/CAB=Je-EDZwVH7FgpDOa0ad8a7a6D=1QoYmvW2kQqSAML2gf+Uw@mail.gmail.com

>If this should not be done in the JDBC driver, then in which area could
such handling be done?
>Or have I missed something?

Believe me or not, pgjdbc has already that feature implemented.
Jeremy did that in https://github.com/pgjdbc/pgjdbc/pull/491

The feature is disabled by default (so everybody can give it a try before
we make it default), and we plan to activate it by default.
To activate multi-inserts, you should add reWriteBatchedInserts=true
connection parameter.
You need 9.4.1209-SNAPSHOT version (you can grab that from Maven Central or
build from sources).

We all would be grateful if you could test it and let us know if it works
for you.

Vladimir

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Christopher Deckers 2016-06-05 20:39:58 Re: Batches of single-insert statements vs batches of multi-insert statements
Previous Message Christopher Deckers 2016-06-05 18:17:54 Batches of single-insert statements vs batches of multi-insert statements