Added hint to max dimensions error [skip ci]

This commit is contained in:
Andrew Kane committed 2026-12-01 21:18:34 -08:00
1 parent 3f4f1be356
commit bbf91bfabe
8 files changed
+44 -2

No files matched your search

+11 -1
View File
@@ -705,9 +705,19 @@ InitBuildState(HnswBuildState * buildstate, Relation heap, Relation index, Index
errmsg("column does not have dimensions")));
if (buildstate->dimensions > buildstate->typeInfo->maxDimensions)
{
char *hint = NULL;
if (buildstate->dimensions <= HNSW_MAX_DIM * 2)
hint = "Use halfvec or binary quantization.";
else if (buildstate->dimensions <= HNSW_MAX_DIM * 32)
hint = "Use binary quantization if possible.";
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("%s column cannot have more than %d dimensions for hnsw index", buildstate->typeInfo->typeName, buildstate->typeInfo->maxDimensions)));
errmsg("%s column cannot have more than %d dimensions for hnsw index", buildstate->typeInfo->typeName, buildstate->typeInfo->maxDimensions),
(hint != NULL ? errhint("%s", hint) : 0)));
}
if (buildstate->efConstruction / 2 < buildstate->m)
ereport(ERROR,
+11 -1
View File
@@ -352,9 +352,19 @@ InitBuildState(IvfflatBuildState * buildstate, Relation heap, Relation index, In
errmsg("column does not have dimensions")));
if (buildstate->dimensions > buildstate->typeInfo->maxDimensions)
{
char *hint = NULL;
if (buildstate->dimensions <= IVFFLAT_MAX_DIM * 2)
hint = "Use halfvec or binary quantization.";
else if (buildstate->dimensions <= IVFFLAT_MAX_DIM * 32)
hint = "Use binary quantization if possible.";
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("%s column cannot have more than %d dimensions for ivfflat index", buildstate->typeInfo->typeName, buildstate->typeInfo->maxDimensions)));
errmsg("%s column cannot have more than %d dimensions for ivfflat index", buildstate->typeInfo->typeName, buildstate->typeInfo->maxDimensions),
(hint != NULL ? errhint("%s", hint) : 0)));
}
buildstate->reltuples = 0;
buildstate->indtuples = 0;
+1
View File
@@ -107,4 +107,5 @@ DROP TABLE t;
CREATE TABLE t (val halfvec(4001));
CREATE INDEX ON t USING hnsw (val halfvec_l2_ops);
ERROR: halfvec column cannot have more than 4000 dimensions for hnsw index
HINT: Use binary quantization if possible.
DROP TABLE t;
+6
View File
@@ -215,6 +215,12 @@ DROP TABLE t;
CREATE TABLE t (val vector(2001));
CREATE INDEX ON t USING hnsw (val vector_l2_ops);
ERROR: vector column cannot have more than 2000 dimensions for hnsw index
HINT: Use halfvec or binary quantization.
DROP TABLE t;
CREATE TABLE t (val vector(4001));
CREATE INDEX ON t USING hnsw (val vector_l2_ops);
ERROR: vector column cannot have more than 2000 dimensions for hnsw index
HINT: Use binary quantization if possible.
DROP TABLE t;
-- properties
SELECT pg_indexam_has_property(oid, 'distance_orderable') FROM pg_am WHERE amname = 'hnsw';
+1
View File
@@ -92,6 +92,7 @@ DROP TABLE t;
CREATE TABLE t (val halfvec(4001));
CREATE INDEX ON t USING ivfflat (val halfvec_l2_ops);
ERROR: halfvec column cannot have more than 4000 dimensions for ivfflat index
HINT: Use binary quantization if possible.
DROP TABLE t;
-- memory
SET maintenance_work_mem = '1MB';
+6
View File
@@ -191,6 +191,12 @@ DROP TABLE t;
CREATE TABLE t (val vector(2001));
CREATE INDEX ON t USING ivfflat (val vector_l2_ops);
ERROR: vector column cannot have more than 2000 dimensions for ivfflat index
HINT: Use halfvec or binary quantization.
DROP TABLE t;
CREATE TABLE t (val vector(4001));
CREATE INDEX ON t USING ivfflat (val vector_l2_ops);
ERROR: vector column cannot have more than 2000 dimensions for ivfflat index
HINT: Use binary quantization if possible.
DROP TABLE t;
-- memory
SET maintenance_work_mem = '1MB';
+4
View File
@@ -123,6 +123,10 @@ CREATE TABLE t (val vector(2001));
CREATE INDEX ON t USING hnsw (val vector_l2_ops);
DROP TABLE t;
CREATE TABLE t (val vector(4001));
CREATE INDEX ON t USING hnsw (val vector_l2_ops);
DROP TABLE t;
-- properties
SELECT pg_indexam_has_property(oid, 'distance_orderable') FROM pg_am WHERE amname = 'hnsw';
+4
View File
@@ -105,6 +105,10 @@ CREATE TABLE t (val vector(2001));
CREATE INDEX ON t USING ivfflat (val vector_l2_ops);
DROP TABLE t;
CREATE TABLE t (val vector(4001));
CREATE INDEX ON t USING ivfflat (val vector_l2_ops);
DROP TABLE t;
-- memory
SET maintenance_work_mem = '1MB';