Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id C0EE7632414 for ; Thu, 15 Apr 2010 20:39:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 95636-04 for ; Thu, 15 Apr 2010 23:39:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f228.google.com (mail-bw0-f228.google.com [209.85.218.228]) by mail.postgresql.org (Postfix) with ESMTP id 6F4626322B5 for ; Thu, 15 Apr 2010 20:39:40 -0300 (ADT) Received: by bwz28 with SMTP id 28so2147580bwz.34 for ; Thu, 15 Apr 2010 16:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:received:message-id :subject:from:to:content-type; bh=7o1tiaD+GtfxO1IK/84FPAKhegpuhG5H6eRcyysihq4=; b=vAnU1lRpFvfHDwMpTdy7YY+zheS4w0oOr56Ll8dT6TJ4JQbPoY6d+gwqPvFcLdJgkB CdzDrX+POaSVYaNhdpZxLMuPZyisKuGSgDz+tcMSynwqaBX+ZrLc2EqmXSS7JxpW+7ro AGxnJBe+zQ6YHM2SMBoCXko59udvjnP3oVgnM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=bzA2t+ijgH9n51wmXo1HRCTrZr+xIi/UA4XF6w0UQTsMZevfJ/c/a6hELJ3/T6AAMA FuuHe3NfwkACVZMmAbuDHhoYJTroyXJZ4yEA6U8r91HkJP6LqxTMd3v/G87wkRW7kgIW ZtCYlHdUBuENfLah8OaMgfA9RjBWaZ9MOKFzM= MIME-Version: 1.0 Received: by 10.204.66.8 with HTTP; Thu, 15 Apr 2010 16:39:37 -0700 (PDT) Date: Thu, 15 Apr 2010 18:39:37 -0500 Received: by 10.204.75.67 with SMTP id x3mr916511bkj.116.1271374777305; Thu, 15 Apr 2010 16:39:37 -0700 (PDT) Message-ID: Subject: SOLVED: Re: HELP: How to tame the 8.3.x JDBC driver with a biq guery result set From: Dave Crooke To: pgsql-performance Content-Type: multipart/alternative; boundary=0016e6dbe6d2fa4cbb04844f0119 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.049 tagged_above=-10 required=5 tests=AWL=-0.150, BAYES_00=-1.9, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201004/197 X-Sequence-Number: 38447 --0016e6dbe6d2fa4cbb04844f0119 Content-Type: text/plain; charset=UTF-8 When a connection is used for both reading and writing, a commit() also destroys any open cursors. Simple workaround - use two connections. See full discussion on JDBC list. Cheers Dave On Thu, Apr 15, 2010 at 3:01 PM, Dave Crooke wrote: > I have followed the instructions below to no avail .... any thoughts? > > > http://jdbc.postgresql.org/documentation/83/query.html#query-with-cursor > > This is what happens when I reduce the fetch_size to 50 ... stops after > about 950msec and 120 fetches (6k rows) .... > > > 13:59:56,054 [PerfDataMigrator] ERROR > com.hyper9.storage.sample.persistence.PersistenceManager:3216 - Unexpected > error while migrating sample data: 6000 > org.postgresql.util.PSQLException: ERROR: portal "C_14" does not exist > > at > org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592) > at > org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1327) > at > org.postgresql.core.v3.QueryExecutorImpl.fetch(QueryExecutorImpl.java:1527) > at > org.postgresql.jdbc2.AbstractJdbc2ResultSet.next(AbstractJdbc2ResultSet.java:1843) > at > org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:169) > at > org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:169) > at > com.hyper9.storage.sample.persistence.PersistenceManager$Migrator.run(PersistenceManager.java:3156) > at java.lang.Thread.run(Thread.java:619) > > > Cheers > Dave > > > > On Thu, Apr 15, 2010 at 2:42 PM, Dave Crooke wrote: > >> Hey folks >> >> I am trying to do a full table scan on a large table from Java, using a >> straightforward "select * from foo". I've run into these problems: >> >> 1. By default, the PG JDBC driver attempts to suck the entire result set >> into RAM, resulting in *java.lang.OutOfMemoryError* ... this is not cool, >> in fact I consider it a serious bug (even MySQL gets this right ;-) I am >> only testing with a 9GB result set, but production needs to scale to 200GB >> or more, so throwing hardware at is is not feasible. >> >> 2. I tried using the official taming method, namely * >> java.sql.Statement.setFetchSize(1000)* and this makes it blow up entirely >> with an error I have no context for, as follows (the number C_10 varies, >> e.g. C_12 last time) ... >> >> org.postgresql.util.PSQLException: ERROR: portal "C_10" does not exist >> at >> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592) >> at >> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1327) >> at >> org.postgresql.core.v3.QueryExecutorImpl.fetch(QueryExecutorImpl.java:1527) >> at >> org.postgresql.jdbc2.AbstractJdbc2ResultSet.next(AbstractJdbc2ResultSet.java:1843) >> >> This is definitely a bug :-) >> >> >> Is there a known workaround for this ... will updating to a newer version >> of the driver fix this? >> >> Is there a magic incation of JDBC calls that will tame it? >> >> Can I cast the objects to PG specific types and access a hidden API to >> turn off this behaviour? >> >> If the only workaround is to explicitly create a cursor in PG, is there a >> good example of how to do this from Java? >> >> Cheers >> Dave >> >> >> >> >> >> > --0016e6dbe6d2fa4cbb04844f0119 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable When a connection is used for both reading and writing, a commit() also des= troys any open cursors. Simple workaround - use two connections.

