pgvector.git / summary / log / commit / refs

commit    be82eaaf13b053ed2a830b310573a34151a07a72
Author:   Andrew Kane <andrew@ankane.org>
Date:     Sun Oct 25 19:38:32 2026 +0000

    Added basic support for hypothetical indexes [skip ci]


src/hnsw.c | 15 +++++++++++---- src/ivfflat.c | 15 +++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/hnsw.c b/src/hnsw.c index 6f1fa7cb..f4e590a0 100644 --- a/src/hnsw.c +++ b/src/hnsw.c @@ -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 diff --git a/src/ivfflat.c b/src/ivfflat.c index a7a6b32d..b43637b8 100644 --- a/src/ivfflat.c +++ b/src/ivfflat.c @@ -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; [parent: 3210babc7667]