Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsHQI-00018x-SW for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Jan 2013 18:27:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TsHQH-0001oo-U1 for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Jan 2013 18:27:45 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsHQH-0001oj-59 for pgsql-hackers@postgresql.org; Mon, 07 Jan 2013 18:27:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsHQF-0007TP-3C for pgsql-hackers@postgresql.org; Mon, 07 Jan 2013 18:27:44 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id r07IRcc6013843; Mon, 7 Jan 2013 13:27:38 -0500 (EST) From: Tom Lane To: Simon Riggs cc: Jeff Janes , pgsql-hackers Subject: Re: [PERFORM] Slow query: bitmap scan troubles In-reply-to: References: <092a01cdd230$ff6143c0$fe23cb40$@foo.me.uk> <097601cdd249$ae338530$0a9a8f90$@foo.me.uk> <9022.1354730710@sss.pgh.pa.us> <28944.1357424296@sss.pgh.pa.us> <18164.1357498720@sss.pgh.pa.us> <8539.1357513385@sss.pgh.pa.us> <12791.1357580151@sss.pgh.pa.us> Comments: In-reply-to Simon Riggs message dated "Mon, 07 Jan 2013 18:03:37 +0000" Date: Mon, 07 Jan 2013 13:27:38 -0500 Message-ID: <13842.1357583258@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Simon Riggs writes: > On 7 January 2013 17:35, Tom Lane wrote: >> That gives a formula of >> cpu_operator_cost * log2(N) + cpu_operator_cost * 50 * (H+2) > Again, this depends on N and H, so thats good. > I think my retinas detached while reading your explanation, but I'm a > long way from coming up with a better or more principled one. > If we can describe this as a heuristic that appears to fit the > observed costs, we may keep the door open for something better a > little later. I'm fairly happy with the general shape of this formula: it has a principled explanation and the resulting numbers appear to be sane. The specific cost multipliers obviously are open to improvement based on future evidence. (In particular, I intend to code it in a way that doesn't tie the "startup overhead" and "cost per page" numbers to be equal, even though I'm setting them equal for the moment for lack of a better idea.) One issue that needs some thought is that the argument for this formula is based entirely on thinking about b-trees. I think it's probably reasonable to apply it to gist, gin, and sp-gist as well, assuming we can get some estimate of tree height for those, but it's obviously hogwash for hash indexes. We could possibly just take H=0 for hash, and still apply the log2(N) part ... not so much because that is right as because it's likely too small to matter. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers