X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BE9F8D1B1B9 for ; Fri, 23 Jul 2004 21:11:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99076-01 for ; Sat, 24 Jul 2004 00:11:45 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 1C1EAD1B174 for ; Fri, 23 Jul 2004 21:11:40 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1BoA8Z-0004FZ-00; Sat, 24 Jul 2004 12:11:39 +1200 Message-ID: <4101A936.9040604@opencloud.com> Date: Sat, 24 Jul 2004 12:11:34 +1200 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bill Schneider Cc: pgsql-jdbc@postgresql.org Subject: Re: JDBC memory usage References: <410156D7.50109@vecna.com> In-Reply-To: <410156D7.50109@vecna.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/275 X-Sequence-Number: 10659 Bill Schneider wrote: > Hello, > > I noticed that I keep running out of memory when trying to run a query > that returns 100,000 rows or so. > > Searching the archives, it seems that the JDBC driver reads the entire > ResultSet into memory at once rather than using cursors. This is > definitely not the desired behavior for this particular query. > > Has this been fixed recently? I'm using PostgreSQL 7.3.4 with the > corresponding JDBC driver. Do all of: - use current development drivers and a 7.4 server, or pre-build-302 drivers and a 7.2/7.3/7.4 server - call Connection.setAutoCommit(false) - create statements that produce resultsets of type TYPE_FORWARD_ONLY - call Statement.setFetchSize() - use queries that consist of a single SELECT with no trailing ';' (only a requirement if using older drivers) Then the driver should use cursors to batch access to the resultset. -O