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