Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Larger M means: recall climbs (denser graph reaches more true neighbors), memory climbs (M pointers per node), build time slows (each insert does more neighbor lookups), and query latency rises modestly (more
Think of the HNSW graph like a social network where every person keeps a contact list of close friends, and M is the size of that list. **More friends per person** means it's easier to walk across the network to find any particular face (better recall), but each person's contact list takes more storage (more memory), and adding new people takes longer because you have to figure out who their best friends should be (slow build). Searching takes a tiny bit longer too because at each step you have to glance at more friends. **Fewer friends per person** is the opposite: smaller, faster to build, but you might get stuck because there's no good path to the person you want.
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.
3 min: name the four monotonic relationships + reject the distractors + cite typical production M range + connect to recall ceiling concept.
| M value | Memory overhead (per 100M nodes) | Build time (100M, well parallelized) | Typical recall@10 (well tuned ef_search) | Use case |
|---|---|---|---|---|
| 8 | ~6 GB | ~20 min | ~0.88 | Memory-constrained tiny corpora |
| 16 | ~13 GB | ~40 min | ~0.92 | General-purpose default |
| 32 | ~26 GB | ~80 min | ~0.95-0.97 | Production RAG |
| 48 | ~38 GB | ~2 hr | ~0.97-0.98 | High-stakes retrieval |
| 64 | ~51 GB | ~3 hr | ~0.98-0.99 | Extreme recall, diminishing returns |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Confusing M (build time, per node graph degree) with ef_search (query time, candidate-list size). They both affect recall and latency but live on opposite sides of the build/query line and respond very differently to changes.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.