Improved cost estimation

This commit is contained in:
Andrew Kane
2021-04-26 01:04:01 -07:00
parent 6d9653d763
commit 8863920fdc
2 changed files with 19 additions and 1 deletions

View File

@@ -1,3 +1,7 @@
## 0.1.2 (unreleased)
- Improved cost estimation
## 0.1.1 (2021-04-25)
- Added binary representation for `COPY`

View File

@@ -42,6 +42,9 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
)
{
GenericCosts costs;
int lists;
double ratio;
Relation indexRel;
#if PG_VERSION_NUM < 120000
List *qinfos;
@@ -57,7 +60,18 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
genericcostestimate(root, path, loop_count, qinfos, &costs);
#endif
*indexStartupCost = costs.indexStartupCost;
indexRel = index_open(path->indexinfo->indexoid, NoLock);
lists = IvfflatGetLists(indexRel);
index_close(indexRel, NoLock);
ratio = ((double) ivfflat_probes) / lists;
if (ratio > 1)
ratio = 1;
costs.indexTotalCost *= ratio;
/* Startup cost and total cost are same */
*indexStartupCost = costs.indexTotalCost;
*indexTotalCost = costs.indexTotalCost;
*indexSelectivity = costs.indexSelectivity;
*indexCorrelation = costs.indexCorrelation;