VFlash: Fast, Accurate Visual Planning via Flash Primitive Decoding
u_Unrolled
D8: RAG & Knowledge Systems · Vector Databases — Finding Nearest Neighbours Among Millions
Phase 5/Domain 8/Lesson 5

Vector Databases — Finding Nearest Neighbours Among Millions

20 min read·Advanced· Unrolled Pro
Vector Databases — Finding Nearest Neighbours Among Millions

You already know: embeddings, normalization and quantization (Embeddings); k-means (D3 Unsupervised learning); heaps and graphs (D1 Data structures); memory hierarchies and paging (D1 Operating systems); tombstones and compaction (Retrieval fundamentals exercise).

Why this matters for Atlas. Finding the nearest vectors exactly means comparing the query with every stored vector. That's fine for thousands of vectors and hopeless for hundreds of millions. Approximate nearest neighbour (ANN) indexes give up a little recall for orders of magnitude in speed and memory, and a vector database wraps them with what production needs: metadata filters, updates, deletes, persistence, replication and sharding. Picking and tuning one is a set of trade-offs you can measure. This lesson builds the three core index families from scratch.


1. Why exact search doesn't scale

The question. How expensive is "compare the query with everything"?

Start from nothing. Exact search does N dot products of dimension d per query, so cost grows linearly with both. Here it is measured on this machine and extrapolated:

That's the preview. The full lesson, with its code and exercises, is part of Unrolled Pro.
Staff AI & Pro Tier Lesson

Unlock "Vector Databases — Finding Nearest Neighbours Among Millions"

The foundations are free forever. Unrolled Pro unlocks the complete lesson, production architectures, and 55 battle-tested ML system design case studies.

Everything included with Pro:
All 234+ Deep-Dive Lessons across transformer internals, inference, RAG & agents
55 Staff-Level ML & System Design Case Studies with mathematical capacity estimates
AI Engineer Sheet & Exercises with worked solutions, self-checks, and code
100 Landmark Research Papers guided walkthroughs & progress tracking
14-Day Money-Back Guarantee — 100% full refund if you aren't satisfied
View Plans & Unlock All Lessons

From ₹167/mo (~$2/mo) · Cancel anytime · Instant activation

100% Risk-Free: 14-day no-questions-asked money-back guarantee
Build Atlas · Part 7 of 9: Ground it in your documentsUse this lesson in the project: Chunk the lessons by structure, search them with BM25 and dense vectors, fuse the rankings, and measure retrieval apart from answers.