DiskANN is a graph-based approximate nearest neighbor (ANN) index designed to store most of its data on a solid-state drive (SSD) instead of in main memory, so that a single server can search billions of vectors with high recall and low latency. In the field of Retrieval & knowledge within artificial intelligence, it serves as the engine behind large semantic search and retrieval-augmented generation systems whose embedding collections are too large or too expensive to hold entirely in RAM.
The approach was introduced by Microsoft Research in 2019 together with its core graph construction algorithm, Vamana. Its central idea is simple: keep a compressed copy of every vector in memory to guide the search, keep the full-precision vectors and the graph on disk, and design the graph so that a query needs only a few dozen SSD reads to reach its nearest neighbors.
How DiskANN searches vectors stored on SSD
DiskANN answers a query by walking a proximity graph in which each vector is a node connected to a limited number of nearby nodes. The walk starts at a fixed entry point, usually a node close to the dataset centroid, and repeatedly moves toward neighbors that are closer to the query until no further improvement is found.
The distinctive part is the memory and disk layout. Each node’s full-precision vector and its adjacency list are stored together in one SSD sector of about 4 KB, so a single read returns both the exact vector and the list of neighbors to explore next. Distances used for steering are computed against product-quantized (PQ) codes held in RAM, which are cheap to evaluate but approximate.
To hide SSD latency, DiskANN uses beam search: in each step it fetches the adjacency lists of several promising candidates in parallel rather than one at a time. At the end, the exact vectors already read from disk are used to re-rank the candidates with full-precision distances, which recovers the accuracy lost to compression.
| Component | Storage location | Role in a query |
|---|---|---|
| PQ-compressed vectors | RAM | Fast approximate distances to steer the walk |
| Graph adjacency lists | SSD | Define which nodes to visit next |
| Full-precision vectors | SSD, same sector as the node | Exact re-ranking of final candidates |
| Entry point and cached nodes | RAM | Shorten the first hops of every search |
The Vamana graph and its build parameters
Vamana is the algorithm that builds the DiskANN graph, and its purpose is to create a flat, single-layer graph with a small diameter so that searches converge in few hops. It starts from a random graph and refines it in two passes, each time running a greedy search for every point and pruning the resulting candidate neighbors.
The key innovation is alpha-based pruning. A standard relative-neighborhood rule discards a candidate neighbor when another selected neighbor is closer to it; Vamana relaxes this rule with a factor alpha greater than 1, which keeps some long-range edges. These long edges let a search cross the dataset quickly, which matters more on disk than in memory because every hop costs an SSD read.
The following table lists the parameters practitioners tune most often and the typical ranges used in published configurations and vector databases.
| Parameter | Typical range | Effect of a higher value |
|---|---|---|
| R (maximum degree) | 32 to 128 | Better recall, larger index, slower build |
| L build (candidate list size) | 75 to 200 | Higher graph quality, longer build time |
| Alpha (pruning factor) | 1.0 to 1.4 | More long-range edges, fewer hops per query |
| L search (search list size) | 50 to 300 | Higher recall, more SSD reads, higher latency |
| Beam width W | 2 to 8 | Fewer round trips, more reads per step |
| PQ code size | 16 to 128 bytes per vector | More accurate steering, more RAM used |
DiskANN compared with HNSW, IVF and exact search
DiskANN differs from other ANN methods mainly in where the index lives and therefore in its cost profile. HNSW builds a multi-layer graph that performs excellently but expects all vectors and edges in RAM. An IVF index partitions vectors into clusters and scans only a few of them, which works on disk but usually needs more reads per query for the same recall. Exact nearest neighbor search compares the query with every vector and becomes impractical at large scale.
| Method | Primary storage | Strength | Main limitation |
|---|---|---|---|
| DiskANN | SSD plus compressed RAM | Billion-scale search on one node | Depends on fast NVMe SSD |
| HNSW | RAM | Very low latency and high recall | Memory cost grows with full vectors |
| IVF with PQ | RAM or disk | Simple, fast to build | Recall drops with heavy compression |
| Exact search | RAM or disk | Perfect recall | Linear cost per query |
The practical consequence is memory economics. A billion 768-dimensional float32 embeddings occupy roughly 3 TB in full precision, while a DiskANN index can keep only compressed codes of about 32 to 64 GB in RAM and place the rest on SSD that costs far less per gigabyte.
Variants and use in retrieval systems
The original DiskANN assumed a static dataset, so several variants extend it for production retrieval. They address updates, filtering and integration with database engines, which are common needs in retrieval-augmented generation (RAG) pipelines.
- FreshDiskANN supports inserts and deletes by buffering changes in an in-memory graph and merging them into the SSD index in the background.
- Filtered-DiskANN builds label-aware edges so that metadata filtering does not break graph navigability.
- In-memory Vamana uses the same graph without SSD and competes directly with HNSW.
- Several vector databases and PostgreSQL extensions offer DiskANN-style indexes, sometimes with their own compression schemes.
Choosing DiskANN is mostly a question of scale, budget and latency target. The decision table below summarizes common situations.
| Situation | Recommended choice | Reason |
|---|---|---|
| Under 10 million vectors, ample RAM | HNSW or in-memory index | Lowest latency, simple operation |
| Hundreds of millions to billions of vectors | DiskANN on NVMe SSD | Avoids terabytes of RAM |
| Frequent inserts and deletes | FreshDiskANN or database integration | Static build would go stale |
| Strict tenant or label filters | Filtered-DiskANN | Keeps recall under restrictive filters |
| Storage on network disks only | IVF or managed service | High disk latency hurts graph hops |
Limitations and common mistakes
DiskANN performs well only when its hardware assumptions hold. It expects local NVMe SSDs with high random-read throughput; on network-attached or spinning disks, each hop can take milliseconds and query latency grows sharply. Index construction is also memory and time intensive, although the build can be split into overlapping partitions that are merged afterward.
| Symptom | Likely cause | Fix |
|---|---|---|
| Latency far above a few milliseconds | Slow or shared storage | Move the index to local NVMe |
| Recall below target | L search or PQ code too small | Raise L search or code size |
| Results ignore filters | Post-filtering after search | Use filter-aware indexing |
| Stale results after updates | Static index never rebuilt | Use a fresh index or rebuild schedule |
A frequent misconception is that DiskANN is slower by nature because it uses disk. With a well-built graph and beam search, published benchmarks report over 90 percent recall at a few milliseconds per query on a single node, although results depend strongly on dataset, dimensionality and hardware. Another mistake is treating its recall as exact: like every ANN method, it trades a small accuracy loss for large gains in speed and cost.
Put simply
DiskANN is a way to find similar items in a huge collection without keeping the whole collection in a computer’s fast memory. It keeps a small summary of every item in memory and the detailed versions on a fast storage drive.
Think of a large library with a pocket map. The map in your hand is rough, but it tells you which shelves are worth visiting. You walk to only a handful of shelves, check the exact books there, and pick the best matches. The key benefit is that one ordinary server can search billions of items quickly and at a much lower cost than a memory-only system.
In practice
A legal research provider wants a RAG assistant over about 800 million text chunks, each stored as a 1,024-dimensional embedding. Keeping these vectors in RAM with an in-memory graph would require several terabytes of memory spread across many servers, which the team judges too costly.
The engineers build a DiskANN index with a maximum degree of 64, alpha set to 1.2 and 64-byte PQ codes, and place it on two local NVMe drives in a single server with 256 GB of RAM. At query time they use a search list size of 120 and a beam width of 4, then pass the top 50 candidates to a cross-encoder reranker.
In internal tests, the index reaches recall of about 95 percent at 10 results with median latency near 4 milliseconds. The assistant now answers questions from the full archive while the hardware cost falls to a fraction of the memory-only design.