mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-14 16:46:54 +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)
|
## 0.1.1 (2021-04-25)
|
||||||
|
|
||||||
- Added binary representation for `COPY`
|
- Added binary representation for `COPY`
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
GenericCosts costs;
|
GenericCosts costs;
|
||||||
|
int lists;
|
||||||
|
double ratio;
|
||||||
|
Relation indexRel;
|
||||||
|
|
||||||
#if PG_VERSION_NUM < 120000
|
#if PG_VERSION_NUM < 120000
|
||||||
List *qinfos;
|
List *qinfos;
|
||||||
@@ -57,7 +60,18 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
|||||||
genericcostestimate(root, path, loop_count, qinfos, &costs);
|
genericcostestimate(root, path, loop_count, qinfos, &costs);
|
||||||
#endif
|
#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;
|
*indexTotalCost = costs.indexTotalCost;
|
||||||
*indexSelectivity = costs.indexSelectivity;
|
*indexSelectivity = costs.indexSelectivity;
|
||||||
*indexCorrelation = costs.indexCorrelation;
|
*indexCorrelation = costs.indexCorrelation;
|
||||||
|
|||||||
Reference in New Issue
Block a user