AI Engineeringestimator

Vector index memory planner

Most vector search runs from memory, so the first sizing question is how much RAM an index needs. The vectors themselves are only part of the answer: a graph index stores links beside every vector, a clustered index stores ids and centroids, and a compressed index trades precision for a much smaller code.

Memory estimate

32 GB for 10,000,000 vectors with an HNSW graph. Largest part: Vectors, 96%.

Total32 GB1 replica × 32 GB
Memory per replica, by part
Memory per replica by part
PartSizeShare
Vectors30.7 GB95.9%
Graph links1.3 GB4.1%

Data and index

768, 1,024 and 1,536 are common for text embeddings.

Payload kept in memory beside each vector, such as filter fields.

Full copies of the index, for throughput or availability.

hnswlib suggests 12 to 48 for most uses. A higher M raises recall and memory.

Detail

Per replica32 GB3,204.3 bytes per vector
Raw vectors30.7 GB10,000,000 × 768 dimensions, float32
Index overhead1.3 GB4.3% of the raw vectors
Total memory for each index type at these settings
Index typePer replicaAll replicas
Flat (exact search)30.7 GB30.7 GB
HNSW graph32 GB32 GB
IVF-flat30.8 GB30.8 GB
IVF-PQ1.1 GB1.1 GB

Formulas used (all estimates)

  • Estimate, vectors: vectors × dimensions × bytes per dimension. Binary packs 8 dimensions per byte.
  • Estimate, graph links: vectors × 4 × (2M + M ÷ (M − 1)) = 132.3 bytes per vector. Layer 0 keeps 2M links; upper layers add about M ÷ (M − 1) on average.
  • Estimate, total: parts per replica, plus vectors × metadata bytes, times replicas.

What it shows

Most vector search runs from memory, so index size decides how much RAM you need. The vectors are only part of it: graph indexes add links, clustered indexes add ids and centroids, and compressed indexes store smaller codes.

The tool adds these parts for one replica, then multiplies by replicas. All formulas are estimates from published rules of thumb.

How to read it

  • Raw vectors is vectors × dimensions × bytes per dimension. float32 uses 4 bytes, float16 2, int8 1, and binary 1 bit.
  • Index overhead is everything beyond vectors and metadata. HNSW adds graph links; IVF types add ids and centroids; IVF-PQ also adds codebooks.
  • Quantising vectors does not shrink the HNSW graph, so overhead grows as a share of the total.
  • IVF-PQ stores m codes per vector. The element type then only sets the raw size shown for comparison.
  • Total is per-replica memory times replicas. Each replica holds a full copy.
  • The table at the bottom compares all four index types at your settings.

Questions

Why does an HNSW index use more memory than the vectors alone?

Each vector keeps a list of neighbour ids at every layer it appears in. At layer 0 that is up to 2M ids of 4 bytes each, so M = 16 adds about 130 bytes per vector. The overhead is small next to a 768-dimension float32 vector, but large next to a quantised one.

Does quantising the vectors shrink the HNSW graph?

No. The links depend only on M and the number of vectors. Quantising from float32 to int8 cuts the vector bytes by four but leaves the links unchanged.

Why must dimensions divide evenly by m in product quantisation?

Product quantisation splits each vector into m equal sub-vectors and learns a separate codebook for each. If the dimensions did not divide evenly, the sub-vectors would differ in length. The planner lists only the values of m that work for your dimensions.

What does this estimate leave out?

Memory used while building the index, query buffers, the operating system, filtering structures, and any full-precision copy of the vectors kept to re-rank results. A disk-backed index also holds less in RAM than shown here.

How accurate are these numbers?

They follow the bytes-per-vector rules in the faiss wiki and the memory note in the hnswlib documentation, plus the layer-probability result from the HNSW paper for the upper layers. Real libraries add headers, alignment and allocator overhead, so expect the measured size to be somewhat higher.

Sources

Explore further

  • ANN-BenchmarksCompares approximate nearest neighbour libraries on recall against queries per second.

Last updated

More tools

All tools

Your first senior-level
lesson is free.

Choose a course, open a free lesson, and explore an idea you’ve wanted to understand.