# Fix pgvector 2000-Dimension HNSW Limit on OpenAI text-embedding-3-large & Gemini 3072d

> PostgreSQL uses fixed 8 KB heap and index pages, capping pgvector FP32 vector(N) HNSW and IVFFlat indexes at 2,000 dimensions and blocking 3,072d outputs from OpenAI text-embedding-3-large and Google gemini-embedding-001. Fix this immediately via halfvec(3072) functional HNSW indexes or normalized 1,536d Matryoshka truncation, or switch to Voxell Forge Turbo 1024d ($0 forever) and Pro 2560d ($0.25/1M tokens).

Canonical URL: https://voxell.ai/optimize/pgvector-2000-dimension-limit-hnsw/


## 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:

```text
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)` in `FP32`: `2,000 * 4 bytes = 8,000 bytes` + header -> **fits** inside `8,192` bytes.
- `vector(3072)` in `FP32`: `3,072 * 4 bytes = 12,288 bytes` + header -> **exceeds** `8,192` bytes (`ERROR`).
- `halfvec(3072)` in `FP16` (`pgvector >= 0.7.0`): `3,072 * 2 bytes = 6,144 bytes` + header -> **fits** up to `4,000` dimensions.
- `bit(3072)` in `1-bit` binary (`pgvector >= 0.7.0`): `3,072 / 8 = 384 bytes` + header -> **fits** up to `64,000` dimensions.

## 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:

```sql
-- 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](/optimize/gemini-embedding-001-mrl-l2-normalization/)). Always enforce unit L2 norm in your ingestion wrapper:

```python
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](/tools/vector-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):

```bash
# 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](/tools/vector-calculator/)**, explore **[Vendor Comparisons](/compare/)**, or grab a free key in the **[Forge Console](https://dash.voxell.ai/home)** and review **[v4.0 Pricing](/pricing/)**.

## Frequently Asked Questions

### Why does pgvector throw ERROR: column cannot have more than 2000 dimensions for hnsw index?

Standard PostgreSQL compiles with BLCKSZ = 8192 bytes. A 3,072-dimension float32 vector consumes 12,288 bytes (3072 * 4 bytes) plus tuple header overhead, so an index tuple cannot fit inside a single 8 KB index page without TOAST out-of-line storage, which PostgreSQL index access methods forbid.

### Does casting vector(3072) to halfvec(3072) hurt recall on OpenAI or Gemini embeddings?

In almost all retrieval benchmarks, IEEE 754 float16 (halfvec, 1 sign bit, 5 exponent bits, 10 mantissa bits) retains 99.8%+ of float32 HNSW recall while cutting index RAM from 12,288 bytes per vector payload to 6,144 bytes, fitting cleanly inside pgvector's 4,000-dimension halfvec limit.

### How do Voxell Forge Turbo and Pro dimensions fit into pgvector?

Voxell Forge Turbo outputs native 1,024-dimension float32 vectors at $0 forever, indexing directly in standard vector(1024) HNSW with 3x smaller memory than 3072d. Forge Pro outputs native 2,560d vectors ($0.25/1M tokens) that index directly in halfvec(2560) or slice cleanly via normalized MRL to 1024d or 1536d.

---

## Zero-Install Model Context Protocol (MCP) & Keyless Agent Verification

```bash
claude mcp add --transport http voxell-forge https://api.voxell.ai/mcp/try
```

- Keyless Retrieval Bake-Off: `POST https://api.voxell.ai/api/v1/agent/bakeoff`
- Keyless Contradiction X-Ray: `POST https://api.voxell.ai/api/v1/agent/xray`
- Machine-Readable Pricing JSON: `https://voxell.ai/api/v1/agent/pricing.json`
- Full LLM Authority Map: `https://voxell.ai/llms-full.txt`
