Added max_probes option [skip ci]

This commit is contained in:
Andrew Kane
2024-09-21 20:19:26 -07:00
parent ff6267917e
commit cd3f9a38ae
3 changed files with 15 additions and 1 deletions

View File

@@ -17,6 +17,7 @@
#endif
int ivfflat_probes;
int ivfflat_max_probes;
bool ivfflat_streaming;
static relopt_kind ivfflat_relopt_kind;
@@ -34,6 +35,10 @@ IvfflatInit(void)
"Valid range is 1..lists.", &ivfflat_probes,
IVFFLAT_DEFAULT_PROBES, IVFFLAT_MIN_LISTS, IVFFLAT_MAX_LISTS, PGC_USERSET, 0, NULL, NULL, NULL);
DefineCustomIntVariable("ivfflat.max_probes", "Sets the max number of probes for iterative scans",
NULL, &ivfflat_max_probes,
-1, IVFFLAT_MIN_LISTS, IVFFLAT_MAX_LISTS, PGC_USERSET, 0, NULL, NULL, NULL);
DefineCustomBoolVariable("ivfflat.streaming", "Use streaming mode",
NULL, &ivfflat_streaming,
IVFFLAT_DEFAULT_STREAMING, PGC_USERSET, 0, NULL, NULL, NULL);

View File

@@ -81,6 +81,7 @@
/* Variables */
extern int ivfflat_probes;
extern int ivfflat_max_probes;
extern bool ivfflat_streaming;
typedef struct VectorArrayData

View File

@@ -262,7 +262,15 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys)
if (probes > lists)
probes = lists;
maxProbes = ivfflat_streaming ? lists : probes;
if (ivfflat_streaming)
{
if (ivfflat_max_probes == -1)
maxProbes = lists;
else
maxProbes = ivfflat_max_probes;
}
else
maxProbes = probes;
so = (IvfflatScanOpaque) palloc(offsetof(IvfflatScanOpaqueData, lists) + maxProbes * sizeof(IvfflatScanList));
so->typeInfo = IvfflatGetTypeInfo(index);