Why PostgreSQL Rejects vector(3072) HNSW Indexes
When you create a table storing default outputs from text-embedding-3-large (3072d) or gemini-embedding-001 (3072d) and run CREATE INDEX ... USING hnsw, pgvector aborts immediately:
ERROR: column cannot have more than 2000 dimensions for hnsw index
The root cause is PostgreSQL’s 8,192-byte (8 KB) page size (BLCKSZ). PostgreSQL index tuples cannot use TOAST external compression pointers; every HNSW graph node and vector payload must reside inline on an 8 KB index page:
vector(2000)inFP32:2,000 * 4 bytes = 8,000 bytes+ header -> fits inside8,192bytes.vector(3072)inFP32:3,072 * 4 bytes = 12,288 bytes+ header -> exceeds8,192bytes (ERROR).halfvec(3072)inFP16(pgvector >= 0.7.0):3,072 * 2 bytes = 6,144 bytes+ header -> fits up to4,000dimensions.bit(3072)in1-bitbinary (pgvector >= 0.7.0):3,072 / 8 = 384 bytes+ header -> fits up to64,000dimensions.
Fix 1 (Zero Re-Embedding): Functional halfvec(3072) HNSW Index in SQL
If you already have millions of vector(3072) rows in PostgreSQL on pgvector 0.7.0+ (supported across RDS, Aurora, Cloud SQL, Supabase, and Neon), you do not need to re-embed or rewrite your table column. Build an expression HNSW index casting embedding::halfvec(3072) and cast the query parameter identically so the planner selects the index:
-- Verify pgvector >= 0.7.0
CREATE EXTENSION IF NOT EXISTS vector;
SELECT extversion FROM pg_extension WHERE extname = 'vector';
-- Option A: Keep existing vector(3072) heap column, build expression HNSW index in FP16
SET LOCAL maintenance_work_mem = '4GB';
SET LOCAL max_parallel_maintenance_workers = 7;
CREATE INDEX CONCURRENTLY idx_chunks_emb_halfvec_hnsw
ON doc_chunks
USING hnsw ((embedding::halfvec(3072)) halfvec_cosine_ops)
WITH (m = 16, ef_construction = 128);
-- CRITICAL: Your SELECT ORDER BY expression MUST match the index expression!
SELECT chunk_id, doc_id, body,
1 - ((embedding::halfvec(3072)) <=> $1::halfvec(3072)) AS cosine_sim
FROM doc_chunks
ORDER BY (embedding::halfvec(3072)) <=> $1::halfvec(3072)
LIMIT 20;
-- Option B: New greenfield table storing halfvec(3072) natively (saves 50% disk + RAM)
CREATE TABLE doc_chunks_v2 (
chunk_id BIGSERIAL PRIMARY KEY,
tenant_id UUID NOT NULL,
body TEXT NOT NULL,
embedding halfvec(3072) NOT NULL
);
CREATE INDEX idx_chunks_v2_hnsw
ON doc_chunks_v2
USING hnsw (embedding halfvec_cosine_ops)
WITH (m = 16, ef_construction = 128);
Fix 2 (50% Smaller Heap + Native FP32): Matryoshka 1536d Truncation
Both text-embedding-3-large and gemini-embedding-001 were trained with Matryoshka Representation Learning (MRL), front-loading high-variance semantic signal into earlier dimensions. Truncating to 1,536 dimensions fits directly inside vector(1536) FP32 HNSW.
Watch out for a critical provider divergence: OpenAI’s API renormalizes truncated vectors server-side when dimensions=1536 is passed, whereas Google gemini-embedding-001 returns unnormalized vectors at output_dimensionality < 3072 (covered in depth in Guide 02). Always enforce unit L2 norm in your ingestion wrapper:
import numpy as np
from openai import OpenAI
oai = OpenAI()
def embed_1536_normalized(texts: list[str]) -> list[list[float]]:
resp = oai.embeddings.create(
model="text-embedding-3-large",
input=texts,
dimensions=1536, # Fits native pgvector vector(1536) HNSW (< 2000d limit)
)
vecs = np.asarray([item.embedding for item in resp.data], dtype=np.float32)
norms = np.linalg.norm(vecs, axis=1, keepdims=True)
vecs = vecs / np.maximum(norms, 1e-12)
return vecs.tolist()
Quantitative Memory & Index Comparison (10,000,000 Vectors)
Use our Interactive Vector RAM & TCO Calculator to adjust chunk counts for your own cluster. At 10M vectors (m = 16, including ~320 B/vec HNSW graph links + tuple headers and 20% buffer headroom):
| Model & Column Type | Dimensions | Native pgvector HNSW? |
Raw Vector Bytes / Row | Resident HNSW RAM (10M Rows) |
Token Price (/ 1M) |
|---|---|---|---|---|---|
OpenAI 3-large vector(3072) |
3072d FP32 |
NO (ERROR > 2000d) |
12,288 B |
Blocked (Heap: 114.4 GB) |
$0.13 |
Gemini 001 halfvec(3072) |
3072d FP16 |
Yes (<= 4000d cap) |
6,144 B |
~72.2 GB |
$0.15 |
OpenAI 3-large vector(1536) |
1536d FP32 |
Yes (<= 2000d cap) |
6,144 B |
~72.2 GB |
$0.13 |
Voxell Forge Turbo vector(1024) |
1024d FP32 |
Yes (Native FP32) | 4,096 B |
~49.4 GB (halfvec: ~26.5 GB) |
$0 forever |
Voxell Forge Pro halfvec(2560) |
2560d FP16 (MRL 256..2560) |
Yes (halfvec or MRL 1536d) |
5,120 B |
~60.8 GB (99.04% Recall@20) |
$0.25 |
Where Workarounds Hit the Ceiling: One-Line Upgrade to Voxell Forge
Getting halfvec(3072) past PostgreSQL’s 8 KB page limit solves the DDL crash, yet leaves unconditioned generic vectors struggling on domain acronyms, financial tables, and negation. Voxell Forge gives you an OpenAI-compatible /v1/embeddings endpoint (Turbo 1024d at $0 forever; Pro 2560d at $0.25/1M tokens with unit-normalized MRL across 256..2560d), plus C_corpus zero-LLM dialect conditioning (0.6652 Stage-1 nDCG@10, 99.04% Recall@20), Play 1 64-bit CUDA AMQ filtering, and Stage-2 Max cross-encoder reranking (0.8849 nDCG@10, 75.93% Strict@1) from $39/mo annual ($199/mo Team):
# 1. Drop-in OpenAI-compatible 1024d FP32 vector call (fits native vector(1024) at $0)
# Python: OpenAI(base_url="https://api.voxell.ai/v1", api_key=FORGE_KEY)
# 2. Verify Forge retrieval conditioning right now with ZERO API key:
curl -sS -X POST https://api.voxell.ai/api/v1/agent/bakeoff \
-H "Content-Type: application/json" \
-d '{
"documents": [
{"name": "pg-limits.md", "text": "PostgreSQL 8 KB index pages limit pgvector FP32 HNSW to 2,000 dimensions and halfvec FP16 HNSW to 4,000 dimensions."},
{"name": "forge-dims.md", "text": "Voxell Forge Turbo emits unit-normalized 1,024d vectors free forever; Pro emits 2,560d vectors with MRL down to 256d."}
],
"queries": ["What is the maximum dimension count for pgvector halfvec HNSW indexes?"]
}'
Compare full cluster costs in the Vector RAM & TCO Calculator, explore Vendor Comparisons, or grab a free key in the Forge Console and review v4.0 Pricing.