Re: executeBatch() issue with new driver? - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: executeBatch() issue with new driver?
Date
Msg-id 4187F9D7.3060308@opencloud.com
Whole thread Raw
In response to Re: executeBatch() issue with new driver?  (Alan Stange <stange@rentec.com>)
List pgsql-jdbc
Alan Stange wrote:

> What about this case:
>
> Connection conn = ...
> Statement st = conn.createStatement();
> st.execute("insert a; insert b; insert c; insert d;");
>
> Is the 8.0 driver busting this up into 4 trips to the database?!

No, but it must split that query string into 4 individual queries (a V3
extended-query-protocol requirement). So it will send:

   Parse("insert a")
   Bind(...)
   Execute(...)
   Parse("insert b")
   Bind(...)
   Execute(...)
   Parse("insert c")
   Bind(...)
   Execute(...)
   Parse("insert d")
   Bind(...)
   Execute(...)
   Sync

Then it starts reading responses from the server.

The driver does exactly the same thing if you do:

   st.addBatch("insert a");
   st.addBatch("insert b");
   st.addBatch("insert c");
   st.addBatch("insert d");
   st.executeBatch();

If you're interested in the gory protocol details, take a look at
http://www.postgresql.org/docs/7.4/static/protocol-flow.html#AEN52666

-O

pgsql-jdbc by date:

Previous
From: Aaron Mulder
Date:
Subject: Re: 1300 to 3100 lines of code for XA support
Next
From: Alan Stange
Date:
Subject: Re: executeBatch() issue with new driver?