From 1fa90d3becb347cdabdad8370f4037a08cb46f1d Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 3 Nov 2026 11:57:03 -0800 Subject: [PATCH] Changed default value of ivfflat.probes to -1 [skip ci] --- src/ivfflat.c | 6 +++--- src/ivfflat.h | 2 +- src/ivfscan.c | 3 +++ src/ivfutils.c | 2 +- test/expected/ivfflat_vector.out | 8 ++++---- test/sql/ivfflat_vector.sql | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/ivfflat.c b/src/ivfflat.c index 1ef1aec3..dd8d4b1c 100644 --- a/src/ivfflat.c +++ b/src/ivfflat.c @@ -52,8 +52,8 @@ IvfflatInit(void) IVFFLAT_DEFAULT_LISTS, IVFFLAT_MIN_LISTS, IVFFLAT_MAX_LISTS, AccessExclusiveLock); DefineCustomIntVariable("ivfflat.probes", "Sets the number of probes", - "Valid range is 0..lists.", &ivfflat_probes, - IVFFLAT_DEFAULT_PROBES, 0, IVFFLAT_MAX_LISTS, PGC_USERSET, 0, NULL, NULL, NULL); + "Valid range is -1..lists.", &ivfflat_probes, + IVFFLAT_DEFAULT_PROBES, -1, IVFFLAT_MAX_LISTS, PGC_USERSET, 0, NULL, NULL, NULL); DefineCustomEnumVariable("ivfflat.iterative_scan", "Sets the mode for iterative scans", NULL, &ivfflat_iterative_scan, @@ -106,7 +106,7 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, double spc_seq_page_cost; /* Never use index without order */ - if (path->indexorderbys == NIL) + if (path->indexorderbys == NIL || ivfflat_probes == 0) { *indexStartupCost = get_float8_infinity(); *indexTotalCost = get_float8_infinity(); diff --git a/src/ivfflat.h b/src/ivfflat.h index 48d194f5..3ec8fc2c 100644 --- a/src/ivfflat.h +++ b/src/ivfflat.h @@ -53,7 +53,7 @@ typedef Pointer Item; #define IVFFLAT_DEFAULT_LISTS 100 #define IVFFLAT_MIN_LISTS 1 #define IVFFLAT_MAX_LISTS 32768 -#define IVFFLAT_DEFAULT_PROBES 0 +#define IVFFLAT_DEFAULT_PROBES -1 /* Build phases */ /* PROGRESS_CREATEIDX_SUBPHASE_INITIALIZE is 1 */ diff --git a/src/ivfscan.c b/src/ivfscan.c index d445f98b..2892be60 100644 --- a/src/ivfscan.c +++ b/src/ivfscan.c @@ -270,6 +270,9 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys) probes = IvfflatGetProbes(lists); + if (probes == 0) + elog(ERROR, "No probes"); + if (ivfflat_iterative_scan != IVFFLAT_ITERATIVE_SCAN_OFF) maxProbes = Max(ivfflat_max_probes, probes); else diff --git a/src/ivfutils.c b/src/ivfutils.c index 9c775c82..156facd3 100644 --- a/src/ivfutils.c +++ b/src/ivfutils.c @@ -74,7 +74,7 @@ IvfflatGetProbes(int lists) { int probes = ivfflat_probes; - if (probes == 0) + if (probes == -1) return round(sqrt(lists)); return probes; diff --git a/test/expected/ivfflat_vector.out b/test/expected/ivfflat_vector.out index 0b0aadf4..75949622 100644 --- a/test/expected/ivfflat_vector.out +++ b/test/expected/ivfflat_vector.out @@ -157,13 +157,13 @@ DROP TABLE t; SHOW ivfflat.probes; ivfflat.probes ---------------- - 0 + -1 (1 row) -SET ivfflat.probes = -1; -ERROR: -1 is outside the valid range for parameter "ivfflat.probes" (0 .. 32768) +SET ivfflat.probes = -2; +ERROR: -2 is outside the valid range for parameter "ivfflat.probes" (-1 .. 32768) SET ivfflat.probes = 32769; -ERROR: 32769 is outside the valid range for parameter "ivfflat.probes" (0 .. 32768) +ERROR: 32769 is outside the valid range for parameter "ivfflat.probes" (-1 .. 32768) SHOW ivfflat.iterative_scan; ivfflat.iterative_scan ------------------------ diff --git a/test/sql/ivfflat_vector.sql b/test/sql/ivfflat_vector.sql index d7d823eb..b6cd2919 100644 --- a/test/sql/ivfflat_vector.sql +++ b/test/sql/ivfflat_vector.sql @@ -87,7 +87,7 @@ CREATE INDEX ON t USING ivfflat (val vector_l2_ops) WITH (lists = 32769); DROP TABLE t; SHOW ivfflat.probes; -SET ivfflat.probes = -1; +SET ivfflat.probes = -2; SET ivfflat.probes = 32769; SHOW ivfflat.iterative_scan;