pgvector.git / summary / log / commit / refs
commit a76a18d5261d72a159c167fd3cecfc9a87d51635
Author: Andrew Kane <andrew@ankane.org>
Date: Wed Jul 01 19:15:27 2026 +0000
Added tests for index dimensions [skip ci]
test/expected/hnsw_halfvec.out | 8 ++++++++
test/expected/hnsw_vector.out | 8 ++++++++
test/expected/ivfflat_halfvec.out | 11 +++++++++++
test/expected/ivfflat_vector.out | 11 +++++++++++
test/sql/hnsw_halfvec.sql | 10 ++++++++++
test/sql/hnsw_vector.sql | 10 ++++++++++
test/sql/ivfflat_halfvec.sql | 10 ++++++++++
test/sql/ivfflat_vector.sql | 10 ++++++++++
8 files changed, 78 insertions(+)
diff --git a/test/expected/hnsw_halfvec.out b/test/expected/hnsw_halfvec.out
index 98bbd436..6924d292 100644
--- a/test/expected/hnsw_halfvec.out
+++ b/test/expected/hnsw_halfvec.out
@@ -100,3 +100,11 @@ SELECT COUNT(*) FROM (SELECT * FROM t ORDER BY val <+> (SELECT NULL::halfvec)) t
(1 row)
DROP TABLE t;
+-- dimensions
+CREATE TABLE t (val halfvec(4000));
+CREATE INDEX ON t USING hnsw (val halfvec_l2_ops);
+DROP TABLE t;
+CREATE TABLE t (val halfvec(4001));
+CREATE INDEX ON t USING hnsw (val halfvec_l2_ops);
+ERROR: column cannot have more than 4000 dimensions for hnsw index
+DROP TABLE t;
diff --git a/test/expected/hnsw_vector.out b/test/expected/hnsw_vector.out
index cb4d8b97..d11268be 100644
--- a/test/expected/hnsw_vector.out
+++ b/test/expected/hnsw_vector.out
@@ -199,3 +199,11 @@ ERROR: 0 is outside the valid range for parameter "hnsw.scan_mem_multiplier" (1
SET hnsw.scan_mem_multiplier = 1001;
ERROR: 1001 is outside the valid range for parameter "hnsw.scan_mem_multiplier" (1 .. 1000)
DROP TABLE t;
+-- dimensions
+CREATE TABLE t (val vector(2000));
+CREATE INDEX ON t USING hnsw (val vector_l2_ops);
+DROP TABLE t;
+CREATE TABLE t (val vector(2001));
+CREATE INDEX ON t USING hnsw (val vector_l2_ops);
+ERROR: column cannot have more than 2000 dimensions for hnsw index
+DROP TABLE t;
diff --git a/test/expected/ivfflat_halfvec.out b/test/expected/ivfflat_halfvec.out
index 9b85331d..4893ad16 100644
--- a/test/expected/ivfflat_halfvec.out
+++ b/test/expected/ivfflat_halfvec.out
@@ -82,3 +82,14 @@ SELECT COUNT(*) FROM (SELECT * FROM t ORDER BY val <=> (SELECT NULL::halfvec)) t
(1 row)
DROP TABLE t;
+-- dimensions
+CREATE TABLE t (val halfvec(4000));
+CREATE INDEX ON t USING ivfflat (val halfvec_l2_ops);
+NOTICE: ivfflat index created with little data
+DETAIL: This will cause low recall.
+HINT: Drop the index until the table has more data.
+DROP TABLE t;
+CREATE TABLE t (val halfvec(4001));
+CREATE INDEX ON t USING ivfflat (val halfvec_l2_ops);
+ERROR: column cannot have more than 4000 dimensions for ivfflat index
+DROP TABLE t;
diff --git a/test/expected/ivfflat_vector.out b/test/expected/ivfflat_vector.out
index 23e1c014..b5567efb 100644
--- a/test/expected/ivfflat_vector.out
+++ b/test/expected/ivfflat_vector.out
@@ -173,6 +173,17 @@ ERROR: 0 is outside the valid range for parameter "ivfflat.max_probes" (1 .. 32
SET ivfflat.max_probes = 32769;
ERROR: 32769 is outside the valid range for parameter "ivfflat.max_probes" (1 .. 32768)
DROP TABLE t;
+-- dimensions
+CREATE TABLE t (val vector(2000));
+CREATE INDEX ON t USING ivfflat (val vector_l2_ops);
+NOTICE: ivfflat index created with little data
+DETAIL: This will cause low recall.
+HINT: Drop the index until the table has more data.
+DROP TABLE t;
+CREATE TABLE t (val vector(2001));
+CREATE INDEX ON t USING ivfflat (val vector_l2_ops);
+ERROR: column cannot have more than 2000 dimensions for ivfflat index
+DROP TABLE t;
-- memory
CREATE TABLE t (val vector(2000));
CREATE INDEX ON t USING ivfflat (val vector_l2_ops) WITH (lists = 4096);
diff --git a/test/sql/hnsw_halfvec.sql b/test/sql/hnsw_halfvec.sql
index 89460ade..e4818a69 100644
--- a/test/sql/hnsw_halfvec.sql
+++ b/test/sql/hnsw_halfvec.sql
@@ -56,3 +56,13 @@ SELECT * FROM t ORDER BY val <+> '[3,3,3]';
SELECT COUNT(*) FROM (SELECT * FROM t ORDER BY val <+> (SELECT NULL::halfvec)) t2;
DROP TABLE t;
+
+-- dimensions
+
+CREATE TABLE t (val halfvec(4000));
+CREATE INDEX ON t USING hnsw (val halfvec_l2_ops);
+DROP TABLE t;
+
+CREATE TABLE t (val halfvec(4001));
+CREATE INDEX ON t USING hnsw (val halfvec_l2_ops);
+DROP TABLE t;
diff --git a/test/sql/hnsw_vector.sql b/test/sql/hnsw_vector.sql
index a928ba44..a081574b 100644
--- a/test/sql/hnsw_vector.sql
+++ b/test/sql/hnsw_vector.sql
@@ -115,3 +115,13 @@ SET hnsw.scan_mem_multiplier = 0;
SET hnsw.scan_mem_multiplier = 1001;
DROP TABLE t;
+
+-- dimensions
+
+CREATE TABLE t (val vector(2000));
+CREATE INDEX ON t USING hnsw (val vector_l2_ops);
+DROP TABLE t;
+
+CREATE TABLE t (val vector(2001));
+CREATE INDEX ON t USING hnsw (val vector_l2_ops);
+DROP TABLE t;
diff --git a/test/sql/ivfflat_halfvec.sql b/test/sql/ivfflat_halfvec.sql
index 17824521..a81b4ab0 100644
--- a/test/sql/ivfflat_halfvec.sql
+++ b/test/sql/ivfflat_halfvec.sql
@@ -43,3 +43,13 @@ SELECT COUNT(*) FROM (SELECT * FROM t ORDER BY val <=> '[0,0,0]') t2;
SELECT COUNT(*) FROM (SELECT * FROM t ORDER BY val <=> (SELECT NULL::halfvec)) t2;
DROP TABLE t;
+
+-- dimensions
+
+CREATE TABLE t (val halfvec(4000));
+CREATE INDEX ON t USING ivfflat (val halfvec_l2_ops);
+DROP TABLE t;
+
+CREATE TABLE t (val halfvec(4001));
+CREATE INDEX ON t USING ivfflat (val halfvec_l2_ops);
+DROP TABLE t;
diff --git a/test/sql/ivfflat_vector.sql b/test/sql/ivfflat_vector.sql
index 826f6f8b..a7392b39 100644
--- a/test/sql/ivfflat_vector.sql
+++ b/test/sql/ivfflat_vector.sql
@@ -98,6 +98,16 @@ SET ivfflat.max_probes = 32769;
DROP TABLE t;
+-- dimensions
+
+CREATE TABLE t (val vector(2000));
+CREATE INDEX ON t USING ivfflat (val vector_l2_ops);
+DROP TABLE t;
+
+CREATE TABLE t (val vector(2001));
+CREATE INDEX ON t USING ivfflat (val vector_l2_ops);
+DROP TABLE t;
+
-- memory
CREATE TABLE t (val vector(2000));
[parent: b383e4d191e7]