aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-10-08 10:41:17 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-10-08 10:41:17 -0400
commitb324384f6bd5d661efeddb83d7f607781e96947d (patch)
tree03db550fb66922bff4d83d1cdb08e792a7793ab0 /src
parent1ef60dab7049ffac52dee60b5788b6c7bc1f9d67 (diff)
downloadpostgresql-b324384f6bd5d661efeddb83d7f607781e96947d.tar.gz
postgresql-b324384f6bd5d661efeddb83d7f607781e96947d.zip
Fix brain fade in cost estimation for index-only scans.
visibility_fraction should not be applied to regular indexscans. Noted by Cédric Villemain.
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/path/costsize.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
index e480797ca8e..45c5524d309 100644
--- a/src/backend/optimizer/path/costsize.c
+++ b/src/backend/optimizer/path/costsize.c
@@ -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,7 +346,8 @@ cost_index(IndexPath *path, PlannerInfo *root,
(double) index->pages,
root);
- pages_fetched = ceil(pages_fetched * visibility_fraction);
+ if (indexonly)
+ pages_fetched = ceil(pages_fetched * visibility_fraction);
max_IO_cost = (pages_fetched * spc_random_page_cost) / num_scans;
@@ -366,7 +368,8 @@ cost_index(IndexPath *path, PlannerInfo *root,
(double) index->pages,
root);
- pages_fetched = ceil(pages_fetched * visibility_fraction);
+ if (indexonly)
+ pages_fetched = ceil(pages_fetched * visibility_fraction);
min_IO_cost = (pages_fetched * spc_random_page_cost) / num_scans;
}
@@ -381,7 +384,8 @@ cost_index(IndexPath *path, PlannerInfo *root,
(double) index->pages,
root);
- pages_fetched = ceil(pages_fetched * visibility_fraction);
+ if (indexonly)
+ pages_fetched = ceil(pages_fetched * visibility_fraction);
/* max_IO_cost is for the perfectly uncorrelated case (csquared=0) */
max_IO_cost = pages_fetched * spc_random_page_cost;
@@ -389,7 +393,8 @@ cost_index(IndexPath *path, PlannerInfo *root,
/* min_IO_cost is for the perfectly correlated case (csquared=1) */
pages_fetched = ceil(indexSelectivity * (double) baserel->pages);
- pages_fetched = ceil(pages_fetched * visibility_fraction);
+ if (indexonly)
+ pages_fetched = ceil(pages_fetched * visibility_fraction);
min_IO_cost = spc_random_page_cost;
if (pages_fetched > 1)