# What Vector Databases Actually Do

They are approximate similarity indexes wrapped in ordinary database machinery — and the approximation is where every real decision lives.

> What do vector databases actually do?

## Short answer

A vector database stores high-dimensional embeddings and returns the items whose vectors are closest to a query vector. Everything else it does — approximate indexes, metadata filters, replication, sharding — exists to make that nearest-neighbor lookup fast, filtered, and durable at a scale where scanning every vector stops being viable.

The database does not understand meaning; the embedding model does. The database solves an index problem: high-dimensional space has no ordering that keeps similar items adjacent, so it either scans everything (exact, slow) or builds a structure that usually finds the true neighbors (approximate, fast, and measurably lossy). **Recall** — the fraction of true nearest neighbors actually returned — is the number you must tune and measure, and it is invisible unless you compute it.

- **Core operation**: Approximate nearest-neighbor search
- **Exact search cost**: One distance computation per stored vector
- **Main index families**: Graph (HNSW), inverted file (IVF), quantization

## Embeddings in, neighbors out

An embedding model — not the database — converts a document, image, or query into a fixed-length list of floats, typically a few hundred to a couple thousand dimensions. The database's job is narrower: store that vector beside an id and some metadata, then answer one question fast — which stored vectors are closest to this query vector?

Closeness needs a metric. **Cosine similarity** compares direction and ignores magnitude. **Dot product** rewards direction and length, so an unnormalized long vector scores high without being more similar. **Euclidean distance** measures straight-line separation. Many systems normalize vectors at ingest so cosine and dot product converge — which is why similarity scores from two vendors rarely compare directly.

The naive implementation is exact **k-nearest-neighbor** search: compute the distance from the query to every stored vector, sort, return the top k. That is O(n·d) per query; a million 768-dimension vectors means roughly 768 million multiply-adds per lookup. It is also simple, exactly correct, and often fast enough under a few hundred thousand vectors because the inner loop vectorizes cleanly.

Ordinary indexes do not rescue this. A B-tree works because scalar values have a total order; no one-dimensional ordering of a thousand-dimensional space keeps near vectors adjacent. Classic inverted indexes keyed on words fail differently: "car" and "automobile" are distinct tokens with nearly identical vectors. So the design space collapses to a full scan or a purpose-built approximate index.

> The embedding model supplies the meaning. The database only supplies the geometry.

## Why the index is approximate

**HNSW** builds a multi-layer proximity graph: sparse upper layers for long jumps, a dense bottom layer for fine neighbors. A query enters at the top, greedily walks to the closest node, drops a layer, and repeats. A parameter usually called `ef_search` sets how wide a candidate list the walk keeps; raising it explores more of the graph, raises recall roughly monotonically, and costs latency.

**IVF** runs k-means over the vectors and files each one under its nearest centroid. A query compares against centroids and scans only `nprobe` of those lists. Memory-light and cheap to build, but lossy: a true neighbor sitting in an unprobed list is never seen.

**Product quantization** attacks memory instead. Split each vector into subvectors, replace each with a short centroid id, and a 4 KB float vector becomes tens of bytes. Distances become approximations computed from lookup tables. IVF-PQ combines both and is the standard way to hold a billion vectors in RAM.

The unifying trade is **recall against latency, memory, and build time**. A density-aware routing paper reports 0.974 Recall@10 at 0.09 ms per query uncompressed, and 0.997 Recall@10 at 0.341 ms with 32-byte compressed codes on SIFT1M . Read that as the shape of the curve, not a portable number — results shift with dataset, dimensionality, and tuning.

Index choice also fixes what is cheap later. HNSW keeps the whole graph resident; IVF stays small but degrades when clusters are non-convex . Deletes are usually tombstones, so sustained churn degrades graph quality until a rebuild.

> Note: Published recall figures are almost always dataset-specific. Treat any vendor recall claim as a hypothesis to test on your own vectors.

## Filters break the index, and hybrid search repairs the ranking

Real queries are rarely "nearest neighbor in the whole corpus". They are "nearest neighbor among documents this user can see, in this locale, newer than a year". That predicate interacts badly with graph indexes, and where the filter is applied changes the answer, not just the speed.

Azure AI Search names three modes . **preFilter** applies the filter during HNSW traversal on each shard: highest recall, but a highly selective filter forces the walk to traverse more of the graph, raising CPU and latency. **postFilter** runs unfiltered traversal per shard and filters afterwards, then merges shard top-k — prone to false negatives for selective filters or small k. **strictPostFilter** takes the unfiltered global top-k first and filters last: cheapest, highest false-negative risk, and with a selective filter and small k it can return nothing at all. AlloyDB's optimizer picks among pre-filtering, post-filtering, and inline filtering that consults ordinary B-tree and GIN indexes alongside the vector scan .

A smaller engine exposes the same decision as a number: below a `prefilter_cardinality_threshold` (default 10,000 matching vectors) it abandons the graph and brute-forces the filtered subset . **When the filter is selective enough, exact search wins.**

