Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id D2C5663312C for ; Thu, 15 Apr 2010 16:43:04 -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 38831-04 for ; Thu, 15 Apr 2010 19:42:50 +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 C82BF632C0B for ; Thu, 15 Apr 2010 16:42:53 -0300 (ADT) Received: by bwz28 with SMTP id 28so1938375bwz.34 for ; Thu, 15 Apr 2010 12:42:52 -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=V8R/SYl+jJsU4D9Q0xfyyr2+h7i/QD3lDP0Y6/5fgSk=; b=KoBMZqa3XrWn00SUBxejuG9XpWtAWQflI5VT9p9m3KwYHOYt4gh3tIguVykMf1sAnW PWsg3gdu3iIIlB880BHl29pxAYoqQDBnvYsHntXKx76fqcQjAxjAVCsjNvuz+O6RWdNI hesf6xwstd3bXuMg+0IxfN/IXjTqWTtklZJfk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=GQMmOUBApzqflqcg+v8nirvx64RmCWu4vp+/kXfAWi3G8QeaLUbqOtFm9eCt8WG5uK qUqAl765U+/Ess35dfCno5fnWKxGlu6KYZEbDwKjTyPDdvR3pG0EGmG4eXETsEkH8/cr TiBU+rCg3s+LVOmZI65fgm49Xm7cl3dmjoQMU= MIME-Version: 1.0 Received: by 10.204.66.8 with HTTP; Thu, 15 Apr 2010 12:42:51 -0700 (PDT) Date: Thu, 15 Apr 2010 14:42:51 -0500 Received: by 10.204.140.70 with SMTP id h6mr697617bku.1.1271360571841; Thu, 15 Apr 2010 12:42:51 -0700 (PDT) Message-ID: Subject: 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=0015174c424e4425d204844bb34c X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.057 tagged_above=-10 required=5 tests=AWL=-0.158, BAYES_00=-1.9, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201004/236 X-Sequence-Number: 38486 --0015174c424e4425d204844bb34c Content-Type: text/plain; charset=UTF-8 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 --0015174c424e4425d204844bb34c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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

<= br>


--0015174c424e4425d204844bb34c--