From: VladlenPopolitov (@VladlenPopolitov) <noreply+VladlenPopolitov@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] PR #698: HNSW index test for insert to empty table with empty index is added
Date: Wed, 23 Oct 2024 12:56:59 +0000
Message-ID: <gh-pgvector-pgvector-698@github.com> (raw)
As soon as TRUNCATE TABLE test is added to check creation of index on empty table, it would be good to add the test of inserting first row to empty table with created index (no one other tests cover this situation).
inline patch 1: test/expected/hnsw_vector.out, test/sql/hnsw_vector.sql (+17/-0 lines) download inline-1.patchdiff --git a/test/expected/hnsw_vector.out b/test/expected/hnsw_vector.outindex 134292b32..23fe19b95 100644--- a/test/expected/hnsw_vector.out+++ b/test/expected/hnsw_vector.out@@ -31,6 +31,18 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]';
-----
(0 rows)
+-- insert to empty table and empty index+INSERT INTO t (val) VALUES ('[0,0,0]'), ('[1,2,3]'), ('[1,1,1]'), (NULL);+INSERT INTO t (val) VALUES ('[1,2,4]');+SELECT * FROM t ORDER BY val <-> '[3,3,3]';+ val +---------+ [1,2,3]+ [1,2,4]+ [1,1,1]+ [0,0,0]+(4 rows)+
DROP TABLE t;
-- inner product
CREATE TABLE t (val vector(3));
diff --git a/test/sql/hnsw_vector.sql b/test/sql/hnsw_vector.sqlindex 328175829..939d36e2d 100644--- a/test/sql/hnsw_vector.sql+++ b/test/sql/hnsw_vector.sql@@ -15,6 +15,11 @@ SELECT COUNT(*) FROM t;
TRUNCATE t;
SELECT * FROM t ORDER BY val <-> '[3,3,3]';
+-- insert to empty table and empty index+INSERT INTO t (val) VALUES ('[0,0,0]'), ('[1,2,3]'), ('[1,1,1]'), (NULL);+INSERT INTO t (val) VALUES ('[1,2,4]');+SELECT * FROM t ORDER BY val <-> '[3,3,3]';+
DROP TABLE t;
-- inner product