@@ -264,6 +264,7 @@ cost_index(IndexPath *path, PlannerInfo *root,
264
264
265
265
if (!enable_indexscan )
266
266
startup_cost += disable_cost ;
267
+ /* we don't need to check enable_indexonlyscan; indxpath.c does that */
267
268
268
269
/*
269
270
* Call index-access-method-specific code to estimate the processing cost
@@ -345,7 +346,8 @@ cost_index(IndexPath *path, PlannerInfo *root,
345
346
(double ) index -> pages ,
346
347
root );
347
348
348
- pages_fetched = ceil (pages_fetched * visibility_fraction );
349
+ if (indexonly )
350
+ pages_fetched = ceil (pages_fetched * visibility_fraction );
349
351
350
352
max_IO_cost = (pages_fetched * spc_random_page_cost ) / num_scans ;
351
353
@@ -366,7 +368,8 @@ cost_index(IndexPath *path, PlannerInfo *root,
366
368
(double ) index -> pages ,
367
369
root );
368
370
369
- pages_fetched = ceil (pages_fetched * visibility_fraction );
371
+ if (indexonly )
372
+ pages_fetched = ceil (pages_fetched * visibility_fraction );
370
373
371
374
min_IO_cost = (pages_fetched * spc_random_page_cost ) / num_scans ;
372
375
}
@@ -381,15 +384,17 @@ cost_index(IndexPath *path, PlannerInfo *root,
381
384
(double ) index -> pages ,
382
385
root );
383
386
384
- pages_fetched = ceil (pages_fetched * visibility_fraction );
387
+ if (indexonly )
388
+ pages_fetched = ceil (pages_fetched * visibility_fraction );
385
389
386
390
/* max_IO_cost is for the perfectly uncorrelated case (csquared=0) */
387
391
max_IO_cost = pages_fetched * spc_random_page_cost ;
388
392
389
393
/* min_IO_cost is for the perfectly correlated case (csquared=1) */
390
394
pages_fetched = ceil (indexSelectivity * (double ) baserel -> pages );
391
395
392
- pages_fetched = ceil (pages_fetched * visibility_fraction );
396
+ if (indexonly )
397
+ pages_fetched = ceil (pages_fetched * visibility_fraction );
393
398
394
399
min_IO_cost = spc_random_page_cost ;
395
400
if (pages_fetched > 1 )
0 commit comments