X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 05632D1B4A8 for ; Thu, 20 May 2004 01:40:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 67015-02 for ; Thu, 20 May 2004 01:39:59 -0300 (ADT) Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) by svr1.postgresql.org (Postfix) with ESMTP id E9960D1D75F for ; Thu, 20 May 2004 01:39:28 -0300 (ADT) Received: by ganymede.hub.org (Postfix, from userid 1000) id 39EE63AD2F; Thu, 20 May 2004 01:39:29 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by ganymede.hub.org (Postfix) with ESMTP id 3931A3983B for ; Thu, 20 May 2004 01:39:29 -0300 (ADT) X-Received: from localhost ([unix socket]) by ganymede.hub.org (Cyrus v2.2.3) with LMTP; Wed, 19 May 2004 18:38:03 -0300 X-Sieve: CMU Sieve 2.2 X-Received: from localhost (localhost [127.0.0.1]) by ganymede.hub.org (Postfix) with ESMTP id 1589E3E886 for ; Wed, 19 May 2004 18:38:02 -0300 (ADT) X-Received: from mail.postgresql.org [200.46.204.71] by localhost with IMAP (fetchmail-6.2.5) for scrappy@localhost (single-drop); Wed, 19 May 2004 18:38:02 -0300 (ADT) X-Received: from svr1.postgresql.org ([unix socket]) by svr1.postgresql.org (Cyrus v2.2.3) with LMTP; Wed, 19 May 2004 18:34:57 -0300 X-Sieve: CMU Sieve 2.2 X-Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BBED9D1B3C6 for ; Wed, 19 May 2004 18:34:57 -0300 (ADT) X-Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 20345-08 for ; Wed, 19 May 2004 18:34:33 -0300 (ADT) X-Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) by svr1.postgresql.org (Postfix) with ESMTP id D7BDCD1B8EB for ; Wed, 19 May 2004 18:31:34 -0300 (ADT) X-Received: from geophile.com ([24.91.49.146]) by comcast.net (sccrmhc11) with SMTP id <2004051921313601100gbrk7e> (Authid: audrey.orenstein); Wed, 19 May 2004 21:31:37 +0000 Message-ID: <40ABD19C.8080109@geophile.com> Date: Wed, 19 May 2004 17:29:00 -0400 From: Jack Orenstein User-Agent: Mozilla/4.0 (compatible;MSIE 5.5; Windows 98) X-Accept-Language: en-us, en MIME-Version: 1.0 To: psql-jdbc@postgresql.org Subject: Queries with large ResultSets Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-DCC: : X-Spam-Pyzor: ReSent-Date: Thu, 20 May 2004 01:39:25 -0300 (ADT) Resent-From: "Marc G. Fournier" Resent-To: pgsql-jdbc@postgresql.org ReSent-Subject: Queries with large ResultSets ReSent-Message-ID: <20040520013925.H5739@ganymede.hub.org> X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/123 X-Sequence-Number: 10133 If I'm reading the source code correctly, the PostgreSQL 7.3.4 JDBC driver creates a ResultSet by evaluating the entire query, and putting all the rows into a Vector. ResultSet.next() iterates over the Vector. Is that in fact what is happening? If so, this isn't very good for processing large ResultSets. The only other open-source driver I could find is jxDBCon (http://jxdbcon.sourceforge.net). Does anyone here have experience with it? One obvious application-level workaround is to add ORDER BY and LIMIT to the query, retrieve batches, keeping track of the last primary key value, etc. That has lots of problems -- changing the results of the overall scan (since each query runs at a different time), and doing an index scan instead of a seq scan. I'm considering modifying the driver, but that would put me behind on my development schedule. Jack Orenstein