Skip to content

Commit 656b059

Browse files
committed
Added tests for iterative index scan with empty index - resolves pgvector#679 [skip ci]
1 parent 7cf9980 commit 656b059

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

test/expected/hnsw_vector.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]';
123123
[0,0,0]
124124
(3 rows)
125125

126+
TRUNCATE t;
127+
SELECT * FROM t ORDER BY val <-> '[3,3,3]';
128+
val
129+
-----
130+
(0 rows)
131+
126132
RESET hnsw.iterative_scan;
127133
RESET hnsw.ef_search;
128134
DROP TABLE t;

test/expected/ivfflat_vector.out

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]';
110110
[1,1,1]
111111
(2 rows)
112112

113+
TRUNCATE t;
114+
NOTICE: ivfflat index created with little data
115+
DETAIL: This will cause low recall.
116+
HINT: Drop the index until the table has more data.
117+
SELECT * FROM t ORDER BY val <-> '[3,3,3]';
118+
val
119+
-----
120+
(0 rows)
121+
113122
RESET ivfflat.iterative_scan;
114123
RESET ivfflat.max_probes;
115124
DROP TABLE t;

test/sql/hnsw_vector.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]';
7070
SET hnsw.iterative_scan = relaxed_order;
7171
SELECT * FROM t ORDER BY val <-> '[3,3,3]';
7272

73+
TRUNCATE t;
74+
SELECT * FROM t ORDER BY val <-> '[3,3,3]';
75+
7376
RESET hnsw.iterative_scan;
7477
RESET hnsw.ef_search;
7578
DROP TABLE t;

test/sql/ivfflat_vector.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]';
5959
SET ivfflat.max_probes = 2;
6060
SELECT * FROM t ORDER BY val <-> '[3,3,3]';
6161

62+
TRUNCATE t;
63+
SELECT * FROM t ORDER BY val <-> '[3,3,3]';
64+
6265
RESET ivfflat.iterative_scan;
6366
RESET ivfflat.max_probes;
6467
DROP TABLE t;

0 commit comments

Comments
 (0)