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

Re: OutOfMemory

From: Guido Fiala <guido(dot)fiala(at)dka-gmbh(dot)de>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: OutOfMemory
Date: 2004-03-30 12:16:28
Message-ID: 200403301416.28191.guido.fiala@dka-gmbh.de (view raw or flat)
Thread:
Lists: pgsql-jdbc
Am Montag, 29. März 2004 18:30 schrieb Alexander Staubo:
> Earlier versions of the PostgreSQL JDBC driver do not stream data from
> the back end: they fetch everything in one go.
>
> The PostgreSQL 7.4 JDBC driver supports JDBC's setFetchSize()
> operation, and will use PostgreSQL cursors internally. If you set the
> fetch size to something >0, it will correctly [*] and transparently
> stream data on demand. The driver works perfectly with earlier
> versions of PostgreSQL.
>
> With earlier versions of the driver, you can emulate the behaviour by
> first doing this:
>
>    stmt.executeUpdate("declare foo cursor for select * from bar");
>
> and then for each batch, as an executeQuery():
>
>    rs = stmt.executeQuery("fetch forward 200 from foo");
>
> and when you're done with the cursor,
>
>    stmt.executeUpdate("close foo");

By chance i'am currently at the same point, unfortunately i don't get it 
working as expected.

-after calling ResultSet.last() the getRow() still reflects the fetchsize (how 
to get the number of records for e.g. a progress-bar?)

-calling "ResultSet.next()" at the "last" fetched record does not fetch more 
results automatically, Statement.fetchMoreResults() gives me null-pointer - 
how do i actually get the next fetch?

-according to the documentation only "FETCH_FORWARD" is supported, which is 
not always suitable

Does it have some meaning that it only works if 
Connection.setAutoCommit(false) is used?
I had a quick look through the sources and found the term 
"server-prepared-statement" is used under certain conditions - what's this 
for?

I was also thinking about using the "SELECT ... LIMIT x OFFSET y" instead, but 
this might lead to unexpected side effects if multiple users are changing 
data - the user gets only a momentary snapshot then, if the order has changed 
in between some records will never be seen, others twice and so on.

Any nice idea to solve this?

(Im using postgres 7.3 + a recent snapshot from cvs-jdbc-driver)

Guido


In response to

Responses

pgsql-jdbc by date

Next:From: Dave CramerDate: 2004-03-30 13:09:39
Subject: Re: V3 protocol, batch statements and binary transfer
Previous:From: Peter SchullerDate: 2004-03-30 10:55:58
Subject: Re: JDBC driver's (non-)handling of InputStream:s

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