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 09:55:23 +1300
Message-ID: <4187F43B.2070505@opencloud.com> (raw)
In-Reply-To: <4187EBA4.2040100@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>

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



view thread (13+ messages)  latest in thread

Message-ID: <4187F43B.2070505@opencloud.com>
Permalink:  ../4187F43B.2070505@opencloud.com/
Also on:    postgresql.org/message-id/4187F43B.2070505@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: <4187F43B.2070505@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> <4187F43B.2070505@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