pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Kris Jurka <books@ejurka.com>
Cc: Bahadur Singh <bahadursingh@yahoo.com>
Cc: pgsql-bugs@postgresql.org
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] BUG #1347: Bulk Import stopps after a while ( 8.0.0.
Date: Tue, 14 Dec 2004 09:58:16 +1300
Message-ID: <41BE0268.1060602@opencloud.com> (raw)
In-Reply-To: <25966.1102958463@sss.pgh.pa.us>
References: <20041213072018.2B6C2738805@www.postgresql.com>
	<Pine.BSO.4.56.0412130234430.26362@leary.csoft.net>
	<25966.1102958463@sss.pgh.pa.us>

Tom Lane wrote:
> Kris Jurka <books@ejurka.com> writes:
> 
>>    // To avoid this, we guess at how many queries we can send before the 
>>    // server -> driver stream's buffer is full (MAX_BUFFERED_QUERIES). 
> 
> 
> It seems essentially impossible for the driver to do this reliably,
> since it has no clue how much data any one query will return.

Right, but I'm not convinced that this is the problem here as batch 
execution in JDBC is only allowed to do non-result-set-returning 
queries. The only case I can think of where this would break is if 
something is causing lots of logging output to the client (triggers etc.).

> How about instead thinking in terms of not filling the driver->server
> channel?  You have a good handle on how much data you have sent (or at
> least you could keep track of that), and if you bound it to 64K or so
> then you should be safe.  Perhaps the limit ought to be easily
> configurable just in case, but at least you'd be measuring something
> measurable.

That's possibly a better idea but it does mean that we wouldn't be able 
to batch inserts that contain lots of data. That's the use case I needed 
to support when I wrote this in the first place..

Also, it's never going to be 100% without a separate thread, as the 
server can spontaneously generate output (e.g. because of NOTIFY) 
regardless of how careful we are with our queries.

There's actually another problem with this code: the subdivision into 
smaller batches is not transparent if autocommit is on. We send a Sync 
at the end of the batch which will cause an implicit commit. We should 
be sending a Flush, but it's harder for the driver to handle this as a 
Flush does not provoke a response message from the server, so we would 
have to track the protocol state more closely. Given that JDBC is silent 
about the autocommit semantics of batch execution anyway, I'm not too 
worried about fixing this urgently.

I'd like to see that this is really the problem before tweaking this 
code. Given that the OP said that batch sizes of 1000-2000 worked OK, 
I'm not sure that this code is the problem since the maximum number of 
queries we'll send per batch is around 250 by default.

-O



view thread (17+ messages)  latest in thread

Message-ID: <41BE0268.1060602@opencloud.com>
Permalink:  ../41BE0268.1060602@opencloud.com/
Also on:    postgresql.org/message-id/41BE0268.1060602@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, tgl@sss.pgh.pa.us, books@ejurka.com, bahadursingh@yahoo.com, pgsql-bugs@postgresql.org
  Subject: Re: [JDBC] BUG #1347: Bulk Import stopps after a while ( 8.0.0.
  In-Reply-To: <41BE0268.1060602@opencloud.com>
  References: <20041213072018.2B6C2738805@www.postgresql.com> <Pine.BSO.4.56.0412130234430.26362@leary.csoft.net> <25966.1102958463@sss.pgh.pa.us> <41BE0268.1060602@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