Vector Index Memory Calculator
Most vector-database sizing assumes vectors × dimensions × 4 bytes. That misses the HNSW graph, payload, replicas and allocator headroom — the parts that actually fill RAM. This calculator includes them.
Index shape
HNSW graph estimate: vectors × M × 2 × 4 bytes. Real implementations vary; use this as a planning baseline and verify with your database's own metrics.
Estimated memory
How the estimate works
| Component | Formula | Why it matters |
|---|---|---|
| Raw vectors | vectors × dimensions × bytes | The floor. float32 = 4 bytes, float16 = 2, int8 = 1. |
| HNSW graph | vectors × M × 2 × 4 bytes | Each vector stores up to M neighbors per layer. The graph can add 20–60%. |
| Payload | vectors × payload bytes | Metadata, filters, IDs and document text kept alongside the vector. |
| Replicas | per-replica total × replicas | Every replica holds a full copy. |
| Headroom | total × 1.5 | Allocator overhead, compaction, segment merges and query working set. |
Worked example
One million vectors at 1,536 dimensions in float32 is about 6.1 GB of raw vectors. With M=32, the HNSW graph adds roughly 256 MB. A 256-byte payload adds another 256 MB, and two replicas double the total to about 13.2 GB. A 1.5× headroom multiplier puts the planning figure near 19.8 GB. That is the number to compare with your vector database's memory limit, not the 6.1 GB raw figure.
What to check before you buy RAM
- Recall after quantization. int8 cuts vector memory by 75% versus float32, but measure recall on your own queries before switching.
- Payload size. Keeping full document text in the index can cost more than the vectors. Store text outside the index and keep only IDs and filter fields.
- Replica policy. Two replicas are the minimum for high availability; three if you need to survive a zone failure.
- Segment and compaction overhead. HNSW indexes are merged in the background; peak memory can exceed the steady-state estimate.
Sizing the rest of the RAG stack?
Estimate ingestion, embeddings and generation cost with the RAG cost calculator, then compare embedding models.
RAG cost calculator Embedding comparisonFAQ
How much RAM does a vector index need?
Start with vectors × dimensions × bytes per dimension, add the HNSW graph, payload and replicas, then multiply by 1.5 for headroom.
Does HNSW use more memory than flat search?
Yes. HNSW adds a graph with up to M neighbors per layer per vector, plus bookkeeping. The graph can add 20–60% on top of raw vector memory.
Should I use float32, float16 or int8?
float32 is 4 bytes per dimension, float16 is 2 and int8 is 1. Quantization reduces memory but can lower recall; measure before switching.
How do replicas affect memory?
Each replica holds a full copy of the index, so memory scales linearly with the replica count.
This calculator is a planning tool, not a benchmark. Actual memory depends on the vector database, index type, segment count and allocator.