Module 4 · Vector Databases · Lesson 10 of 34
Vector databases and fast search
Why brute force does not scale, how approximate indexes trade recall for speed, and what else a vector database stores.
In this lesson · about 18 minutes
- Explain why exact nearest-neighbour search is slow at scale
- Describe how an inverted-file (IVF) index and HNSW speed up search
- List what a vector database stores besides vectors, and how to choose one
Finding the closest vectors the obvious way, brute force, means comparing the query with every stored vector. Fine for 10,000 documents. With 50 million, each search would do 50 million comparisons of 1,000 numbers each. Far too slow for a chat reply.
Vector databases use approximate nearest neighbour (ANN) indexes. They skip most of the data and accept that, now and then, they miss a true neighbour. Two common designs:
- IVF (inverted file): group the vectors into clusters ("lists") once, ahead of time. At search time, find the few cluster centres nearest the query and only look inside those lists. The setting nprobe says how many lists to search.
- HNSW (hierarchical navigable small world): link every vector to some near neighbours, in layers like a road map with motorways and side streets. A search starts on the motorway layer and zooms in. Very fast and accurate, but uses more memory.
Speed against accuracy is measured with recall@k: of the true k nearest neighbours, how many did the index return?
Try it · simulator
Fast search: an approximate-nearest-neighbour index
240 vectors in 2-D. The index groups them into lists, then searches only the lists nearest the query. Click to search, then trade speed against recall.
Recall
20%
Distance checks
25
Brute force checks
240
Work saved
90%
Sorting drill
Speed or recall?
For each change, does it mainly make search faster, or find more of the true neighbours?
- Raise nprobe from 2 to 10
- Search only the single nearest list
- Switch from an ANN index to brute force
- Filter to the user's own 2,000 documents first
0 of 4 sorted
Check your understanding0 of 3 correct
Plan the searchable knowledge for your project.
Consider these questions and write down your thoughts. What you write stays on this device.
Quiz score: 0 of 3
Written by Noviq Academy in its own words. The simulators are small teaching models that keep the real idea and leave out the scale; their numbers (prices, speeds, scores) are illustrative. Model names, prices and features change quickly, so check your provider's current documentation before you build. Read-aloud uses your device's built-in voices.