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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-jdbc by date

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