From 656b059258e04c4c67ad8f5a927058b2ab5ecdcb Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 13 Feb 2025 16:28:14 -0800 Subject: [PATCH] Added tests for iterative index scan with empty index - resolves #679 [skip ci] --- test/expected/hnsw_vector.out | 6 ++++++ test/expected/ivfflat_vector.out | 9 +++++++++ test/sql/hnsw_vector.sql | 3 +++ test/sql/ivfflat_vector.sql | 3 +++ 4 files changed, 21 insertions(+) diff --git a/test/expected/hnsw_vector.out b/test/expected/hnsw_vector.out index 29ea724..cb4d8b9 100644 --- a/test/expected/hnsw_vector.out +++ b/test/expected/hnsw_vector.out @@ -123,6 +123,12 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]'; [0,0,0] (3 rows) +TRUNCATE t; +SELECT * FROM t ORDER BY val <-> '[3,3,3]'; + val +----- +(0 rows) + RESET hnsw.iterative_scan; RESET hnsw.ef_search; DROP TABLE t; diff --git a/test/expected/ivfflat_vector.out b/test/expected/ivfflat_vector.out index 5a6bc75..aad8226 100644 --- a/test/expected/ivfflat_vector.out +++ b/test/expected/ivfflat_vector.out @@ -110,6 +110,15 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]'; [1,1,1] (2 rows) +TRUNCATE t; +NOTICE: ivfflat index created with little data +DETAIL: This will cause low recall. +HINT: Drop the index until the table has more data. +SELECT * FROM t ORDER BY val <-> '[3,3,3]'; + val +----- +(0 rows) + RESET ivfflat.iterative_scan; RESET ivfflat.max_probes; DROP TABLE t; diff --git a/test/sql/hnsw_vector.sql b/test/sql/hnsw_vector.sql index 184d65f..a928ba4 100644 --- a/test/sql/hnsw_vector.sql +++ b/test/sql/hnsw_vector.sql @@ -70,6 +70,9 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]'; SET hnsw.iterative_scan = relaxed_order; SELECT * FROM t ORDER BY val <-> '[3,3,3]'; +TRUNCATE t; +SELECT * FROM t ORDER BY val <-> '[3,3,3]'; + RESET hnsw.iterative_scan; RESET hnsw.ef_search; DROP TABLE t; diff --git a/test/sql/ivfflat_vector.sql b/test/sql/ivfflat_vector.sql index 785fc6c..4c20d2f 100644 --- a/test/sql/ivfflat_vector.sql +++ b/test/sql/ivfflat_vector.sql @@ -59,6 +59,9 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]'; SET ivfflat.max_probes = 2; SELECT * FROM t ORDER BY val <-> '[3,3,3]'; +TRUNCATE t; +SELECT * FROM t ORDER BY val <-> '[3,3,3]'; + RESET ivfflat.iterative_scan; RESET ivfflat.max_probes; DROP TABLE t;