RAG Vector Database RAM & HNSW Storage Calculator
Calculate exact RAM and disk footprint for HNSW vector indexes across Float32, Float16, Int8 scalar quantization, and Binary vectors.
Input Parameters
Calculated Output
Primary Result
—
Adjust inputs to recalculate immediately.
1 Million Vectors (1536 Dimensions, HNSW M=16, 200B Metadata)
Notice how HNSW graph pointers (~0.15 GiB per 1M at M=16) remain fixed regardless of vector quantization.
| Vector Precision | Raw Vectors | HNSW + Metadata | Total RAM (w/ 1.2x) | Hosting Tier Fit |
|---|---|---|---|---|
| Float32 (4 B/dim) | 5.72 GiB | 0.34 GiB | 7.27 GiB | 16 GB VPS / RAM Node |
| Float16 (2 B/dim) | 2.86 GiB | 0.34 GiB | 3.84 GiB | 8 GB Budget VPS |
| Int8 Scalar Quant (1 B/dim) | 1.43 GiB | 0.34 GiB | 2.12 GiB | 4 GB Budget VPS |
| Binary Quant (1-bit) | 0.18 GiB | 0.34 GiB | 0.62 GiB | Fits anywhere (with rescore) |
Formula & Engineering Methodology
HNSW keeps bidirectional adjacency lists (~2 * M * 4-byte uint32 node IDs plus ~25% level/structural overhead) in RAM for millisecond ANN traversal alongside raw quantized vectors and indexed metadata fields.
raw_vectors_gib = (num_vectors * dimensions * precision) / 1073741824
hnsw_gib = (num_vectors * (2 * hnsw_m * 4) * 1.25) / 1073741824
metadata_gib = (num_vectors * metadata_bytes) / 1073741824
total_ram_gib = (raw_vectors_gib + hnsw_gib + metadata_gib) * headroom_mult
Variable Definitions
2 * hnsw_m * 4: Average bi-directional HNSW neighbor edge pointer bytes per vector.headroom_mult: Buffer for segment merges, WAL buffers, and mmap page cache.
Practical Note: On Qdrant/Milvus with disk-backed payloads and memory-mapped original FP32 vectors, you only need to hold Int8/Binary vectors + HNSW edges in hot RAM.
Frequently Asked Questions
Why do HNSW index edges still use RAM after Int8 or Binary quantization?
Vector quantization shrinks the embedding coordinates, not the graph node adjacency pointers (2 * M * 4 bytes per vector), which become a larger percentage of memory at high compression.
When does pgvector fit on a cheap single VPS vs dedicated Qdrant/Milvus?
Up to 1–3 million vectors (with halfvec FP16 or int8 quantization), pgvector or single-node Qdrant runs comfortably inside 4–16 GB RAM on a €10–€30/month VPS.
How does changing HNSW M from 16 to 32 impact RAM and recall?
Doubling M doubles graph edge memory and slows index ingestion, typically yielding only 1–2% higher recall—M=16 is optimal for most 1536d RAG workloads.