See= full discussion on JDBC list.

Cheers
Dave

On Thu, Apr 15, 2010 at 3:01 PM, Dave Crooke <dcrooke@gmail.com> wrote:
I have followed the instructions below to no avail .... any thoughts?This is what happens when I reduce the fetch_size to 50 ... stops= after about 950msec and 120 fetches (6k rows) ....

13:59:56,054 [PerfDataMigrator] ERROR com.hyper9.storage.sample.persisten= ce.PersistenceManager:3216 - Unexpected error while migrating sample data: = 6000
org.postgresql.util.PSQLException: ERROR: portal "C_14" does not = exist

=C2=A0=C2=A0=C2=A0 at org.postgresql.core.v3.Que= ryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592)
=C2=A0= =C2=A0=C2=A0 at org.postgresql.core.v3.QueryExecutorImpl.processResults(Que= ryExecutorImpl.java:1327)
=C2=A0=C2=A0=C2=A0 at org.postgresql.core.v3.QueryExecutorImpl.fetch(QueryE= xecutorImpl.java:1527)
=C2=A0=C2=A0=C2=A0 at org.postgresql.jdbc2.Abstra= ctJdbc2ResultSet.next(AbstractJdbc2ResultSet.java:1843)
=C2=A0=C2=A0=C2=A0 at org.apache.commons.dbcp.DelegatingResultSet.n= ext(DelegatingResultSet.java:169)
=C2=A0=C2=A0=C2=A0 at org.apache.commons.dbcp.DelegatingResultSet.next(Dele= gatingResultSet.java:169)
=C2=A0=C2=A0=C2=A0 at com.hyper9.storage.sampl= e.persistence.PersistenceManager$Migrator.run(PersistenceManager.java:3156)=
=C2=A0=C2=A0=C2=A0 at java.lang.Thread.run(Thread.java:619)


Cheers
Dave
=



On Thu, Apr 15, 20= 10 at 2:42 PM, Dave Crooke <dcrooke@gmail.com> wrote:
Hey folks

I am trying to do a full table scan on a large table from = Java, using a straightforward "select * from foo". I've run i= nto these problems:

1. By default, the PG JDBC driver attempts to su= ck the entire result set into RAM, resulting in java.lang.OutOfMemoryErr= or ... this is not cool, in fact I consider it a serious bug (even MySQ= L gets this right ;-) I am only testing with a 9GB result set, but producti= on needs to scale to 200GB or more, so throwing hardware at is is not feasi= ble.

2. I tried using the official taming method, namely java.sql.Stateme= nt.setFetchSize(1000) and this makes it blow up entirely with an error = I have no context for, as follows (the number C_10 varies, e.g. C_12 last t= ime) ...

org.postgresql.util.PSQLException: ERROR: portal "C_10" does = not exist
=C2=A0=C2=A0=C2=A0 at org.postgresql.core.v3.QueryExecutorImpl= .receiveErrorResponse(QueryExecutorImpl.java:1592)
=C2=A0=C2=A0=C2=A0 at= org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.= java:1327)
=C2=A0=C2=A0=C2=A0 at org.postgresql.core.v3.QueryExecutorImpl.fetch(QueryE= xecutorImpl.java:1527)
=C2=A0=C2=A0=C2=A0 at org.postgresql.jdbc2.Abstra= ctJdbc2ResultSet.next(AbstractJdbc2ResultSet.java:1843)

This is defi= nitely a bug :-)


Is there a known workaround for this ... will updating to a newer version o= f the driver fix this?

Is there a magic incation of JDBC calls that= will tame it?

Can I cast the objects to PG specific types and acces= s a hidden API to turn off this behaviour?

If the only workaround is to explicitly create a cursor in PG, is there= a good example of how to do this from Java?

Cheers
Dave







--0016e6dbe6d2fa4cbb04844f0119--