Vector DB & ANN · core

Brute-Force Vector DB

Exact nearest-neighbour search by scanning every vector — the correctness baseline.

vector-dbann

Mental model

Brute force computes the metric against every stored vector. It is O(n·d) and slow at scale, but it is exact — making it the recall=1.0 baseline that every ANN index is measured against.

How to study Brute-Force Vector DB

Begin by restating the mental model in your own words, then connect it to a concrete system you have built or operated. Name the mechanism, the constraint it addresses, and the trade-off it introduces. Use FAISS — Getting started to check details, but close the source before writing your explanation. Retrieval is the learning step; rereading is only preparation.

Next, compare Brute-Force Vector DB with HNSW, Metadata Filtering. Ask what changes in correctness, latency, resource use, operability, and failure recovery. Complete Build a brute-force vector index and preserve the command, input, output, and one failed attempt as evidence. Finish by explaining the idea without jargon to someone who has not studied the track.

Proof of understanding

  • Explain the mechanism from first principles and identify the state it reads or changes.
  • Give one situation where the concept is the right choice and one where it is not.
  • Predict a realistic failure mode before running the drill, then compare the prediction with evidence.
  • Connect the result to a roadmap or build artifact instead of treating the concept as isolated trivia.

Where it matters

FAISS IndexFlat, the ground-truth oracle for ANN benchmarks.

Common mistakes

  • Skipping the brute-force baseline, so ANN recall is unmeasurable
  • Not batching the matrix multiply for the scan
  • Assuming brute force is always too slow — it is fine for <100k vectors

Learn from primary sources

Practice and explain it back

Build a brute-force vector index

Build an index that stores vectors and answers top-k queries by scanning every vector. Benchmark latency as the vector count grows.

Expected evidence: Exact top-k results; a latency-vs-n table.

Open the interactive drill →

Review prompts

  • Why is a brute-force index essential even though it is slow?

Build evidence

Brute-force vector index

An exact nearest-neighbour index — the recall=1.0 baseline.

  • Insert and search vectors with a chosen metric
  • Return correct top-k via a k-sized heap
  • Benchmark query latency vs vector count

Metadata filtering for vector search

Add structured predicate filtering to vector search.

  • Support 'nearest WHERE field = value' queries
  • Implement both pre-filter and post-filter and compare
  • Always return k results when k are available

Prerequisites

Related concepts

Learning paths