diff --git a/src/hnsw.c b/src/hnsw.c index ca60455..acfd14f 100644 --- a/src/hnsw.c +++ b/src/hnsw.c @@ -26,7 +26,7 @@ static const struct config_enum_entry hnsw_iterative_search_options[] = { }; int hnsw_ef_search; -int hnsw_iterative_search_max_tuples; +int hnsw_max_search_tuples; int hnsw_iterative_search; int hnsw_lock_tranche_id; static relopt_kind hnsw_relopt_kind; @@ -78,13 +78,13 @@ 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_search", "Sets iterative search", + DefineCustomEnumVariable("hnsw.iterative_search", "Sets iterative search mode", 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 "all" */ - DefineCustomIntVariable("hnsw.iterative_search_max_tuples", "Sets the max number of candidates to visit for iterative search", - "-1 means all", &hnsw_iterative_search_max_tuples, + /* 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); MarkGUCPrefixReserved("hnsw"); diff --git a/src/hnsw.h b/src/hnsw.h index 254a60a..5f170dd 100644 --- a/src/hnsw.h +++ b/src/hnsw.h @@ -110,7 +110,7 @@ /* Variables */ extern int hnsw_ef_search; extern int hnsw_iterative_search; -extern int hnsw_iterative_search_max_tuples; +extern int hnsw_max_search_tuples; extern int hnsw_lock_tranche_id; typedef enum HnswIterativeSearchType diff --git a/src/hnswscan.c b/src/hnswscan.c index 6e9a9ab..84e2332 100644 --- a/src/hnswscan.c +++ b/src/hnswscan.c @@ -230,7 +230,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir) break; /* Reached max number of tuples */ - if (hnsw_iterative_search_max_tuples != -1 && so->tuples >= hnsw_iterative_search_max_tuples) + if (hnsw_max_search_tuples != -1 && so->tuples >= hnsw_max_search_tuples) { if (pairingheap_is_empty(so->discarded)) break; diff --git a/src/ivfflat.c b/src/ivfflat.c index 1854fba..2ad27b4 100644 --- a/src/ivfflat.c +++ b/src/ivfflat.c @@ -18,7 +18,7 @@ int ivfflat_probes; int ivfflat_iterative_search; -int ivfflat_iterative_search_max_probes; +int ivfflat_max_probes; static relopt_kind ivfflat_relopt_kind; static const struct config_enum_entry ivfflat_iterative_search_options[] = { @@ -45,8 +45,8 @@ IvfflatInit(void) NULL, &ivfflat_iterative_search, IVFFLAT_ITERATIVE_SEARCH_OFF, ivfflat_iterative_search_options, PGC_USERSET, 0, NULL, NULL, NULL); - DefineCustomIntVariable("ivfflat.iterative_search_max_probes", "Sets the max number of probes for iterative search", - "Zero sets to the number of lists", &ivfflat_iterative_search_max_probes, + 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); MarkGUCPrefixReserved("ivfflat"); diff --git a/src/ivfflat.h b/src/ivfflat.h index c2b4121..1ca37ad 100644 --- a/src/ivfflat.h +++ b/src/ivfflat.h @@ -81,7 +81,7 @@ /* Variables */ extern int ivfflat_probes; extern int ivfflat_iterative_search; -extern int ivfflat_iterative_search_max_probes; +extern int ivfflat_max_probes; typedef enum IvfflatIterativeSearchType { diff --git a/src/ivfscan.c b/src/ivfscan.c index 578f6aa..548af81 100644 --- a/src/ivfscan.c +++ b/src/ivfscan.c @@ -264,10 +264,10 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys) if (ivfflat_iterative_search != IVFFLAT_ITERATIVE_SEARCH_OFF) { - if (ivfflat_iterative_search_max_probes == 0) + if (ivfflat_max_probes == 0) maxProbes = lists; else - maxProbes = Min(ivfflat_iterative_search_max_probes, lists); + maxProbes = Min(ivfflat_max_probes, lists); } else maxProbes = probes; diff --git a/test/expected/hnsw_vector.out b/test/expected/hnsw_vector.out index 6a1f984..60eb011 100644 --- a/test/expected/hnsw_vector.out +++ b/test/expected/hnsw_vector.out @@ -174,12 +174,12 @@ SHOW hnsw.iterative_search; SET hnsw.iterative_search = on; ERROR: invalid value for parameter "hnsw.iterative_search": "on" HINT: Available values: off, relaxed_order, strict_order. -SHOW hnsw.iterative_search_max_tuples; - hnsw.iterative_search_max_tuples ----------------------------------- +SHOW hnsw.max_search_tuples; + hnsw.max_search_tuples +------------------------ -1 (1 row) -SET hnsw.iterative_search_max_tuples = -2; -ERROR: -2 is outside the valid range for parameter "hnsw.iterative_search_max_tuples" (-1 .. 2147483647) +SET hnsw.max_search_tuples = -2; +ERROR: -2 is outside the valid range for parameter "hnsw.max_search_tuples" (-1 .. 2147483647) DROP TABLE t; diff --git a/test/expected/ivfflat_vector.out b/test/expected/ivfflat_vector.out index c22135a..9bb7b13 100644 --- a/test/expected/ivfflat_vector.out +++ b/test/expected/ivfflat_vector.out @@ -137,14 +137,14 @@ SHOW ivfflat.iterative_search; SET ivfflat.iterative_search = on; ERROR: invalid value for parameter "ivfflat.iterative_search": "on" HINT: Available values: off, relaxed_order. -SHOW ivfflat.iterative_search_max_probes; - ivfflat.iterative_search_max_probes -------------------------------------- +SHOW ivfflat.max_probes; + ivfflat.max_probes +-------------------- 0 (1 row) -SET ivfflat.iterative_search_max_probes = -1; -ERROR: -1 is outside the valid range for parameter "ivfflat.iterative_search_max_probes" (0 .. 32768) -SET ivfflat.iterative_search_max_probes = 32769; -ERROR: 32769 is outside the valid range for parameter "ivfflat.iterative_search_max_probes" (0 .. 32768) +SET ivfflat.max_probes = -1; +ERROR: -1 is outside the valid range for parameter "ivfflat.max_probes" (0 .. 32768) +SET ivfflat.max_probes = 32769; +ERROR: 32769 is outside the valid range for parameter "ivfflat.max_probes" (0 .. 32768) DROP TABLE t; diff --git a/test/sql/hnsw_vector.sql b/test/sql/hnsw_vector.sql index 8f69a4c..ba8d4aa 100644 --- a/test/sql/hnsw_vector.sql +++ b/test/sql/hnsw_vector.sql @@ -102,8 +102,8 @@ SHOW hnsw.iterative_search; SET hnsw.iterative_search = on; -SHOW hnsw.iterative_search_max_tuples; +SHOW hnsw.max_search_tuples; -SET hnsw.iterative_search_max_tuples = -2; +SET hnsw.max_search_tuples = -2; DROP TABLE t; diff --git a/test/sql/ivfflat_vector.sql b/test/sql/ivfflat_vector.sql index 93f4224..7e83915 100644 --- a/test/sql/ivfflat_vector.sql +++ b/test/sql/ivfflat_vector.sql @@ -81,9 +81,9 @@ SHOW ivfflat.iterative_search; SET ivfflat.iterative_search = on; -SHOW ivfflat.iterative_search_max_probes; +SHOW ivfflat.max_probes; -SET ivfflat.iterative_search_max_probes = -1; -SET ivfflat.iterative_search_max_probes = 32769; +SET ivfflat.max_probes = -1; +SET ivfflat.max_probes = 32769; DROP TABLE t; diff --git a/test/t/041_ivfflat_iterative_search.pl b/test/t/041_ivfflat_iterative_search.pl index 2b1add3..6e0f721 100644 --- a/test/t/041_ivfflat_iterative_search.pl +++ b/test/t/041_ivfflat_iterative_search.pl @@ -40,7 +40,7 @@ foreach ((30, 50, 70)) SET enable_seqscan = off; SET ivfflat.probes = 10; SET ivfflat.iterative_search = relaxed_order; - SET ivfflat.iterative_search_max_probes = $max_probes; + SET ivfflat.max_probes = $max_probes; SELECT COUNT(*) FROM (SELECT v FROM tst WHERE i % 10000 = 0 ORDER BY v <-> (SELECT v FROM tst WHERE i = $i) LIMIT 11) t; )); $sum += $count; diff --git a/test/t/043_hnsw_iterative_search.pl b/test/t/043_hnsw_iterative_search.pl index 6ccef21..8e1aa1e 100644 --- a/test/t/043_hnsw_iterative_search.pl +++ b/test/t/043_hnsw_iterative_search.pl @@ -43,7 +43,7 @@ foreach ((30000, 50000, 70000)) $count = $node->safe_psql("postgres", qq( SET enable_seqscan = off; SET hnsw.iterative_search = relaxed_order; - SET hnsw.iterative_search_max_tuples = $max_tuples; + SET hnsw.max_search_tuples = $max_tuples; SET work_mem = '8MB'; SELECT COUNT(*) FROM (SELECT v FROM tst WHERE i % 10000 = 0 ORDER BY v <-> (SELECT v FROM tst WHERE i = $i) LIMIT 11) t; ));