mirror of
https://github.com/pgvector/pgvector.git
synced 2026-12-05 00:38:39 +00:00
Added basic support for hypothetical indexes [skip ci]
This commit is contained in:
1 parent
3210babc76
commit
be82eaaf13
2 files changed
+22
-8
No files matched your search
+11
-4
@@ -151,7 +151,6 @@ hnswcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
||||
double ratio;
|
||||
double startupPages;
|
||||
double spc_seq_page_cost;
|
||||
Relation index;
|
||||
|
||||
/* Never use index without order */
|
||||
if (path->indexorderbys == NIL)
|
||||
@@ -170,9 +169,17 @@ hnswcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
||||
|
||||
genericcostestimate(root, path, loop_count, &costs);
|
||||
|
||||
index = index_open(path->indexinfo->indexoid, NoLock);
|
||||
HnswGetMetaPageInfo(index, &m, NULL, NULL);
|
||||
index_close(index, NoLock);
|
||||
/* Get m */
|
||||
if (!path->indexinfo->hypothetical)
|
||||
{
|
||||
Relation index;
|
||||
|
||||
index = index_open(path->indexinfo->indexoid, NoLock);
|
||||
HnswGetMetaPageInfo(index, &m, NULL, NULL);
|
||||
index_close(index, NoLock);
|
||||
}
|
||||
else
|
||||
m = HNSW_DEFAULT_M;
|
||||
|
||||
/*
|
||||
* HNSW cost estimation follows a formula that accounts for the total
|
||||
|
||||
+11
-4
@@ -103,7 +103,6 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
||||
double sequentialRatio = 0.5;
|
||||
double startupPages;
|
||||
double spc_seq_page_cost;
|
||||
Relation index;
|
||||
|
||||
/* Never use index without order */
|
||||
if (path->indexorderbys == NIL)
|
||||
@@ -122,9 +121,17 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
||||
|
||||
genericcostestimate(root, path, loop_count, &costs);
|
||||
|
||||
index = index_open(path->indexinfo->indexoid, NoLock);
|
||||
IvfflatGetMetaPageInfo(index, &lists, NULL);
|
||||
index_close(index, NoLock);
|
||||
/* Get lists */
|
||||
if (!path->indexinfo->hypothetical)
|
||||
{
|
||||
Relation index;
|
||||
|
||||
index = index_open(path->indexinfo->indexoid, NoLock);
|
||||
IvfflatGetMetaPageInfo(index, &lists, NULL);
|
||||
index_close(index, NoLock);
|
||||
}
|
||||
else
|
||||
lists = IVFFLAT_DEFAULT_LISTS;
|
||||
|
||||
/* Get the ratio of lists that we need to visit */
|
||||
ratio = ((double) ivfflat_probes) / lists;
|
||||
|
||||
Reference in new issue
Block a user