**Hybrid search** fixes a different weakness. Dense vectors capture paraphrase but fumble product codes and rare names, which BM25 nails. Reciprocal rank fusion merges both lists with `w/(k + dense_rank) + (1−w)/(k + sparse_rank)`, typically k of 60 — and it works because RRF consumes ranks, not raw scores, so incomparable scales never need calibration . A reranker over the fused top-N then buys precision the first stage cannot.

> Where you apply the filter is a correctness decision disguised as a performance setting.

## Writes, deletes, shards, and the re-embedding problem

The similarity computation is the cheap part. What makes a vector store a database is everything around it.

**Durability.** Vectors and payloads are logged or written to object storage before a write is acknowledged; the index itself is typically an immutable segment or a rebuildable structure, snapshotted and compacted on a schedule. Recovery therefore does not require re-embedding the corpus — but a cold index build takes hours where a restore takes minutes.

**Sharding.** Large collections split across shards, each with its own index. A query fans out to every shard and a coordinator merges the local top-k lists into a global top-k . Two consequences: latency is set by the slowest shard, and recall is per-shard — a partition that misses a neighbor cannot be rescued downstream. Distributed scatter-gather designs report that recall survives partitioning only when every partition is tuned, not just the aggregate .

**Updates and deletes.** Appending is easy. Changing a vector inside a graph means re-linking edges, so most systems tombstone the old entry and insert a new one, fragmenting the graph and inflating memory until a rebuild. Batch heavy churn into off-peak windows rather than streaming constant mutation.

**Model changes.** Swapping the embedding model invalidates every stored vector. Re-embedding millions of documents, backfilling a second vector column, and cutting over is usually the largest project in a vector search deployment — larger than choosing the index. Budget for it at design time by storing source text and model identity next to each vector.

> Note: Index build time, not query latency, is usually what surprises teams after the first data load.

## Where it earns its keep, and the four places it fails

Vector search pays off when queries are fuzzy and the candidate pool is large: semantic search over support articles, image similarity, near-duplicate detection, recommendation candidates, and retrieval-augmented generation where a model needs the right few paragraphs out of hundreds of thousands.

A concrete pipeline: chunk each support article, store each chunk with product line, locale, and last-reviewed date as metadata, embed it, then at query time retrieve a wide top-50 with a pre-filter on product line and a freshness cutoff, rerank, and pass the top 5 to the model. The dominant failure is not the model — it is a chunk boundary that split a policy in half, or a filter that excluded the one document containing the exception. Retrieval quality is measurable engineering, not a property you purchase.

Four boundaries matter.

- **Small corpora do not need an ANN index.** Below roughly a hundred thousand vectors, an exact scan is often single-digit milliseconds and exactly correct. Adding HNSW there buys risk with no payoff.
- **Similarity is not truth.** The store returns text that reads like the query. It has no mechanism for checking that the text is accurate, current, or applicable — that belongs to the filter, the reranker, or the model.
- **Embeddings drift.** Product names, slang, and domain vocabulary move. A frozen model degrades quietly and nothing on the dashboard turns red.
- **Recall is unmeasured by default.** You learn what the index missed only by keeping a ground-truth set: exact k-NN over a sample, compared against what the approximate index returned.

Measure recall@k before optimizing latency. A fast index that silently drops the right answer is worse than a slow one that finds it.

> A fast index that silently drops the right answer is worse than a slow one that finds it.

## Common misconceptions

- **Myth:** A vector database understands what your content means. **Reality:** The embedding model encodes meaning into coordinates before the database ever sees the data. Swap the model and the same database returns different neighbors for the same query — the semantics live upstream, and the database only compares geometry.
- **Myth:** Approximate search is just a faster version of exact search. **Reality:** Approximation means the true nearest neighbor may never be visited. That is a recall loss you can tune downward in latency terms or upward in accuracy terms, but not eliminate — and you only know its size if you keep a ground-truth sample.
- **Myth:** Adding a metadata filter silently narrows the results correctly. **Reality:** Filter placement is a correctness decision. Post-filtering a per-shard top-k can return false negatives, and strict post-filtering with a highly selective filter and small k can return an empty result even though matching documents exist .

## FAQ

### Which component supplies the semantic meaning in a vector search system?

The database only compares coordinates. Meaning is baked in by the embedding model, which is why swapping models changes results and forces re-embedding.

### A 50-million-vector collection is filtered down to 400 matching documents, and the query asks for the top 5. Which strategy is likely both fastest and most accurate?

Post-filtering variants drop true neighbors when the filter is selective and k is small. With only 400 candidates, brute force is trivially cheap and exactly correct — the threshold behavior engines like endee encode explicitly .

### Why does hybrid search fuse BM25 and vector results with reciprocal rank fusion rather than adding their scores?

BM25 scores and cosine similarities live on unrelated scales. RRF converts both to ranks before combining, which sidesteps calibration entirely  — it changes the fusion, not the underlying retrieval quality.

### How much recall do production systems actually give up once metadata filters, deletes, and sharding are all in play?

Vendor recall claims are measured on clean, unfiltered, static datasets. The real-world number is what determines whether retrieval silently fails.

### Is re-embedding or index rebuild the larger recurring cost over a system's lifetime?

It decides whether you should optimize the vector index or the document pipeline that feeds it.

---

Delve Editorial · https://delve.prisflow.com/p/vector-databases-explained
