On Tue, Jan 7, 2020 at 1:29 AM Justin Pryzby <pry...@telsasoft.com> wrote: > > Find attached cleaned up patch. > For now, I updated the regress/expected/, but I think the test maybe has to be > updated to do what it was written to do.
I have noticed that in "cost_index" we have used the indexCorrelation for computing the run_cost, not the number of pages whereas in your patch you have used it for computing the number of pages. Any reason for the same? cost_index { .. /* * Now interpolate based on estimated index order correlation to get total * disk I/O cost for main table accesses. */ csquared = indexCorrelation * indexCorrelation; run_cost += max_IO_cost + csquared * (min_IO_cost - max_IO_cost); } Patch - pages_fetched = (2.0 * T * tuples_fetched) / (2.0 * T + tuples_fetched); + pages_fetchedMAX = (2.0 * T * tuples_fetched) / (2.0 * T + tuples_fetched); + + /* pages_fetchedMIN is for the perfectly correlated case (csquared=1) */ + pages_fetchedMIN = ceil(indexSelectivity * (double) baserel->pages); + + pages_fetched = pages_fetchedMAX + indexCorrelation*indexCorrelation*(pages_fetchedMIN - pages_fetchedMAX); -- Regards, Dilip Kumar EnterpriseDB: http://www.enterprisedb.com