Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite718eb8

Browse files
committed
Updated range and defaults for iterative search parameters
1 parent049972a commite718eb8

File tree

9 files changed

+17
-36
lines changed

9 files changed

+17
-36
lines changed

‎src/hnsw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ HnswInit(void)
8484

8585
/* This is approximate and does not apply to the initial scan */
8686
DefineCustomIntVariable("hnsw.max_search_tuples","Sets the max number of candidates to visit for iterative search",
87-
"-1 means no limit",&hnsw_max_search_tuples,
88-
-1,-1,INT_MAX,PGC_USERSET,0,NULL,NULL,NULL);
87+
NULL,&hnsw_max_search_tuples,
88+
20000,1,INT_MAX,PGC_USERSET,0,NULL,NULL,NULL);
8989

9090
MarkGUCPrefixReserved("hnsw");
9191
}

‎src/hnswscan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
241241
break;
242242

243243
/* Reached max number of tuples */
244-
if (hnsw_max_search_tuples!=-1&&so->tuples >=hnsw_max_search_tuples)
244+
if (so->tuples >=hnsw_max_search_tuples)
245245
{
246246
if (pairingheap_is_empty(so->discarded))
247247
break;

‎src/ivfflat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ IvfflatInit(void)
4747

4848
/* If this is less than probes, probes is used */
4949
DefineCustomIntVariable("ivfflat.max_probes","Sets the max number of probes for iterative search",
50-
"-1 means no limit",&ivfflat_max_probes,
51-
-1,-1,IVFFLAT_MAX_LISTS,PGC_USERSET,0,NULL,NULL,NULL);
50+
NULL,&ivfflat_max_probes,
51+
IVFFLAT_MAX_LISTS,IVFFLAT_MIN_LISTS,IVFFLAT_MAX_LISTS,PGC_USERSET,0,NULL,NULL,NULL);
5252

5353
MarkGUCPrefixReserved("ivfflat");
5454
}

‎src/ivfscan.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -264,17 +264,7 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys)
264264
IvfflatGetMetaPageInfo(index,&lists,&dimensions);
265265

266266
if (ivfflat_iterative_search!=IVFFLAT_ITERATIVE_SEARCH_OFF)
267-
{
268-
maxProbes=ivfflat_max_probes;
269-
270-
if (maxProbes<0)
271-
maxProbes=lists;
272-
elseif (maxProbes<probes)
273-
{
274-
/* TODO Show notice */
275-
maxProbes=probes;
276-
}
277-
}
267+
maxProbes=Max(ivfflat_max_probes,probes);
278268
else
279269
maxProbes=probes;
280270

‎test/expected/hnsw_vector.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ HINT: Available values: off, relaxed_order, strict_order.
177177
SHOW hnsw.max_search_tuples;
178178
hnsw.max_search_tuples
179179
------------------------
180-
-1
180+
20000
181181
(1 row)
182182

183-
SET hnsw.max_search_tuples =-2;
184-
ERROR:-2 is outside the valid range for parameter "hnsw.max_search_tuples" (-1 .. 2147483647)
183+
SET hnsw.max_search_tuples =0;
184+
ERROR:0 is outside the valid range for parameter "hnsw.max_search_tuples" (1 .. 2147483647)
185185
DROP TABLE t;

‎test/expected/ivfflat_vector.out

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,6 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]';
9595
[0,0,0]
9696
(3 rows)
9797

98-
SET ivfflat.max_probes = 0;
99-
SELECT * FROM t ORDER BY val <-> '[3,3,3]';
100-
val
101-
---------
102-
[1,2,3]
103-
(1 row)
104-
10598
SET ivfflat.max_probes = 1;
10699
SELECT * FROM t ORDER BY val <-> '[3,3,3]';
107100
val
@@ -163,11 +156,11 @@ HINT: Available values: off, relaxed_order.
163156
SHOW ivfflat.max_probes;
164157
ivfflat.max_probes
165158
--------------------
166-
-1
159+
32768
167160
(1 row)
168161

169-
SET ivfflat.max_probes =-2;
170-
ERROR:-2 is outside the valid range for parameter "ivfflat.max_probes" (-1 .. 32768)
162+
SET ivfflat.max_probes =0;
163+
ERROR:0 is outside the valid range for parameter "ivfflat.max_probes" (1 .. 32768)
171164
SET ivfflat.max_probes = 32769;
172-
ERROR: 32769 is outside the valid range for parameter "ivfflat.max_probes" (-1 .. 32768)
165+
ERROR: 32769 is outside the valid range for parameter "ivfflat.max_probes" (1 .. 32768)
173166
DROP TABLE t;

‎test/sql/hnsw_vector.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,6 @@ SET hnsw.iterative_search = on;
104104

105105
SHOWhnsw.max_search_tuples;
106106

107-
SEThnsw.max_search_tuples=-2;
107+
SEThnsw.max_search_tuples=0;
108108

109109
DROPTABLE t;

‎test/sql/ivfflat_vector.sql

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ CREATE INDEX ON t USING ivfflat (val vector_l2_ops) WITH (lists = 3);
5353
SETivfflat.iterative_search= relaxed_order;
5454
SELECT*FROM tORDER BY val<->'[3,3,3]';
5555

56-
SETivfflat.max_probes=0;
57-
SELECT*FROM tORDER BY val<->'[3,3,3]';
58-
5956
SETivfflat.max_probes=1;
6057
SELECT*FROM tORDER BY val<->'[3,3,3]';
6158

@@ -93,7 +90,7 @@ SET ivfflat.iterative_search = on;
9390

9491
SHOWivfflat.max_probes;
9592

96-
SETivfflat.max_probes=-2;
93+
SETivfflat.max_probes=0;
9794
SETivfflat.max_probes=32769;
9895

9996
DROPTABLE t;

‎test/t/043_hnsw_iterative_search.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
my$count =$node->safe_psql("postgres",qq(
2828
SET enable_seqscan = off;
2929
SET hnsw.iterative_search = relaxed_order;
30+
SET hnsw.max_search_tuples = 100000;
3031
SET work_mem = '8MB';
3132
SELECT COUNT(*) FROM (SELECT v FROM tst WHERE i % 10000 = 0 ORDER BY v <-> (SELECT v FROM tst LIMIT 1) LIMIT 11) t;
3233
));
@@ -59,7 +60,7 @@
5960
SET enable_seqscan = off;
6061
SET hnsw.iterative_search = relaxed_order;
6162
SET client_min_messages = debug1;
62-
SET work_mem = '2MB';
63+
SET work_mem = '1MB';
6364
SELECT COUNT(*) FROM (SELECT v FROM tst WHERE i % 10000 = 0 ORDER BY v <-> (SELECT v FROM tst LIMIT 1) LIMIT 11) t;
6465
));
6566
like($stderr,qr/hnsw index scan exceeded work_mem after\d+ tuples/);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp