Skip site navigation (1) Skip section navigation (2)

Re: executeBatch() issue with new driver?

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: stange(at)rentec(dot)com
Cc: Kris Jurka <books(at)ejurka(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: executeBatch() issue with new driver?
Date: 2004-11-02 20:55:23
Message-ID: 4187F43B.2070505@opencloud.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
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

In response to

Responses

pgsql-jdbc by date

Next:From: Aaron MulderDate: 2004-11-02 21:12:10
Subject: Re: 1300 to 3100 lines of code for XA support
Previous:From: Alan StangeDate: 2004-11-02 20:44:40
Subject: Re: executeBatch() issue with new driver?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group