pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Cramer <pg@fastcrypt.com>
To: David Wall <d.wall@computer.org>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: JDBC and processing large numbers of rows
Date: Tue, 11 May 2004 15:56:34 -0400
Message-ID: <1084305394.1534.121.camel@localhost.localdomain> (raw)
In-Reply-To: <024101c4376d$d567d050$3201a8c0@rasta>
References: <20040511103520.1ADC6D1B1EE@svr1.postgresql.org>
	<40A0CB55.5060400@opencloud.com>
	<024101c4376d$d567d050$3201a8c0@rasta>

David,
Use cursors to page through really large result sets

Dave

On Tue, 2004-05-11 at 11:37, David Wall wrote:
> This is more towards JDBC than PG in particular, but since we support PG,
> Oracle and eventually other DBMS via JDBC, I thought I'd see if anybody has
> any good ideas on how do the following in a somewhat portable way via JDBC
> (by large, I'm talking about thousands to millions of rows -- significant
> amounts of data)
> 
> 1) Often people need to "page through"  large result set.  Some DBs support
> the LIMIT,OFFSET construct of SELECT, and while not super efficient, at
> least it only returns the window of the result set that is of interest.  How
> do most people handle such paging through of data?  I've heard people cache
> the entire result set, but that's not practical because of the memory
> overhead and, with the web, not even knowing when to get rid of the
> resultset.  Do people use work tables or other schemes to "pre-paginate" the
> results but store it in a temporary table?
> 
> 
> 2) How do people process many records in a large resultset?  For example,
> scanning through a list of rows and then doing some processing based on
> those rows, and then perhaps updating the rows to indicate that they've been
> processed.
> 
> 
> 3) How do people use cursors in JDBC?  Being able to FETCH seems like a nice
> way to handle question #2 above in a batch program, since only a subset of
> rows needs to be retrieved from the db at a time.  Cursors probably don't
> work for question #1 above since keeping a transaction alive across page
> views is generally frowned upon and even hard to accomplish since it means
> locking up a connection to the db for each paging user.
> 
> 
> Any pointers would be appreciated.
> 
> Thanks,
> David
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
> 
> 
> 
> !DSPAM:40a0f4e2176411409110076!
> 
> 
-- 
Dave Cramer
519 939 0336
ICQ # 14675561




view thread (17+ messages)  latest in thread

Message-ID: <1084305394.1534.121.camel@localhost.localdomain>
Permalink:  ../1084305394.1534.121.camel@localhost.localdomain/
Also on:    postgresql.org/message-id/1084305394.1534.121.camel@localhost.localdomain

 · 

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: pg@fastcrypt.com, d.wall@computer.org
  Subject: Re: JDBC and processing large numbers of rows
  In-Reply-To: <1084305394.1534.121.camel@localhost.localdomain>
  References: <20040511103520.1ADC6D1B1EE@svr1.postgresql.org> <40A0CB55.5060400@opencloud.com> <024101c4376d$d567d050$3201a8c0@rasta> <1084305394.1534.121.camel@localhost.localdomain>

* 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