pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: stange@rentec.com
Cc: Kris Jurka <books@ejurka.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: executeBatch() issue with new driver?
Date: Wed, 03 Nov 2004 10:19:19 +1300
Message-ID: <4187F9D7.3060308@opencloud.com> (raw)
In-Reply-To: <4187F1B8.1010302@rentec.com>
References: <4187B025.2090201@rentec.com>
	<Pine.BSO.4.56.0411021411070.17267@leary.csoft.net>
	<4187DF2E.3030302@rentec.com>
	<Pine.BSO.4.56.0411021427540.3642@leary.csoft.net>
	<4187EBA4.2040100@rentec.com>
	<Pine.BSO.4.56.0411021520580.17126@leary.csoft.net>
	<4187F1B8.1010302@rentec.com>

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



view thread (13+ messages)  latest in thread

Message-ID: <4187F9D7.3060308@opencloud.com>
Permalink:  ../4187F9D7.3060308@opencloud.com/
Also on:    postgresql.org/message-id/4187F9D7.3060308@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: oliver@opencloud.com, stange@rentec.com, books@ejurka.com
  Subject: Re: executeBatch() issue with new driver?
  In-Reply-To: <4187F9D7.3060308@opencloud.com>
  References: <4187B025.2090201@rentec.com> <Pine.BSO.4.56.0411021411070.17267@leary.csoft.net> <4187DF2E.3030302@rentec.com> <Pine.BSO.4.56.0411021427540.3642@leary.csoft.net> <4187EBA4.2040100@rentec.com> <Pine.BSO.4.56.0411021520580.17126@leary.csoft.net> <4187F1B8.1010302@rentec.com> <4187F9D7.3060308@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox