Formula: Vector DB HNSW RAM Systems Engineering Formula
- vectorCountMillions: Vector Count Millions (M vectors)
- embeddingDimensions: Embedding Dimensions (dims)
- bytesPerDimension: Bytes Per Dimension (B/dim)
- hnswMaxLinksM: Hnsw Max Links M (M links)
Size HNSW vector search index RAM for 768d, 1024d, 1536d, or 3072d embeddings.
Memory sizes for servers and cloud instances are usually given in binary units, where 1 GiB is 1024 cubed bytes. The default raw payload is 61.44 billion bytes, which is 57.22 GiB but 61.44 GB. Comparing a GB figure with a GiB instance size makes the index look about 7 percent smaller than it is, so stick to GiB for RAM planning. The difference grows with size.
Only through the flat 15 percent allowance. If you store chunk text, titles or JSON payloads alongside each vector and your database keeps them in RAM, they can easily exceed that margin. Estimate the average payload size per vector, multiply by the vector count, and add it to the total. Many databases let you keep payloads on disk, which avoids the problem.
It is a planning assumption, not a measurement of any specific engine. Different HNSW implementations store upper graph layers, deleted node markers and ID maps differently, and some add significant per segment overhead. Index a sample of a few hundred thousand vectors, measure the actual memory, and scale linearly. That calibrates the factor for your setup better than any generic number.
Enter 0.125, because one bit is an eighth of a byte. With the default 10 million 1536d vectors, that gives 1.79 GiB of raw vectors and 3.43 GiB in total. Binary quantization usually needs rescoring with higher precision vectors to keep recall acceptable, so check where your database keeps those originals and size that storage separately.
The links store neighbour IDs, not vector values. Each node keeps up to 2 × M integer IDs no matter how long its embedding is. That is why the overhead is 1.19 GiB at 768, 1536 and 3072 dimensions alike, for 10 million vectors at M = 16. Only vector count and M move that line.
No. The result is the steady state size once the index is built. Construction usually needs extra working memory, and some systems build a new index next to the old one during a rebuild, which briefly needs room for both. Allow extra headroom on the machine that does the build, especially for indexes in the tens of millions of vectors.
Divide the total by the number of shards to get memory per shard, then multiply by the number of copies you keep. For example, the default 67.17 GiB split across two shards is about 33.6 GiB each. With one replica of each shard, every shard exists twice, so the cluster needs the full 67.17 GiB twice over, plus operating headroom on every node.
Possibly, but that is a different calculation. Disk based approaches keep compressed vectors or graph portions in memory and read the rest from fast SSD, so RAM needs can be a small fraction of this page's figure. This calculator assumes everything sits in memory, which is the classic HNSW deployment and gives the fastest, most predictable query latency.
In millions. The field is Vector Count Millions, so 10 means 10 million vectors. Typing ten million out in full would ask for ten trillion vectors and produce an enormous result. For small collections use decimals: 0.5 is half a million. A count of zero returns an input error, and so do zero bytes per dimension or an M below 2.
No. M sets how many links each node keeps, so it affects memory, which is why it appears here. The ef parameters control how widely the algorithm searches while building or querying. They change build time, query speed and recall, but they do not add stored links. You can tune ef freely without changing the RAM figure on this page.
Not in a single run, because bytes per dimension is one value for the whole collection. Run the calculator twice, once for each part, using that part's vector count, and add the two totals. That works because every term in the formula scales with the number of vectors, so separate estimates simply add together without any correction.
The default asks a common sizing question. You have 10 million embeddings, each 1536 dimensions, stored as 4 byte float32 values, and you plan an HNSW index with M = 16. How much memory does the index need to sit entirely in RAM?
The answer is 67.17 GiB. Almost all of that is the vectors themselves. The raw payload is 57.22 GiB, the graph links add 1.19 GiB, and the engine then multiplies the sum by 1.15 to cover everything else a real process keeps in memory.
That split is the most useful thing on the page. People often assume the index structure is the expensive part, because HNSW has a reputation as a memory hungry algorithm. At these settings the graph is about 2 percent of the raw data. If you need to cut RAM, the dimensions and the bytes per dimension are where the savings are, not M.
The interpretation line spells the sum out: 57.22 GiB of vectors plus 1.19 GiB of links, plus 15% allocator and metadata overhead. If you check by hand, the first two add to 58.41, and multiplying by 1.15 gives the 67.17 total.
The formula is three steps. Raw bytes = vectors × dimensions × bytes per dimension. HNSW bytes = vectors × 2 × M × 4. Total = (raw + HNSW) × 1.15. Both byte counts are divided by 1024 cubed to give GiB.
For the default, 10 million × 1536 × 4 is 61.44 billion bytes. Divided by 1024 cubed, that is 57.22 GiB. Notice the units here. In decimal gigabytes the same data is 61.44 GB. Cloud instance memory is usually quoted in GiB, so the binary figure is the one to compare with your machine.
The link term assumes each node stores 2 × M neighbour IDs, each a 4 byte integer. With M = 16 that is 32 links and 8 × M bytes per vector. Across 10 million vectors it comes to 1.19 GiB.
The 1.15 factor is a flat allowance. It stands in for the parts of HNSW the simple link count leaves out, such as the sparser upper layers of the graph, plus allocator slack, ID mapping tables, any stored metadata and the database process itself. Real overhead depends heavily on the engine you run, so treat 15 percent as a planning margin rather than a measured figure.
It helps to think per vector as well as in total. A float32 vector of 1536 dimensions is 4 bytes times 1536, a few kilobytes each. Its links at M = 16 add 8 × 16 bytes, which is tiny by comparison. That ratio, vector bytes against link bytes, tells you at a glance which term will dominate before you run any numbers. Big embeddings at float32 are vector dominated. Small, heavily quantized embeddings with a high M can become link dominated.
Embedding size is the biggest lever you control when picking a model. The page summary lists four common sizes, 768d, 1024d, 1536d and 3072d, and I ran each with 10 million vectors at 4 bytes and M = 16.
At 768 dimensions the total is 34.27 GiB, of which 28.61 GiB is raw vectors. At 1024 dimensions it is 45.24 GiB. The default 1536 gives 67.17 GiB. At 3072 dimensions the raw payload alone is twice the default's 57.22 GiB, and the total comes out at almost exactly double the default.
The graph overhead stays at 1.19 GiB in every one of those runs. Links depend on how many vectors you have and on M, not on how long each vector is. So for larger embeddings the graph becomes an even smaller share of memory.
This is a real trade off. A larger embedding model may retrieve slightly better, but going from 1536 to 3072 dimensions doubles the memory cost. Some newer embedding models can be truncated to fewer dimensions with limited quality loss. If yours can, test retrieval quality at a shorter length before paying for twice the RAM.
The bytes per dimension field is where quantization shows up. Float32 is 4 bytes. Half precision float16 is 2 bytes, scalar INT8 quantization is 1 byte, and binary quantization packs each dimension into one bit, which is 0.125 bytes.
With the default 10 million 1536d vectors, float16 cuts the total from 67.17 GiB to 34.27 GiB. INT8 brings it to 17.82 GiB, and binary, entered as 0.125, brings it to 3.43 GiB. At that last setting the 1.19 GiB of graph links is a third of the raw size, so M starts to matter again.
The supporting line labelled Scalar INT8 RAM Equivalent always shows what 1 byte per dimension would cost, whatever you entered. It is 17.82 GiB for the default. Note that this line includes the 1.15 overhead, while the raw payload line above it does not. They are not directly comparable unless you allow for that.
Quantized indexes usually trade some recall for memory. Many vector databases keep the full precision vectors on disk and use them to rescore the best candidates, which recovers most of the accuracy. If your system does that, the RAM figure here applies to the quantized copy, and you need separate disk space for the float32 originals.
M is the maximum number of links each node keeps. Higher M generally gives better recall at a given search effort, at the cost of slower index builds and more memory. Common settings fall somewhere between 8 and 64.
Doubling M from 16 to 32 on the default doubles the graph from 1.19 GiB to 2.38 GiB and lifts the total to 68.55 GiB. At M = 64 the graph is 4.77 GiB and the total is 71.29 GiB. For 1536d float32 vectors, moving M from 16 to 64 adds only about 6 percent to the bill.
Compact or quantized embeddings tell a different story. With 768 dimensions at 4 bytes and M = 64, the raw vectors are 28.61 GiB and the links 4.77 GiB, for a total of 38.39 GiB. Quantize those same vectors to INT8 and the raw part falls to 7.15 GiB while the links stay at 4.77 GiB, giving 13.71 GiB in total. Now the graph is two thirds the size of the data. Drop M back to 16 at INT8 and the total is 9.6 GiB.
Every term in the formula is proportional to vector count, so memory grows in a straight line. The presets show it. At 6 million vectors the total is 40.3 GiB. At 10 million it is 67.17 GiB. At 15 million it is 100.76 GiB.
That straight line makes capacity planning simple. Each extra million 1536d float32 vectors at M = 16 costs about 6.7 GiB. One million alone comes out at 6.72 GiB, and 100 million at roughly ten times the default.
Plan for the size you will reach, not the size you have today. Corpora grow, documents get re-chunked, and new sources are added. Building on a machine that is already at its limit means a migration later, and HNSW builds on tens of millions of vectors are not quick. Leave headroom for growth and for rebuilding the index alongside the old one if your database needs to do that.
Deletes deserve a mention here too. Many HNSW implementations mark deleted vectors rather than removing them immediately, so a collection with heavy churn can hold more nodes in memory than its live count suggests until it is compacted or rebuilt. If you replace a large share of your vectors regularly, enter a count somewhat above your live total.
67.17 GiB of index does not mean a 64 GiB machine will almost do, or that a 72 GiB one is comfortable. The operating system, the database's query workers, caches, and any other services on the box need memory too. Search queries also allocate working memory while they run, and that rises with concurrency.
A practical habit is to keep the index well under the machine's total memory and leave room for the rest. In a cluster, divide by the number of shards and then multiply by the number of replicas, because each replica holds its own full copy of its shard.
Memory per node also depends on whether your search engine holds the index on the JVM heap, in native memory or in memory mapped files. Memory mapped indexes show up as page cache rather than process memory, and the operating system can evict them under pressure, which shows up later as slow queries rather than an out of memory error. Whichever model your database uses, the index still needs to stay resident to get the latency HNSW is chosen for, so the sizing rule is the same.
If the total is far beyond any single machine you want to pay for, the earlier sections point to the realistic options. Use a smaller embedding, quantize to float16 or INT8, or choose a disk based index type that keeps only part of the data in memory. This calculator only sizes the fully in memory HNSW case.