mirror of
https://github.com/pgvector/pgvector.git
synced 2026-06-06 05:51:21 +08:00
Improved cost estimation
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
## 0.1.2 (unreleased)
|
||||
|
||||
- Improved cost estimation
|
||||
|
||||
## 0.1.1 (2021-04-25)
|
||||
|
||||
- Added binary representation for `COPY`
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user