Skip to content
Snippets Groups Projects
Commit b324384f authored by Tom Lane's avatar Tom Lane
Browse files

Fix brain fade in cost estimation for index-only scans.

visibility_fraction should not be applied to regular indexscans.
Noted by Cédric Villemain.
parent 1ef60dab
No related branches found
No related tags found
No related merge requests found
......@@ -264,6 +264,7 @@ cost_index(IndexPath *path, PlannerInfo *root,
if (!enable_indexscan)
startup_cost += disable_cost;
/* we don't need to check enable_indexonlyscan; indxpath.c does that */
/*
* Call index-access-method-specific code to estimate the processing cost
......@@ -345,6 +346,7 @@ cost_index(IndexPath *path, PlannerInfo *root,
(double) index->pages,
root);
if (indexonly)
pages_fetched = ceil(pages_fetched * visibility_fraction);
max_IO_cost = (pages_fetched * spc_random_page_cost) / num_scans;
......@@ -366,6 +368,7 @@ cost_index(IndexPath *path, PlannerInfo *root,
(double) index->pages,
root);
if (indexonly)
pages_fetched = ceil(pages_fetched * visibility_fraction);
min_IO_cost = (pages_fetched * spc_random_page_cost) / num_scans;
......@@ -381,6 +384,7 @@ cost_index(IndexPath *path, PlannerInfo *root,
(double) index->pages,
root);
if (indexonly)
pages_fetched = ceil(pages_fetched * visibility_fraction);
/* max_IO_cost is for the perfectly uncorrelated case (csquared=0) */
......@@ -389,6 +393,7 @@ cost_index(IndexPath *path, PlannerInfo *root,
/* min_IO_cost is for the perfectly correlated case (csquared=1) */
pages_fetched = ceil(indexSelectivity * (double) baserel->pages);
if (indexonly)
pages_fetched = ceil(pages_fetched * visibility_fraction);
min_IO_cost = spc_random_page_cost;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment