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

Commit78b877b

Browse files
committed
Revert "Renamed iterative_search to iterative_scan"
This reverts commit7043cce.
1 parent7043cce commit78b877b

16 files changed

+76
-76
lines changed

‎CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
##0.8.0 (unreleased)
22

3-
- Added support for iterativeindex scans
3+
- Added support for iterativesearch
44
- Added casts for arrays to`sparsevec`
55
- Improved cost estimation
66
- Improved performance of HNSW inserts and on-disk index builds

‎README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,31 +451,31 @@ Use [partitioning](https://www.postgresql.org/docs/current/ddl-partitioning.html
451451
CREATETABLEitems (embedding vector(3), category_idint) PARTITION BY LIST(category_id);
452452
```
453453

454-
##IterativeIndex Scans
454+
##IterativeSearch
455455

456456
*Unreleased*
457457

458458
With approximate indexes, queries with filtering can return less results (due to post-filtering).
459459

460-
Starting with 0.8.0, you can enable iterativeindex scans. If too few results from the initial index scan match the filters, the scan will resume until enough results are found (or it reaches`hnsw.max_search_tuples` or`ivfflat.max_probes`). This can significantly improve recall.
460+
Starting with 0.8.0, you can enable iterativesearch. If too few results from the initial index scan match the filters, the scan will resume until enough results are found (or it reaches`hnsw.max_search_tuples` or`ivfflat.max_probes`). This can significantly improve recall.
461461

462-
There are two modes for iterativescans: strict and relaxed (due to the streaming nature of Postgres executor).
462+
There are two modes for iterativesearch: strict and relaxed (due to the streaming nature of Postgres executor).
463463

464464
Strict ensures results are in the exact order by distance
465465

466466
```sql
467-
SEThnsw.iterative_scan= strict_order;
467+
SEThnsw.iterative_search= strict_order;
468468
```
469469

470470
Relaxed allows results to be slightly out of order by distance, but provides better recall
471471

472472
```sql
473-
SEThnsw.iterative_scan= relaxed_order;
473+
SEThnsw.iterative_search= relaxed_order;
474474
# or
475-
SETivfflat.iterative_scan= relaxed_order;
475+
SETivfflat.iterative_search= relaxed_order;
476476
```
477477

478-
Note: IVFFlat only supports relaxedordering for iterativescans
478+
Note: IVFFlat only supports relaxedorder for iterativesearch
479479

480480
With relaxed ordering, you can use a[materialized CTE](https://www.postgresql.org/docs/current/queries-with.html#QUERIES-WITH-CTE-MATERIALIZATION) to get strict ordering
481481

‎src/hnsw.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
#defineMarkGUCPrefixReserved(x) EmitWarningsOnPlaceholders(x)
1919
#endif
2020

21-
staticconststructconfig_enum_entryhnsw_iterative_scan_options[]= {
22-
{"off",HNSW_ITERATIVE_SCAN_OFF, false},
23-
{"relaxed_order",HNSW_ITERATIVE_SCAN_RELAXED, false},
24-
{"strict_order",HNSW_ITERATIVE_SCAN_STRICT, false},
21+
staticconststructconfig_enum_entryhnsw_iterative_search_options[]= {
22+
{"off",HNSW_ITERATIVE_SEARCH_OFF, false},
23+
{"relaxed_order",HNSW_ITERATIVE_SEARCH_RELAXED, false},
24+
{"strict_order",HNSW_ITERATIVE_SEARCH_STRICT, false},
2525
{NULL,0, false}
2626
};
2727

2828
inthnsw_ef_search;
29-
inthnsw_iterative_scan;
29+
inthnsw_iterative_search;
3030
inthnsw_max_search_tuples;
3131
doublehnsw_search_mem_multiplier;
3232
inthnsw_lock_tranche_id;
@@ -79,17 +79,17 @@ HnswInit(void)
7979
"Valid range is 1..1000.",&hnsw_ef_search,
8080
HNSW_DEFAULT_EF_SEARCH,HNSW_MIN_EF_SEARCH,HNSW_MAX_EF_SEARCH,PGC_USERSET,0,NULL,NULL,NULL);
8181

82-
DefineCustomEnumVariable("hnsw.iterative_scan","Sets themode foriterativescans",
83-
NULL,&hnsw_iterative_scan,
84-
HNSW_ITERATIVE_SCAN_OFF,hnsw_iterative_scan_options,PGC_USERSET,0,NULL,NULL,NULL);
82+
DefineCustomEnumVariable("hnsw.iterative_search","Sets the iterativesearch mode",
83+
NULL,&hnsw_iterative_search,
84+
HNSW_ITERATIVE_SEARCH_OFF,hnsw_iterative_search_options,PGC_USERSET,0,NULL,NULL,NULL);
8585

8686
/* This is approximate and does not apply to the initial scan */
87-
DefineCustomIntVariable("hnsw.max_search_tuples","Sets the max number of candidates to visit for iterativescans",
87+
DefineCustomIntVariable("hnsw.max_search_tuples","Sets the max number of candidates to visit for iterativesearch",
8888
NULL,&hnsw_max_search_tuples,
8989
20000,1,INT_MAX,PGC_USERSET,0,NULL,NULL,NULL);
9090

9191
/* Same range and default as hash_mem_multiplier */
92-
DefineCustomRealVariable("hnsw.search_mem_multiplier","Sets the multiple of work_mem to use for iterativescans",
92+
DefineCustomRealVariable("hnsw.search_mem_multiplier","Sets the multiple of work_mem to use for iterativesearch",
9393
NULL,&hnsw_search_mem_multiplier,
9494
2,1,1000,PGC_USERSET,0,NULL,NULL,NULL);
9595

‎src/hnsw.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,17 @@
109109

110110
/* Variables */
111111
externinthnsw_ef_search;
112-
externinthnsw_iterative_scan;
112+
externinthnsw_iterative_search;
113113
externinthnsw_max_search_tuples;
114114
externdoublehnsw_search_mem_multiplier;
115115
externinthnsw_lock_tranche_id;
116116

117-
typedefenumHnswIterativeScanMode
117+
typedefenumHnswIterativeSearchMode
118118
{
119-
HNSW_ITERATIVE_SCAN_OFF,
120-
HNSW_ITERATIVE_SCAN_RELAXED,
121-
HNSW_ITERATIVE_SCAN_STRICT
122-
}HnswIterativeScanMode;
119+
HNSW_ITERATIVE_SEARCH_OFF,
120+
HNSW_ITERATIVE_SEARCH_RELAXED,
121+
HNSW_ITERATIVE_SEARCH_STRICT
122+
}HnswIterativeSearchMode;
123123

124124
typedefstructHnswElementDataHnswElementData;
125125
typedefstructHnswNeighborArrayHnswNeighborArray;

‎src/hnswscan.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ GetScanItems(IndexScanDesc scan, Datum value)
4141
ep=w;
4242
}
4343

44-
returnHnswSearchLayer(base,q,ep,hnsw_ef_search,0,index,support,m, false,NULL,&so->v,hnsw_iterative_scan!=HNSW_ITERATIVE_SCAN_OFF ?&so->discarded :NULL, true,&so->tuples);
44+
returnHnswSearchLayer(base,q,ep,hnsw_ef_search,0,index,support,m, false,NULL,&so->v,hnsw_iterative_search!=HNSW_ITERATIVE_SEARCH_OFF ?&so->discarded :NULL, true,&so->tuples);
4545
}
4646

4747
/*
@@ -229,7 +229,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
229229

230230
if (list_length(so->w)==0)
231231
{
232-
if (hnsw_iterative_scan==HNSW_ITERATIVE_SCAN_OFF)
232+
if (hnsw_iterative_search==HNSW_ITERATIVE_SEARCH_OFF)
233233
break;
234234

235235
/* Empty index */
@@ -295,7 +295,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
295295
so->w=list_delete_last(so->w);
296296

297297
/* Mark memory as free for next iteration */
298-
if (hnsw_iterative_scan!=HNSW_ITERATIVE_SCAN_OFF)
298+
if (hnsw_iterative_search!=HNSW_ITERATIVE_SEARCH_OFF)
299299
{
300300
pfree(element);
301301
pfree(sc);
@@ -306,7 +306,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
306306

307307
heaptid=&element->heaptids[--element->heaptidsLength];
308308

309-
if (hnsw_iterative_scan==HNSW_ITERATIVE_SCAN_STRICT)
309+
if (hnsw_iterative_search==HNSW_ITERATIVE_SEARCH_STRICT)
310310
{
311311
if (sc->distance<so->previousDistance)
312312
continue;

‎src/ivfflat.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
#endif
1818

1919
intivfflat_probes;
20-
intivfflat_iterative_scan;
20+
intivfflat_iterative_search;
2121
intivfflat_max_probes;
2222
staticrelopt_kindivfflat_relopt_kind;
2323

24-
staticconststructconfig_enum_entryivfflat_iterative_scan_options[]= {
25-
{"off",IVFFLAT_ITERATIVE_SCAN_OFF, false},
26-
{"relaxed_order",IVFFLAT_ITERATIVE_SCAN_RELAXED, false},
24+
staticconststructconfig_enum_entryivfflat_iterative_search_options[]= {
25+
{"off",IVFFLAT_ITERATIVE_SEARCH_OFF, false},
26+
{"relaxed_order",IVFFLAT_ITERATIVE_SEARCH_RELAXED, false},
2727
{NULL,0, false}
2828
};
2929

@@ -41,12 +41,12 @@ IvfflatInit(void)
4141
"Valid range is 1..lists.",&ivfflat_probes,
4242
IVFFLAT_DEFAULT_PROBES,IVFFLAT_MIN_LISTS,IVFFLAT_MAX_LISTS,PGC_USERSET,0,NULL,NULL,NULL);
4343

44-
DefineCustomEnumVariable("ivfflat.iterative_scan","Sets themode foriterativescans",
45-
NULL,&ivfflat_iterative_scan,
46-
IVFFLAT_ITERATIVE_SCAN_OFF,ivfflat_iterative_scan_options,PGC_USERSET,0,NULL,NULL,NULL);
44+
DefineCustomEnumVariable("ivfflat.iterative_search","Sets the iterativesearch mode",
45+
NULL,&ivfflat_iterative_search,
46+
IVFFLAT_ITERATIVE_SEARCH_OFF,ivfflat_iterative_search_options,PGC_USERSET,0,NULL,NULL,NULL);
4747

4848
/* If this is less than probes, probes is used */
49-
DefineCustomIntVariable("ivfflat.max_probes","Sets the max number of probes for iterativescans",
49+
DefineCustomIntVariable("ivfflat.max_probes","Sets the max number of probes for iterativesearch",
5050
NULL,&ivfflat_max_probes,
5151
IVFFLAT_MAX_LISTS,IVFFLAT_MIN_LISTS,IVFFLAT_MAX_LISTS,PGC_USERSET,0,NULL,NULL,NULL);
5252

‎src/ivfflat.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@
8080

8181
/* Variables */
8282
externintivfflat_probes;
83-
externintivfflat_iterative_scan;
83+
externintivfflat_iterative_search;
8484
externintivfflat_max_probes;
8585

86-
typedefenumIvfflatIterativeScanMode
86+
typedefenumIvfflatIterativeSearchMode
8787
{
88-
IVFFLAT_ITERATIVE_SCAN_OFF,
89-
IVFFLAT_ITERATIVE_SCAN_RELAXED
90-
}IvfflatIterativeScanMode;
88+
IVFFLAT_ITERATIVE_SEARCH_OFF,
89+
IVFFLAT_ITERATIVE_SEARCH_RELAXED
90+
}IvfflatIterativeSearchMode;
9191

9292
typedefstructVectorArrayData
9393
{

‎src/ivfscan.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ GetScanItems(IndexScanDesc scan, Datum value)
171171
}
172172
}
173173

174-
if (tuples<100&&ivfflat_iterative_scan==IVFFLAT_ITERATIVE_SCAN_OFF)
174+
if (tuples<100&&ivfflat_iterative_search==IVFFLAT_ITERATIVE_SEARCH_OFF)
175175
ereport(DEBUG1,
176176
(errmsg("index scan found few tuples"),
177177
errdetail("Index may have been created with little data."),
@@ -263,7 +263,7 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys)
263263
/* Get lists and dimensions from metapage */
264264
IvfflatGetMetaPageInfo(index,&lists,&dimensions);
265265

266-
if (ivfflat_iterative_scan!=IVFFLAT_ITERATIVE_SCAN_OFF)
266+
if (ivfflat_iterative_search!=IVFFLAT_ITERATIVE_SEARCH_OFF)
267267
maxProbes=Max(ivfflat_max_probes,probes);
268268
else
269269
maxProbes=probes;

‎test/expected/hnsw_vector.out

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ DROP TABLE t;
104104
CREATE TABLE t (val vector(3));
105105
INSERT INTO t (val) VALUES ('[0,0,0]'), ('[1,2,3]'), ('[1,1,1]'), (NULL);
106106
CREATE INDEX ON t USING hnsw (val vector_l2_ops);
107-
SET hnsw.iterative_scan = strict_order;
107+
SET hnsw.iterative_search = strict_order;
108108
SET hnsw.ef_search = 1;
109109
SELECT * FROM t ORDER BY val <-> '[3,3,3]';
110110
val
@@ -114,7 +114,7 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]';
114114
[0,0,0]
115115
(3 rows)
116116

117-
SET hnsw.iterative_scan = relaxed_order;
117+
SET hnsw.iterative_search = relaxed_order;
118118
SELECT * FROM t ORDER BY val <-> '[3,3,3]';
119119
val
120120
---------
@@ -123,7 +123,7 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]';
123123
[0,0,0]
124124
(3 rows)
125125

126-
RESET hnsw.iterative_scan;
126+
RESET hnsw.iterative_search;
127127
RESET hnsw.ef_search;
128128
DROP TABLE t;
129129
-- unlogged
@@ -165,14 +165,14 @@ SET hnsw.ef_search = 0;
165165
ERROR: 0 is outside the valid range for parameter "hnsw.ef_search" (1 .. 1000)
166166
SET hnsw.ef_search = 1001;
167167
ERROR: 1001 is outside the valid range for parameter "hnsw.ef_search" (1 .. 1000)
168-
SHOW hnsw.iterative_scan;
169-
hnsw.iterative_scan
170-
---------------------
168+
SHOW hnsw.iterative_search;
169+
hnsw.iterative_search
170+
-----------------------
171171
off
172172
(1 row)
173173

174-
SET hnsw.iterative_scan = on;
175-
ERROR: invalid value for parameter "hnsw.iterative_scan": "on"
174+
SET hnsw.iterative_search = on;
175+
ERROR: invalid value for parameter "hnsw.iterative_search": "on"
176176
HINT: Available values: off, relaxed_order, strict_order.
177177
SHOW hnsw.max_search_tuples;
178178
hnsw.max_search_tuples

‎test/expected/ivfflat_vector.out

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ DROP TABLE t;
8686
CREATE TABLE t (val vector(3));
8787
INSERT INTO t (val) VALUES ('[0,0,0]'), ('[1,2,3]'), ('[1,1,1]'), (NULL);
8888
CREATE INDEX ON t USING ivfflat (val vector_l2_ops) WITH (lists = 3);
89-
SET ivfflat.iterative_scan = relaxed_order;
89+
SET ivfflat.iterative_search = relaxed_order;
9090
SELECT * FROM t ORDER BY val <-> '[3,3,3]';
9191
val
9292
---------
@@ -110,7 +110,7 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]';
110110
[1,1,1]
111111
(2 rows)
112112

113-
RESET ivfflat.iterative_scan;
113+
RESET ivfflat.iterative_search;
114114
RESET ivfflat.max_probes;
115115
DROP TABLE t;
116116
-- unlogged
@@ -144,14 +144,14 @@ SET ivfflat.probes = 0;
144144
ERROR: 0 is outside the valid range for parameter "ivfflat.probes" (1 .. 32768)
145145
SET ivfflat.probes = 32769;
146146
ERROR: 32769 is outside the valid range for parameter "ivfflat.probes" (1 .. 32768)
147-
SHOW ivfflat.iterative_scan;
148-
ivfflat.iterative_scan
149-
------------------------
147+
SHOW ivfflat.iterative_search;
148+
ivfflat.iterative_search
149+
--------------------------
150150
off
151151
(1 row)
152152

153-
SET ivfflat.iterative_scan = on;
154-
ERROR: invalid value for parameter "ivfflat.iterative_scan": "on"
153+
SET ivfflat.iterative_search = on;
154+
ERROR: invalid value for parameter "ivfflat.iterative_search": "on"
155155
HINT: Available values: off, relaxed_order.
156156
SHOW ivfflat.max_probes;
157157
ivfflat.max_probes

‎test/sql/hnsw_vector.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ CREATE TABLE t (val vector(3));
6363
INSERT INTO t (val)VALUES ('[0,0,0]'), ('[1,2,3]'), ('[1,1,1]'), (NULL);
6464
CREATEINDEXON t USING hnsw (val vector_l2_ops);
6565

66-
SEThnsw.iterative_scan= strict_order;
66+
SEThnsw.iterative_search= strict_order;
6767
SEThnsw.ef_search=1;
6868
SELECT*FROM tORDER BY val<->'[3,3,3]';
6969

70-
SEThnsw.iterative_scan= relaxed_order;
70+
SEThnsw.iterative_search= relaxed_order;
7171
SELECT*FROM tORDER BY val<->'[3,3,3]';
7272

73-
RESEThnsw.iterative_scan;
73+
RESEThnsw.iterative_search;
7474
RESEThnsw.ef_search;
7575
DROPTABLE t;
7676

@@ -98,9 +98,9 @@ SHOW hnsw.ef_search;
9898
SEThnsw.ef_search=0;
9999
SEThnsw.ef_search=1001;
100100

101-
SHOWhnsw.iterative_scan;
101+
SHOWhnsw.iterative_search;
102102

103-
SEThnsw.iterative_scan=on;
103+
SEThnsw.iterative_search=on;
104104

105105
SHOWhnsw.max_search_tuples;
106106

‎test/sql/ivfflat_vector.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ CREATE TABLE t (val vector(3));
5050
INSERT INTO t (val)VALUES ('[0,0,0]'), ('[1,2,3]'), ('[1,1,1]'), (NULL);
5151
CREATEINDEXON t USING ivfflat (val vector_l2_ops) WITH (lists=3);
5252

53-
SETivfflat.iterative_scan= relaxed_order;
53+
SETivfflat.iterative_search= relaxed_order;
5454
SELECT*FROM tORDER BY val<->'[3,3,3]';
5555

5656
SETivfflat.max_probes=1;
@@ -59,7 +59,7 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]';
5959
SETivfflat.max_probes=2;
6060
SELECT*FROM tORDER BY val<->'[3,3,3]';
6161

62-
RESETivfflat.iterative_scan;
62+
RESETivfflat.iterative_search;
6363
RESETivfflat.max_probes;
6464
DROPTABLE t;
6565

@@ -84,9 +84,9 @@ SHOW ivfflat.probes;
8484
SETivfflat.probes=0;
8585
SETivfflat.probes=32769;
8686

87-
SHOWivfflat.iterative_scan;
87+
SHOWivfflat.iterative_search;
8888

89-
SETivfflat.iterative_scan=on;
89+
SETivfflat.iterative_search=on;
9090

9191
SHOWivfflat.max_probes;
9292

‎test/t/041_ivfflat_iterative_scan.plrenamed to‎test/t/041_ivfflat_iterative_search.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
my$count =$node->safe_psql("postgres",qq(
2424
SET enable_seqscan = off;
2525
SET ivfflat.probes = 10;
26-
SET ivfflat.iterative_scan = relaxed_order;
26+
SET ivfflat.iterative_search = relaxed_order;
2727
SELECT COUNT(*) FROM (SELECT v FROM tst WHERE i % 10000 = 0 ORDER BY v <-> (SELECT v FROM tst LIMIT 1) LIMIT 11) t;
2828
));
2929
is($count, 10);
@@ -39,7 +39,7 @@
3939
$count =$node->safe_psql("postgres",qq(
4040
SET enable_seqscan = off;
4141
SET ivfflat.probes = 10;
42-
SET ivfflat.iterative_scan = relaxed_order;
42+
SET ivfflat.iterative_search = relaxed_order;
4343
SET ivfflat.max_probes =$max_probes;
4444
SELECT COUNT(*) FROM (SELECT v FROM tst WHERE i % 10000 = 0 ORDER BY v <-> (SELECT v FROM tst WHERE i =$i) LIMIT 11) t;
4545
));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp