mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-01 10:11:20 +08:00
Revert "Renamed iterative_search to iterative_scan"
This reverts commit 7043cce893.
This commit is contained in:
20
src/hnsw.c
20
src/hnsw.c
@@ -18,15 +18,15 @@
|
||||
#define MarkGUCPrefixReserved(x) EmitWarningsOnPlaceholders(x)
|
||||
#endif
|
||||
|
||||
static const struct config_enum_entry hnsw_iterative_scan_options[] = {
|
||||
{"off", HNSW_ITERATIVE_SCAN_OFF, false},
|
||||
{"relaxed_order", HNSW_ITERATIVE_SCAN_RELAXED, false},
|
||||
{"strict_order", HNSW_ITERATIVE_SCAN_STRICT, false},
|
||||
static const struct config_enum_entry hnsw_iterative_search_options[] = {
|
||||
{"off", HNSW_ITERATIVE_SEARCH_OFF, false},
|
||||
{"relaxed_order", HNSW_ITERATIVE_SEARCH_RELAXED, false},
|
||||
{"strict_order", HNSW_ITERATIVE_SEARCH_STRICT, false},
|
||||
{NULL, 0, false}
|
||||
};
|
||||
|
||||
int hnsw_ef_search;
|
||||
int hnsw_iterative_scan;
|
||||
int hnsw_iterative_search;
|
||||
int hnsw_max_search_tuples;
|
||||
double hnsw_search_mem_multiplier;
|
||||
int hnsw_lock_tranche_id;
|
||||
@@ -79,17 +79,17 @@ HnswInit(void)
|
||||
"Valid range is 1..1000.", &hnsw_ef_search,
|
||||
HNSW_DEFAULT_EF_SEARCH, HNSW_MIN_EF_SEARCH, HNSW_MAX_EF_SEARCH, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||
|
||||
DefineCustomEnumVariable("hnsw.iterative_scan", "Sets the mode for iterative scans",
|
||||
NULL, &hnsw_iterative_scan,
|
||||
HNSW_ITERATIVE_SCAN_OFF, hnsw_iterative_scan_options, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||
DefineCustomEnumVariable("hnsw.iterative_search", "Sets the iterative search mode",
|
||||
NULL, &hnsw_iterative_search,
|
||||
HNSW_ITERATIVE_SEARCH_OFF, hnsw_iterative_search_options, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||
|
||||
/* This is approximate and does not apply to the initial scan */
|
||||
DefineCustomIntVariable("hnsw.max_search_tuples", "Sets the max number of candidates to visit for iterative scans",
|
||||
DefineCustomIntVariable("hnsw.max_search_tuples", "Sets the max number of candidates to visit for iterative search",
|
||||
NULL, &hnsw_max_search_tuples,
|
||||
20000, 1, INT_MAX, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||
|
||||
/* Same range and default as hash_mem_multiplier */
|
||||
DefineCustomRealVariable("hnsw.search_mem_multiplier", "Sets the multiple of work_mem to use for iterative scans",
|
||||
DefineCustomRealVariable("hnsw.search_mem_multiplier", "Sets the multiple of work_mem to use for iterative search",
|
||||
NULL, &hnsw_search_mem_multiplier,
|
||||
2, 1, 1000, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||
|
||||
|
||||
12
src/hnsw.h
12
src/hnsw.h
@@ -109,17 +109,17 @@
|
||||
|
||||
/* Variables */
|
||||
extern int hnsw_ef_search;
|
||||
extern int hnsw_iterative_scan;
|
||||
extern int hnsw_iterative_search;
|
||||
extern int hnsw_max_search_tuples;
|
||||
extern double hnsw_search_mem_multiplier;
|
||||
extern int hnsw_lock_tranche_id;
|
||||
|
||||
typedef enum HnswIterativeScanMode
|
||||
typedef enum HnswIterativeSearchMode
|
||||
{
|
||||
HNSW_ITERATIVE_SCAN_OFF,
|
||||
HNSW_ITERATIVE_SCAN_RELAXED,
|
||||
HNSW_ITERATIVE_SCAN_STRICT
|
||||
} HnswIterativeScanMode;
|
||||
HNSW_ITERATIVE_SEARCH_OFF,
|
||||
HNSW_ITERATIVE_SEARCH_RELAXED,
|
||||
HNSW_ITERATIVE_SEARCH_STRICT
|
||||
} HnswIterativeSearchMode;
|
||||
|
||||
typedef struct HnswElementData HnswElementData;
|
||||
typedef struct HnswNeighborArray HnswNeighborArray;
|
||||
|
||||
@@ -41,7 +41,7 @@ GetScanItems(IndexScanDesc scan, Datum value)
|
||||
ep = w;
|
||||
}
|
||||
|
||||
return HnswSearchLayer(base, q, ep, hnsw_ef_search, 0, index, support, m, false, NULL, &so->v, hnsw_iterative_scan != HNSW_ITERATIVE_SCAN_OFF ? &so->discarded : NULL, true, &so->tuples);
|
||||
return HnswSearchLayer(base, q, ep, hnsw_ef_search, 0, index, support, m, false, NULL, &so->v, hnsw_iterative_search != HNSW_ITERATIVE_SEARCH_OFF ? &so->discarded : NULL, true, &so->tuples);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -229,7 +229,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||
|
||||
if (list_length(so->w) == 0)
|
||||
{
|
||||
if (hnsw_iterative_scan == HNSW_ITERATIVE_SCAN_OFF)
|
||||
if (hnsw_iterative_search == HNSW_ITERATIVE_SEARCH_OFF)
|
||||
break;
|
||||
|
||||
/* Empty index */
|
||||
@@ -295,7 +295,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||
so->w = list_delete_last(so->w);
|
||||
|
||||
/* Mark memory as free for next iteration */
|
||||
if (hnsw_iterative_scan != HNSW_ITERATIVE_SCAN_OFF)
|
||||
if (hnsw_iterative_search != HNSW_ITERATIVE_SEARCH_OFF)
|
||||
{
|
||||
pfree(element);
|
||||
pfree(sc);
|
||||
@@ -306,7 +306,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||
|
||||
heaptid = &element->heaptids[--element->heaptidsLength];
|
||||
|
||||
if (hnsw_iterative_scan == HNSW_ITERATIVE_SCAN_STRICT)
|
||||
if (hnsw_iterative_search == HNSW_ITERATIVE_SEARCH_STRICT)
|
||||
{
|
||||
if (sc->distance < so->previousDistance)
|
||||
continue;
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
#endif
|
||||
|
||||
int ivfflat_probes;
|
||||
int ivfflat_iterative_scan;
|
||||
int ivfflat_iterative_search;
|
||||
int ivfflat_max_probes;
|
||||
static relopt_kind ivfflat_relopt_kind;
|
||||
|
||||
static const struct config_enum_entry ivfflat_iterative_scan_options[] = {
|
||||
{"off", IVFFLAT_ITERATIVE_SCAN_OFF, false},
|
||||
{"relaxed_order", IVFFLAT_ITERATIVE_SCAN_RELAXED, false},
|
||||
static const struct config_enum_entry ivfflat_iterative_search_options[] = {
|
||||
{"off", IVFFLAT_ITERATIVE_SEARCH_OFF, false},
|
||||
{"relaxed_order", IVFFLAT_ITERATIVE_SEARCH_RELAXED, false},
|
||||
{NULL, 0, false}
|
||||
};
|
||||
|
||||
@@ -41,12 +41,12 @@ IvfflatInit(void)
|
||||
"Valid range is 1..lists.", &ivfflat_probes,
|
||||
IVFFLAT_DEFAULT_PROBES, IVFFLAT_MIN_LISTS, IVFFLAT_MAX_LISTS, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||
|
||||
DefineCustomEnumVariable("ivfflat.iterative_scan", "Sets the mode for iterative scans",
|
||||
NULL, &ivfflat_iterative_scan,
|
||||
IVFFLAT_ITERATIVE_SCAN_OFF, ivfflat_iterative_scan_options, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||
DefineCustomEnumVariable("ivfflat.iterative_search", "Sets the iterative search mode",
|
||||
NULL, &ivfflat_iterative_search,
|
||||
IVFFLAT_ITERATIVE_SEARCH_OFF, ivfflat_iterative_search_options, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||
|
||||
/* If this is less than probes, probes is used */
|
||||
DefineCustomIntVariable("ivfflat.max_probes", "Sets the max number of probes for iterative scans",
|
||||
DefineCustomIntVariable("ivfflat.max_probes", "Sets the max number of probes for iterative search",
|
||||
NULL, &ivfflat_max_probes,
|
||||
IVFFLAT_MAX_LISTS, IVFFLAT_MIN_LISTS, IVFFLAT_MAX_LISTS, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||
|
||||
|
||||
@@ -80,14 +80,14 @@
|
||||
|
||||
/* Variables */
|
||||
extern int ivfflat_probes;
|
||||
extern int ivfflat_iterative_scan;
|
||||
extern int ivfflat_iterative_search;
|
||||
extern int ivfflat_max_probes;
|
||||
|
||||
typedef enum IvfflatIterativeScanMode
|
||||
typedef enum IvfflatIterativeSearchMode
|
||||
{
|
||||
IVFFLAT_ITERATIVE_SCAN_OFF,
|
||||
IVFFLAT_ITERATIVE_SCAN_RELAXED
|
||||
} IvfflatIterativeScanMode;
|
||||
IVFFLAT_ITERATIVE_SEARCH_OFF,
|
||||
IVFFLAT_ITERATIVE_SEARCH_RELAXED
|
||||
} IvfflatIterativeSearchMode;
|
||||
|
||||
typedef struct VectorArrayData
|
||||
{
|
||||
|
||||
@@ -171,7 +171,7 @@ GetScanItems(IndexScanDesc scan, Datum value)
|
||||
}
|
||||
}
|
||||
|
||||
if (tuples < 100 && ivfflat_iterative_scan == IVFFLAT_ITERATIVE_SCAN_OFF)
|
||||
if (tuples < 100 && ivfflat_iterative_search == IVFFLAT_ITERATIVE_SEARCH_OFF)
|
||||
ereport(DEBUG1,
|
||||
(errmsg("index scan found few tuples"),
|
||||
errdetail("Index may have been created with little data."),
|
||||
@@ -263,7 +263,7 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys)
|
||||
/* Get lists and dimensions from metapage */
|
||||
IvfflatGetMetaPageInfo(index, &lists, &dimensions);
|
||||
|
||||
if (ivfflat_iterative_scan != IVFFLAT_ITERATIVE_SCAN_OFF)
|
||||
if (ivfflat_iterative_search != IVFFLAT_ITERATIVE_SEARCH_OFF)
|
||||
maxProbes = Max(ivfflat_max_probes, probes);
|
||||
else
|
||||
maxProbes = probes;
|
||||
|
||||
Reference in New Issue
Block a user