Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb324384

Browse files
committed
Fix brain fade in cost estimation for index-only scans.
visibility_fraction should not be applied to regular indexscans.Noted by Cédric Villemain.
1 parent1ef60da commitb324384

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

‎src/backend/optimizer/path/costsize.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ cost_index(IndexPath *path, PlannerInfo *root,
264264

265265
if (!enable_indexscan)
266266
startup_cost+=disable_cost;
267+
/* we don't need to check enable_indexonlyscan; indxpath.c does that */
267268

268269
/*
269270
* Call index-access-method-specific code to estimate the processing cost
@@ -345,7 +346,8 @@ cost_index(IndexPath *path, PlannerInfo *root,
345346
(double)index->pages,
346347
root);
347348

348-
pages_fetched=ceil(pages_fetched*visibility_fraction);
349+
if (indexonly)
350+
pages_fetched=ceil(pages_fetched*visibility_fraction);
349351

350352
max_IO_cost= (pages_fetched*spc_random_page_cost) /num_scans;
351353

@@ -366,7 +368,8 @@ cost_index(IndexPath *path, PlannerInfo *root,
366368
(double)index->pages,
367369
root);
368370

369-
pages_fetched=ceil(pages_fetched*visibility_fraction);
371+
if (indexonly)
372+
pages_fetched=ceil(pages_fetched*visibility_fraction);
370373

371374
min_IO_cost= (pages_fetched*spc_random_page_cost) /num_scans;
372375
}
@@ -381,15 +384,17 @@ cost_index(IndexPath *path, PlannerInfo *root,
381384
(double)index->pages,
382385
root);
383386

384-
pages_fetched=ceil(pages_fetched*visibility_fraction);
387+
if (indexonly)
388+
pages_fetched=ceil(pages_fetched*visibility_fraction);
385389

386390
/* max_IO_cost is for the perfectly uncorrelated case (csquared=0) */
387391
max_IO_cost=pages_fetched*spc_random_page_cost;
388392

389393
/* min_IO_cost is for the perfectly correlated case (csquared=1) */
390394
pages_fetched=ceil(indexSelectivity* (double)baserel->pages);
391395

392-
pages_fetched=ceil(pages_fetched*visibility_fraction);
396+
if (indexonly)
397+
pages_fetched=ceil(pages_fetched*visibility_fraction);
393398

394399
min_IO_cost=spc_random_page_cost;
395400
if (pages_fetched>1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp