X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 5283711F6250 for ; Tue, 18 Apr 2006 07:52:25 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 0.115 X-Spam-Level: X-Spam-Status: No, score=0.115 required=5 tests=[AWL=0.115] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 5VFXN8ZPUWeq for ; Tue, 18 Apr 2006 07:51:40 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (unknown [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id E9AA311F621A for ; Tue, 18 Apr 2006 07:51:42 -0300 (ADT) Received: from kingfisher.intern.logix-tt.com (Tba08.t.pppool.de [89.55.186.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 053B8656CD for ; Tue, 18 Apr 2006 12:52:42 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 2B756181C1F3F for ; Tue, 18 Apr 2006 12:52:00 +0200 (CEST) Message-ID: <4444C4CF.2000106@logix-tt.com> Date: Tue, 18 Apr 2006 12:51:59 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: merge>hash>loop References: <1145029009.3422.31.camel@spectre.intellivid.com> <10000.1145031205@sss.pgh.pa.us> <1145033149.3422.41.camel@spectre.intellivid.com> <11035.1145033929@sss.pgh.pa.us> In-Reply-To: <11035.1145033929@sss.pgh.pa.us> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Archive-Number: 200604/367 X-Sequence-Number: 18451 Hi, Tom, Tom Lane wrote: > Well, the other thing that's going on here is that we know we are > overestimating the cost of nestloop-with-inner-indexscan plans. > The current estimation for that is basically "outer scan cost plus N > times inner scan cost" where N is the estimated number of outer tuples; > in other words the repeated indexscan probes are each assumed to happen > from a cold start. In reality, caching of the upper levels of the index > means that the later index probes are much cheaper than this model > thinks. We've known about this for some time but no one's yet proposed > a more reasonable cost model. My spontaneus guess would be to use log(N)*inner instead of N*inner. I don't have any backings for that, it's just what my intuition tells me as a first shot. > In my mind this is tied into another issue, which is that the planner > always costs on the basis of each query starting from zero. In a real > environment it's much cheaper to use heavily-used indexes than this cost > model suggests, because they'll already be swapped in due to use by > previous queries. But we haven't got any infrastructure to keep track > of what's been heavily used, let alone a cost model that could make use > of the info. An easy first approach would be to add a user tunable cache probability value to each index (and possibly table) between 0 and 1. Then simply multiply random_page_cost with (1-that value) for each scan. Later, this value could be automatically tuned by stats analysis or other means. > I think part of the reason that people commonly reduce random_page_cost > to values much lower than physical reality would suggest is that it > provides a crude way of partially compensating for this basic problem. I totall agree with this, it's just what we did here from time to time. :-) Hmm, how does effective_cach_size correspond with it? Shouldn't a high effective_cache_size have a similar effect? Thanks, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org