X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 16684D1C488 for ; Thu, 7 Aug 2003 20:44:29 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 27163-05 for ; Thu, 7 Aug 2003 17:43:05 -0300 (ADT) Received: from perrin.int.nxad.com (internal.ext.nxad.com [69.1.70.251]) by svr1.postgresql.org (Postfix) with ESMTP id 3EDB9D1C4E1 for ; Thu, 7 Aug 2003 17:44:18 -0300 (ADT) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id 83ADC20F00; Thu, 7 Aug 2003 13:44:19 -0700 (PDT) Date: Thu, 7 Aug 2003 13:44:19 -0700 From: Sean Chittenden To: Tom Lane Cc: Manfred Koizar , pgsql-hackers@postgresql.org Subject: Re: Correlation in cost_index() Message-ID: <20030807204419.GJ94710@perrin.int.nxad.com> References: <29475.1033598929@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <29475.1033598929@sss.pgh.pa.us> X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/406 X-Sequence-Number: 42064 > > AFAICS (part of) the real problem is in costsize.c:cost_index() where > > IO_cost is calculated from min_IO_cost, pages_fetched, > > random_page_cost, and indexCorrelation. The current implementation > > uses indexCorrelation^2 to interpolate between min_IO_cost and > > max_IO_cost, which IMHO gives results that are too close to > > max_IO_cost. > > The indexCorrelation^2 algorithm was only a quick hack with no theory > behind it :-(. I've wanted to find some better method to put in there, > but have not had any time to research the problem. Could we "quick hack" it to a geometric mean instead since a mean seemed to yield better results than indexCorrelation^2? > > As nobody knows how each of these proposals performs in real life > > under different conditions, I suggest to leave the current > > implementation in, add all three algorithms, and supply a GUC variable > > to select a cost function. > > I don't think it's really a good idea to expect users to pick among > multiple cost functions that *all* have no guiding theory behind them. > I'd prefer to see us find a better cost function and use it. Has anyone > trawled the database literature on the subject? Hrm, after an hour of searching and reading, I think one of the better papers on the subject can be found here: http://www.cs.ust.hk/faculty/dimitris/PAPERS/TKDE-NNmodels.pdf Page 13, figure 3-12 is the ticket you were looking for Tom. It's an interesting read with a pretty good analysis and conclusion. The author notes that his formula begins to fall apart when the number of dimensions reaches 10 and suggests the use of a high dimension random cost estimate algo, but that the use of those comes at great expense to the CPU (which is inline with a few other papers that I read). The idea of precomputing values piqued my interest and I thought was very clever, albeit space intensive. *shrug* -sc -- Sean Chittenden