Use -1 for no limit for ivfflat.max_probes [skip ci]

This commit is contained in:
Andrew Kane
2024-10-11 11:43:32 -07:00
parent 42af8aa1d1
commit d1ebb8db73
5 changed files with 54 additions and 14 deletions

View File

@@ -82,7 +82,6 @@ HnswInit(void)
NULL, &hnsw_iterative_search,
HNSW_ITERATIVE_SEARCH_OFF, hnsw_iterative_search_options, PGC_USERSET, 0, NULL, NULL, NULL);
/* TODO Ensure ivfflat.max_probes uses same value for no limit */
DefineCustomIntVariable("hnsw.max_search_tuples", "Sets the max number of candidates to visit for iterative search",
"-1 means no limit", &hnsw_max_search_tuples,
-1, -1, INT_MAX, PGC_USERSET, 0, NULL, NULL, NULL);

View File

@@ -46,8 +46,8 @@ IvfflatInit(void)
IVFFLAT_ITERATIVE_SEARCH_OFF, ivfflat_iterative_search_options, PGC_USERSET, 0, NULL, NULL, NULL);
DefineCustomIntVariable("ivfflat.max_probes", "Sets the max number of probes for iterative search",
"Zero sets to the number of lists", &ivfflat_max_probes,
0, 0, IVFFLAT_MAX_LISTS, PGC_USERSET, 0, NULL, NULL, NULL);
"-1 means no limit", &ivfflat_max_probes,
-1, -1, IVFFLAT_MAX_LISTS, PGC_USERSET, 0, NULL, NULL, NULL);
MarkGUCPrefixReserved("ivfflat");
}

View File

@@ -259,19 +259,27 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys)
/* Get lists and dimensions from metapage */
IvfflatGetMetaPageInfo(index, &lists, &dimensions);
if (probes > lists)
probes = lists;
if (ivfflat_iterative_search != IVFFLAT_ITERATIVE_SEARCH_OFF)
{
if (ivfflat_max_probes == 0)
maxProbes = ivfflat_max_probes;
if (maxProbes < 0)
maxProbes = lists;
else
maxProbes = Min(ivfflat_max_probes, lists);
else if (maxProbes < probes)
{
/* TODO Show notice */
maxProbes = probes;
}
}
else
maxProbes = probes;
if (probes > lists)
probes = lists;
if (maxProbes > lists)
maxProbes = lists;
so = (IvfflatScanOpaque) palloc(offsetof(IvfflatScanOpaqueData, lists) + maxProbes * sizeof(IvfflatScanList));
so->typeInfo = IvfflatGetTypeInfo(index);
so->first = true;