What problem does DiskANN solve that HNSW does not, and when do you reach for it?
DiskANN stores the graph on SSD with a small in RAM PQ summary. Use it when corpus × dim outgrows RAM and the workload tolerates 5-15ms per query.
Think of DiskANN like a library that lives in a warehouse instead of on your desk. HNSW is fast because the whole map and every book sit on your desk (RAM), but desks are tiny and expensive, and a billion books will never fit. DiskANN is a clever redesign that lays the map out on a fast warehouse shelf (the SSD) so that grabbing a book pulls a whole nearby section at once (SSDs love sequential reads). A tiny index card on your desk tells the search which warehouse aisle to walk to, so each lookup only fetches a few shelves. The result: you can hold a billion items on one fancy laptop's SSD instead of renting a rack of RAM-stuffed servers, at the cost of each lookup taking 5-15 milliseconds instead of being instant.
Detailed answer & concept explanation~5 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
6 min: the Vamana graph and SSD layout, the PQ-in RAM filter, the cost versus latency tradeoff, and the right and wrong workloads for billion-scale DiskANN.
| Property | HNSW | DiskANN |
|---|---|---|
| Primary storage tier | RAM | SSD |
| In-RAM footprint per vector | 4 × d + graph edges | PQ code (~64-128 bytes) |
| Typical query latency | Sub-millisecond | 5-15 ms |
| Sweet-spot scale | 1M-100M vectors | 100M-10B vectors |
| Write cost | Cheap incremental | Expensive (rebuild flavored) |
| Cost per billion vectors | Very high (RAM) | Moderate (SSD + small RAM) |
Real products, models, and research that use this idea.
- Microsoft Bing uses DiskANN internally for enterprise document search at hundreds of millions of documents.
- Milvus ships DiskANN as an opt in index type for billion-scale workloads where RAM is not feasible.
- Vespa exposes a disk resident ANN mode for large scale ranking workloads with relaxed latency SLOs.
- Turbopuffer's object storage-backed architecture extends the DiskANN insight further, with S3 as the cold tier and per query latency in the 50-200ms range.
- Azure AI Search ships an exhaustive or approximate hybrid that uses DiskANN style on disk graphs for large indexes.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow does the PQ summary in DiskANN avoid spurious SSD reads during graph traversal?
QWhy does Turbopuffer's S3-backed design accept much higher latency than DiskANN's SSD-backed design?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating DiskANN as a GPU variant or a recall improvement over HNSW. It is neither; it trades latency for storage cost by moving the index to SSD.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.