Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 660EC9FA502 for ; Tue, 26 Sep 2006 09:01:21 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 65026-04 for ; Tue, 26 Sep 2006 12:00:45 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (mail.logix-tt.com [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id 73CC79F9ECF for ; Tue, 26 Sep 2006 09:00:45 -0300 (ADT) Received: from kingfisher.intern.logix-tt.com (84-72-188-217.dclient.hispeed.ch [84.72.188.217]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id C80AE65977 for ; Tue, 26 Sep 2006 14:03:05 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id D9C11181AC330 for ; Tue, 26 Sep 2006 14:00:45 +0200 (CEST) Message-ID: <4519166D.9040705@logix-tt.com> Date: Tue, 26 Sep 2006 14:00:45 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Thunderbird 1.5.0.5 (X11/20060812) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: Bind message References: <451846B0.6070906@logix-tt.com> <45184D61.3010007@opencloud.com> <4518E986.3030801@logix-tt.com> <4518FF16.3050804@opencloud.com> In-Reply-To: <4518FF16.3050804@opencloud.com> X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200609/117 X-Sequence-Number: 15835 Hi, Oliver, Oliver Jowett wrote: >> Ah. But usually, the other parameter values for the same prepared >> statement produce similar query plans, because they're the same use case >> on similar data. > > For the "wrong" values though the plan might be pathologically bad. Yes, I know, and that's why I'd like to retain the possibilitiy of preparing a new statement with a different first parameter set for different use cases, and introduce the option of switching back to the current behaviour. >> Maybe this behaviour should be configurable via some session >> configuration variable? > > Isn't this just a very roundabout way of overriding the planner? i.e. > what you are really doing is saying "ignore your statistics, I know more > about the parameter values I'm going to give you than I'm actually > telling you".. No, it's telling the planner "You can assume that all those queries for my statement are similar enough that the same query plan will fit them, so you can safe the overhead of both parsing and planning". Don't forget that, in the current implementation, the query planner has no choice but planning the query without any actual parameter values, which is likely to give equal or worse results in most cases. The use case I have in mind are geometric data lookup of mostly static data (PostGIS objects) that are nicely distributed, and the queries all fetch a small bounding box hitting a fraction of at most 1/1000th, more likely 1/1000000 of the data. For them, the GIST index scan is the best query plan. Another option would be that the planner uses some self-learning algorithm that analyzes the parameter sets for a given prepared statement, and sees whether it's better to replan always, keep the same plan, or even efficiently switch between a small set of fixed plans. But that's out of scope for now, I'm afraid. Thanks, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in Europe! www.ffii.org www.nosoftwarepatents.org