Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 2FAC06333C5; Wed, 21 Apr 2010 11:41:39 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 32038-03; Wed, 21 Apr 2010 14:41:28 +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-pw0-f46.google.com (mail-pw0-f46.google.com [209.85.160.46]) by mail.postgresql.org (Postfix) with ESMTP id 45B1F632FB6; Wed, 21 Apr 2010 11:41:28 -0300 (ADT) Received: by pwj9 with SMTP id 9so5132322pwj.19 for ; Wed, 21 Apr 2010 07:41:26 -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 :content-transfer-encoding; bh=4QC25U+LxVJT3bwfkljXWQsm4PQ/+w0seKfN3EHlnr4=; b=VdkrxaJe2meM9swqIwv5oTOy1mHg/C0UWnO3HJrM31QYBikr+3EUha69Ll1oRu52dy O7FYIDkyiutZDSHmX4vBICljlGCo5yfsuEhQgcf7bpVl46+EM1Rx+kGd7wuJY/A+x16d rBLzrRSvODYdnlADbkHuPOsrOWGr3Qh4mGDig= 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:content-transfer-encoding; b=YdQznyx8/105yLDzHEbXmmUNg9fO4OO5X2fXVtWEVAAQMnWD0HqDwM8KYhn+qLsN8X cwJvRLw5yfGpSXPsoABcKyqnNASbLzkvjPW5LccCyrDpmjibQOtLg0Q4fwkaSQSrt8MQ X3RdX7d6dySD/LgO7nKb94MWjZhXT3Lpghfh0= MIME-Version: 1.0 Received: by 10.231.38.194 with HTTP; Wed, 21 Apr 2010 07:41:25 -0700 (PDT) In-Reply-To: References: <4BCD73AF0200002500030BC2@gw.wicourts.gov> <4BCD90D80200002500030BDD@gw.wicourts.gov> <4BCDC6B90200002500030C09@gw.wicourts.gov> Date: Wed, 21 Apr 2010 10:41:25 -0400 Received: by 10.142.117.27 with SMTP id p27mr3753618wfc.252.1271860885959; Wed, 21 Apr 2010 07:41:25 -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: Robert Haas To: Kris Jurka Cc: Dave Crooke , Kevin Grittner , pgsql-jdbc@postgresql.org, pgsql-performance , Scott Carey Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.499 tagged_above=-10 required=5 tests=BAYES_05=-0.5, FREEMAIL_FROM=0.001 X-Spam-Level: X-Archive-Number: 201004/52 X-Sequence-Number: 20463 On Tue, Apr 20, 2010 at 5:05 PM, Kris Jurka wrote: > The reason this is not done is that the mechanism used for fetching a pie= ce > of the results at a time can change the query plan used if using a > PreparedStatement. =A0There are three ways to plan a PreparedStatement: > > a) Using the exact parameter values by substituting them directly into th= e > query. =A0This isn't really "planned" as you can't re-use it at all. =A0T= his is > only available using the V2 protocol. > > b) Using the parameter values for statistics, but not making any stronger > guarantees about them. =A0So the parameters will be used for evaluating t= he > selectivity, but not to perform other optimizations like contraint_exclus= ion > or transforming a LIKE operation to a range query. This is the default pl= an > type the JDBC driver uses. Hmm. I didn't think this was possible. How are you doing this? > c) Planning the query with no regard for the parameters passed to it. Thi= s > is the plan type the JDBC driver uses when it sees the same > PreparedStatement being re-used multiple times or when it is respecting > setFetchSize and allowing for partial results. > > We must use (c) for partial results instead of (b) because of some > limitations of the server. =A0Currently you cannot have two statements of= type > (b) open on the same connection. =A0So since the driver can't know if the= user > will issue another query before fetching the remainder of the first query= 's > results, it must setup the first query to be of type (c) so that multiple > statements can exist simultaneously. > > Switching the default plan type to (c) will cause a significant number of > complaints as performance on some queries will go into the tank. =A0Perha= ps we > could have a default fetchSize for plain Statements as it won't affect th= e > plan. =A0I could also see making this a URL parameter though so it could = be > set as the default with only a configuration, not a code change. ...Robert