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

Re: OutOfMemory

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Guido Fiala <guido(dot)fiala(at)dka-gmbh(dot)de>
Cc: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: OutOfMemory
Date: 2004-03-30 19:52:51
Message-ID: 1080676371.10919.208.camel@localhost.localdomain (view raw or flat)
Thread:
Lists: pgsql-jdbc
Guido,

One thing of note, is that for the driver to use a cursor based fetch,
it must be inside a transaction, in other words setAutoCommit(false);

Dave
On Tue, 2004-03-30 at 07:16, Guido Fiala wrote:
> 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
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
> 
-- 
Dave Cramer
519 939 0336
ICQ # 14675561


In response to

pgsql-jdbc by date

Next:From: Alan StangeDate: 2004-03-30 22:10:32
Subject: Re: V3 protocol, batch statements and binary transfer
Previous:From: Jeff AmielDate: 2004-03-30 15:42:32
Subject: what is lslowing me down? JDBC or Postgresql itself?

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