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 28D803A40A1 for ; Tue, 2 Nov 2004 20:54:15 +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 87482-10 for ; Tue, 2 Nov 2004 20:54:12 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id A14AA3A408C for ; Tue, 2 Nov 2004 20:54:12 +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 1CP5ex-0008Pe-00; Wed, 03 Nov 2004 09:53:43 +1300 Message-ID: <4187F43B.2070505@opencloud.com> Date: Wed, 03 Nov 2004 09:55:23 +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> In-Reply-To: <4187EBA4.2040100@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/38 X-Sequence-Number: 11460 Alan Stange wrote: >> Especially since you are already using addBatch, there doesn't seem to >> be much point in jamming two commands into one batch. >> > Network latency. We were able to greatly increase performance this way > by reducing the number of round trips. If you give the development driver multiple queries via *multiple* addBatch() calls, it will avoid the extra round trips. i.e. if you do: stmt.addBatch("CREATE TABLE ..."); stmt.addBatch("INSERT ..."); stmt.executeBatch(); then the driver will only do one round trip. There is a limit of somewhere around 100 queries per round-trip (from memory) due to some issues with avoiding network deadlocks, but in practice that won't have much effect on performance. AFAIK this is exactly what addBatch/executeBatch is there for. It's just that the older driver was not particularly smart about handling this case, so you had to shoehorn multiple statements into one query to get the same effect. Both driver versions should handle multiple queries per query string if you use the normal query execution interface rather than the batch interface. The older driver doesn't handle multiple resultsets per query, but multiple updates (or other queries that do not return results) should be fine. -O