Brute Force and When It's Enough

The most underrated vector index is no index at all. Brute-force search — compare the query to every vector — is the one method with perfect recall, zero build time, and no tuning, and for a surprising number of real systems it's not just adequate but optimal. Knowing when you don't need an ANN index is as valuable as knowing how they work.

Before the clever algorithms, honor the baseline. Brute-force search (also called flat or exact search) computes the distance from the query to every stored vector and returns the closest — the exact kNN from the first post. It’s the method every approximate index is measured against, and, crucially, it’s the right choice more often than the hype around vector databases suggests. This post covers how it works, its real performance, and the genuine cases where reaching for an ANN index is premature optimization.

How flat search works

There’s almost nothing to it, which is part of the appeal:

for each stored vector v:
    d = distance(query, v)      # using your chosen metric
keep the K smallest distances   # e.g. a bounded heap
return those K vectors

No index structure, no build step, no parameters. You store the vectors (a “flat” list) and scan them at query time. This simplicity has real virtues that the fancier methods sacrifice:

Brute force is the gold standard for correctness — which is also why it’s used to measure ANN recall (you compare an ANN index’s results against brute-force ground truth). The only thing it lacks is speed at scale, which is the whole reason ANN exists.

Its real performance

The cost is O(N × d) per query, as the first post noted — linear in the number of vectors. The practical question is: at what scale does that become too slow? And the answer surprises people, because modern hardware computes distances very fast:

The exact crossover depends on your dimension, hardware, latency budget, and query rate — but the key realization is that it’s higher than most people assume. Vectors are compared with highly optimized math, and a modern machine can scan a lot of them per second. Many systems that reach for a vector database would be perfectly served by brute force.

When brute force is the right call

Reaching for an ANN index has real costs — build time, memory overhead, tuning, imperfect recall, update complexity — so brute force is genuinely better when those costs outweigh the speed you don’t yet need:

The recurring theme, consistent with the AI Architecture Decisions reasoning: don’t add infrastructure you don’t need. An ANN index (or a dedicated vector database) is justified by scale; below that scale it adds complexity, tuning burden, and imperfect recall in exchange for a speedup you won’t notice.

When you’ve outgrown it

Brute force stops being the answer when its linear cost genuinely hurts:

At that point you accept approximate results (the ANN trade from post one) to buy speed — and the next posts cover the two dominant ways to do it: IVF (partition and search part) and HNSW (navigate a graph). But adopt them because a measurement told you to, not because vector search “should” use a fancy index. The mark of good engineering here is starting simple and escalating on evidence.

Key takeaways

Further reading

Sources & References

Exact search baseline