mirror of
https://github.com/pgvector/pgvector.git
synced 2026-12-05 08:48:38 +00:00
Added hint to max dimensions error [skip ci]
This commit is contained in:
1 parent
3f4f1be356
commit
bbf91bfabe
8 files changed
+44
-2
No files matched your search
+11
-1
@@ -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
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in new issue
Block a user