X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 789203A404B for ; Tue, 2 Nov 2004 21:18:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95972-09 for ; Tue, 2 Nov 2004 21:18:00 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 9ECBF3A4061 for ; Tue, 2 Nov 2004 21:18:00 +0000 (GMT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1CP625-00006I-00; Wed, 03 Nov 2004 10:17:37 +1300 Message-ID: <4187F9D7.3060308@opencloud.com> Date: Wed, 03 Nov 2004 10:19:19 +1300 From: Oliver Jowett User-Agent: Mozilla Thunderbird 0.8 (X11/20041021) X-Accept-Language: en-us, en MIME-Version: 1.0 To: stange@rentec.com Cc: Kris Jurka , pgsql-jdbc@postgresql.org Subject: Re: executeBatch() issue with new driver? References: <4187B025.2090201@rentec.com> <4187DF2E.3030302@rentec.com> <4187EBA4.2040100@rentec.com> <4187F1B8.1010302@rentec.com> In-Reply-To: <4187F1B8.1010302@rentec.com> X-Enigmail-Version: 0.86.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/40 X-Sequence-Number: 11462 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