Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 781D1632FB6; Tue, 20 Apr 2010 17:40:27 -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 04583-01; Tue, 20 Apr 2010 20:40:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f221.google.com (mail-bw0-f221.google.com [209.85.218.221]) by mail.postgresql.org (Postfix) with ESMTP id 1EAE36332D3; Tue, 20 Apr 2010 17:40:15 -0300 (ADT) Received: by bwz21 with SMTP id 21so5963238bwz.35 for ; Tue, 20 Apr 2010 13:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:received:message-id:subject:from:to:cc:content-type; bh=5IlvX5vO87bhXxxsBcKujSLrRk/hVSBZl6J4E3YODQ0=; b=n1WGuv5dpU9AH7S59WVoLwahMmU9rdwWESW4q3nUrguKHtXAq3hyNs3xY8njvmc+L2 oHqMvgZ4Rzsoz+GbPizXHw+7zUAjHvNfiKCz9IbN3B7J2kzAcKqIhHKkGcr+3d5WIdH/ iDOT9wslURlLlZALVifJJ/6f6ANQVGmBv/HxA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=jacod8BwbdCMuO3GQO3kulUGXEc5RrXNmAgherWa8E3B+koOOqt26itXLUsGomy24p UY4X8VocgRgnaoLgbxTx+EydHd+5TnDzF00K/5WIp9MxjiDVWj4APenUMYlJXi+r92oB BL+xYUtoq4+Kt67cV9JvvOJLoevSRG8B3R/UA= MIME-Version: 1.0 Received: by 10.204.66.8 with HTTP; Tue, 20 Apr 2010 13:40:14 -0700 (PDT) In-Reply-To: <4BCDC6B90200002500030C09@gw.wicourts.gov> References: <4BCD73AF0200002500030BC2@gw.wicourts.gov> <4BCD90D80200002500030BDD@gw.wicourts.gov> <4BCDC6B90200002500030C09@gw.wicourts.gov> Date: Tue, 20 Apr 2010 15:40:14 -0500 Received: by 10.204.73.165 with SMTP id q37mr6593807bkj.100.1271796014582; Tue, 20 Apr 2010 13:40:14 -0700 (PDT) Message-ID: Subject: Re: SOLVED ... Re: Getting rid of a cursor from JDBC .... Re: [PERFORM] Re: HELP: How to tame the 8.3.x JDBC driver with a biq guery result set From: Dave Crooke To: Kevin Grittner Cc: pgsql-jdbc@postgresql.org, pgsql-performance , Scott Carey Content-Type: multipart/alternative; boundary=0016e6db66f9ad0ff50484b11549 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.974 tagged_above=-10 required=5 tests=AWL=-0.075, BAYES_00=-1.9, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201004/38 X-Sequence-Number: 20449 --0016e6db66f9ad0ff50484b11549 Content-Type: text/plain; charset=UTF-8 I digest this down to "this is the best that can be achieved on a connection that's single threaded" I think the big difference with Oracle is this: i. in Oracle, a SELECT does not have to be a transaction, in the sense that PG's SELECT does ... but in Oracle, a SELECT can fail mid-stream if you wait too long and the UNDO tablespace wraps (ORA-600), i.e. Oracle does not lock on SELECT. Oracle is optimized for lots of small transactions that typically commit, PG supports arbitrary transaction mixes of any size, but is less efficient at the workload for which Oracle is specialized. ii. SELECT always creates an implicit cursor in Oracle, but access to these cursors can be interleaved arbitrarily on one connection both with each other and transactions (writes) After consiering the context you offered, I'd recommend the following two minor changes to the PG driver .... a. Make setFetchSize(10000) the default b. If someone does call rs.close() before the end of the ResultSet, and has not created an explicit cursor at the JDBC level, flag the query / lock / virtual transaction in some way in the JDBC driver that tells it that it can just dump the cursor on a subsequent stmt.close(), conn.commit() or conn.close() call without sucking down the rest of the data. AFAICT, this will make the behaviour more like other DB's without sacrifcing anything, but I don't know what default behaviour expectations might be out there in PG land. Cheers Dave On Tue, Apr 20, 2010 at 3:22 PM, Kevin Grittner wrote: (Lots of good explanatory stuff) --0016e6db66f9ad0ff50484b11549 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I digest this down to "this is the best that can be achieved on a conn= ection that's single threaded"

I think the big difference w= ith Oracle is this:

i. in Oracle, a SELECT does not have to be a tra= nsaction, in the sense that PG's SELECT does ... but in Oracle, a SELEC= T can fail mid-stream if you wait too long and the UNDO tablespace wraps (O= RA-600), i.e. Oracle does not lock on SELECT. Oracle is optimized for lots = of small transactions that typically commit, PG supports arbitrary transact= ion mixes of any size, but is less efficient at the workload for which Orac= le is specialized.

ii. SELECT always creates an implicit cursor in Oracle, but access to t= hese cursors can be interleaved arbitrarily on one connection both with eac= h other and transactions (writes)

After consiering the context you o= ffered, I'd recommend the following two minor changes to the PG driver = ....

a. Make setFetchSize(10000) the default

b. If someone does call = rs.close() before the end of the ResultSet, and has not created an explicit= cursor at the JDBC level, flag the query / lock / virtual transaction in s= ome way in the JDBC driver that tells it that it can just dump the cursor o= n a subsequent stmt.close(), conn.commit() or conn.close() call without suc= king down the rest of the data.

AFAICT, this will make the behaviour more like other DB's without s= acrifcing anything, but I don't know what default behaviour expectation= s might be out there in PG land.

Cheers
Dave

On Tue, Apr 20, 2010 at 3:22 PM, Kevin Grittner <Kevin.Grittner@wicourts.gov&g= t; wrote:
(Lots of good explanatory stuff)
<= br> --0016e6db66f9ad0ff50484b11549--