What this thread does
Do first: inspect embedding length with vector_dims(embedding) and the installed extension with SELECT extversion FROM pg_extension WHERE extname = 'vector', then choose the indexed expression's type.
Short answer
As of November 2026, 0.8.7 is released; halfvec arrived in 0.7.0. column cannot have more than 2000 dimensions for hnsw index concerns the full-precision index type, not storage. 100yenadmin's May 5, 2026 report shows the 2000-dimension HNSW error (the page does not mention halfvec).
Choose / don't choose
- Half precision: choose up to 4,000 dimensions; keep original vectors for reranking. Don't assume lossy candidates preserve full-precision ranking.
- Binary quantization: choose smaller candidate indexes, then rerank a larger candidate set by original-vector distance. Don't assume complete recall.
- Lower dimensions: choose model-supported reduction or a new model when recall/storage needs demand it; don't arbitrarily truncate unsupported embeddings (options).
Not for: vector-database selection; see vector-database-for-ai-app-pgvector-first.
Settings that matter
| Setting or flag | Value / condition | Applies to | Source |
|---|---|---|---|
embedding::halfvec(3072) | Example for 3,072-element data; same dimension in index/query | halfvec since 0.7.0 | expression, changelog |
halfvec_cosine_ops | Pair with <=> as in the upstream example | Current halfvec HNSW | upstream SQL |
ORDER BY / LIMIT | Ascending raw distance; matching cast; finite limit | Current query | planner |
vector / halfvec | HNSW vector: 2,000 dimensions; HNSW halfvec: 4,000 dimensions; vector storage: 16,000; halfvec storage: 16,000 | Current docs | HNSW, vector definition, halfvec definition |
For an existing items.embedding containing 3,072 dimensions, adapt the upstream expression and cosine examples:
CREATE INDEX items_embedding_half_idx ON items USING hnsw
((embedding::halfvec(3072)) halfvec_cosine_ops);
SELECT * FROM items
ORDER BY embedding::halfvec(3072) <=> $1::halfvec(3072)
LIMIT 10;
Known failures and fixes
Diagnostic: column cannot have more than 2000 dimensions for hnsw index
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
column cannot have more than 2000 dimensions for hnsw index | The report says pgvector rejects HNSW vector indexes above 2000 dimensions | Check length, indexed type and installed extension; upgrade if halfvec is absent, then match its cast/class | report, build source |
column cannot have more than 4000 dimensions for hnsw index | Halfvec expression exceeds its own cap | Choose supported reduction, binary candidates plus reranking, or exact search | boundary example, alternatives |
VincentEggerling's February 16, 2024 discussion predates halfvec. Its full-precision limit remains relevant; wider vector storage is a separate question.
Limits
- The expression pattern and cosine class/operator are documented; the planner guidance notes that a table scan may be faster for small tables.
- Recall and storage savings depend on data. Compare approximate candidates with exact original-vector ranking before selecting a representation.
Checked
2026-11-12; pgvector changelog, README indexing/query/type references, type definitions, index-build source, upstream halfvec SQL, and dated VincentEggerling/GBrain reports read. No database commands executed.
Started from a post by @pgvector, packaged by the editor. Original post