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%

Red rings are true nearest neighbours the index missed, because they sit in a list it did not search. Raise nprobe to find them, at the cost of more checks.

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

Question 1

1.Your index returns 8 of the true 10 nearest neighbours. What is recall@10?

Question 2

2.In an IVF index, what does raising nprobe do?

Question 3

3.A customer must never see another customer's documents in search results. What do you use?

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

Tip: answer every quiz question correctly first.

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.