Skip to content

Part 8 · Blueprint 51

Vector Database Internals (Milvus / Qdrant / pgvector Scale)

15 min reading · Sources · Editorial review pending

Approximate retrieval and authorization filtering can interact to reduce eligible recall.

More
20px
Reading list
Page details

Published date · Last edited:

Draft edition. Editorial review and supplementary reading recommendations are still being completed.

Format: Architecture walkthrough. Prerequisites: the beginner bootcamp. Chapter prerequisites: Indexes & Storage Engines: B-Trees vs. LSM Trees, Search Engine & Real-Time Typeahead, Enterprise RAG System Architecture & Failure Modes.

Sixty-second mental model

Problem: Approximate retrieval and authorization filtering can interact to reduce eligible recall.

Use: Measure recall under the actual filter and update distribution.

Design boundary: Retrieve approximate nearest neighbors under a defined distance, corpus and permission scope. Index tuning trades work/memory against measured recall; approximate similarity is not a correctness guarantee for the downstream answer.

Layer 1 · Intuition

Hypothetical scenario: Northwind is designing vector indexes. Maya represents product requirements, Dev implementation and Priya reliability. The team must agree what one vector means and which component owns the embedding and filter versions.

Think of a map that finds approximate neighboring coordinates. Separate the requester from embedding and filter versions, then identify the retained evidence needed after failure.

Authority
The entitled state owner.
Invariant
A rule preserved across concurrency and failures.
Vector database
A data service supporting storage and retrieval of vectors, often with approximate similarity indexes and metadata. Analogy: A library that can find nearby meaning-coordinates.

Architecture and worked reasoning

Design boundary: Retrieve approximate nearest neighbors under a defined distance, corpus and permission scope. Index tuning trades work/memory against measured recall; approximate similarity is not a correctness guarantee for the downstream answer.

Responsibilities on the request path

Vector indexes: responsibilities and request directionRetrieve approximate nearest neighbors under a defined distance, corpus and permission scope. Index tuning trades work/memory against measured recall; approximate similarity is not a correctness guarantee for the downstream answer.Embedding versionsVector indexFiltered searchRecall evaluation
Retrieve approximate nearest neighbors under a defined distance, corpus and permission scope. Index tuning trades work/memory against measured recall; approximate similarity is not a correctness guarantee for the downstream answer.

Workload and limiting resource

Hypothetical 1,000,000 vectors × 768 dimensions × four bytes = 3.072 GB raw before graph/allocator/metadata overhead. Returning 20 approximate neighbors from that corpus does not establish recall; compare with the exact top-20 for sampled queries under the same filters.

Keep the units attached to each intermediate result. The assumptions above describe a hypothetical exercise, not observed vendor capacity. A real capacity decision also needs a measured service curve, skew, recovery traffic and an explicit admission policy for overload.

Mutation or publication path

Vector indexes: mutation boundaryBind vectors to source and embedding version. Then: Build or update the chosen ANN structure. Then: Publish a coherent index and deletion lifecycle.Step 1
Bind vectors to source and embedding version.
Step 2
Build or update the chosen ANN structure.
Step 3
Publish a coherent index and deletion lifecycle.
Bind vectors to source and embedding version. Then: Build or update the chosen ANN structure. Then: Publish a coherent index and deletion lifecycle.
  1. Bind vectors to source and embedding version.
  2. Build or update the chosen ANN structure.
  3. Publish a coherent index and deletion lifecycle.

Observation and recovery path

Vector indexes: observation boundaryApply required scope constraints. Then: Search with a bounded effort setting. Then: Evaluate returned candidates against an exact baseline on a representative sample.Step 1
Apply required scope constraints.
Step 2
Search with a bounded effort setting.
Step 3
Evaluate returned candidates against an exact baseline on a representative sample.
Apply required scope constraints. Then: Search with a bounded effort setting. Then: Evaluate returned candidates against an exact baseline on a representative sample.
  1. Apply required scope constraints.
  2. Search with a bounded effort setting.
  3. Evaluate returned candidates against an exact baseline on a representative sample.

Failure that changes the decision

Hypothetical scenario: A deleted or unauthorized vector remains reachable in an old graph generation. Enforce source eligibility even when physical collection is delayed.

Attempt this decision before reading the explanation

Does increasing top-k always repair filtered retrieval quality?

No. Candidate search effort, filter selectivity, topology and ranking all matter. Measure filtered recall and latency under realistic scopes rather than treating a larger result count as proof.

Supporting mechanism analysis

Hypothetical scenario: Northwind. Maya represents product, Dev implementation and Priya reliability. The following workflow develops the underlying mechanism.

Hypothetical scenario. Northwind’s chosen chunks make the vector collection larger. Dev proposes approximate search to avoid scoring every vector. Maya wants to know whether a faster lookup still finds the passages her questions require.

You will distinguish exact KNN, HNSW graph navigation and IVF list probing, then derive candidate work and storage under stated assumptions. Evaluate candidate recall before asking a later ranker to repair missing evidence.

Before you continue: A relevant vector lies in an IVF list the query never probes. Can reranking only the returned candidates recover it?

A reranker can reorder its inputs, but the missing vector is outside that input set. This failure occurs during candidate generation, before pair scoring can help.

This targets the failed boundary. Compare recall under the actual filter and adjust the index or search budget before judging the reranker on candidates it never received.

An IVF index assigns vectors to coarse partitions and stores their identifiers in inverted lists. A query probes selected lists and compares vectors within them. Probe count trades candidate work against the chance of excluding a relevant vector. In contrast, HNSW navigates a proximity graph. Neither approximation removes the need for exact-search reference cases and permission-aware evaluation. The Faiss IndexIVF reference describes this inverted-list structure.

Hypothetical scenario. Assume 10,000 vectors distributed evenly across 100 lists. Each contains 10,000/100 = 100 vectors. Probing four lists compares approximately 4 × 100 = 400 candidate vectors instead of 10,000. Uneven lists and coarse-assignment work change this estimate. A relevant vector in an unprobed list cannot be recovered by reranking the 400 candidates. Measure recall on declared queries; candidate reduction is not evidence of unchanged answer quality.

Hypothetical scenario. Dev proposes faster search, but Priya needs to know which relevant passages disappear.

In short. Compare approximate results with an exact baseline. Measure recall under the permitted filter.

Hypothetical scenario. A library has searchable vectors for its handbook passages. Exhaustive scoring gives useful results, but the team expects more documents and concurrent requests. It replaces the scan with a graph index. Queries become faster in a small trial, while a passage needed for an exception disappears from some results. Was the representation wrong, the graph search incomplete, or the source absent?

A vector index organizes vectors to support a search rule. Some approaches examine every eligible vector; approximate methods aim to avoid some work while accepting that they may miss neighbors that exhaustive scoring would return. To assess that trade-off, first define the reference result and the workload.

Hypothetical scenario. Define a query and the currently eligible vector set before comparing exact KNN, HNSW and IVF. The exact result over that set is a reference for neighbor recall; it is not itself a relevance label.

HNSW traverses a graph of candidate relationships; IVF chooses coarse partitions and searches selected lists. Their tuning parameters trade work for candidate coverage under the chosen data and filter behavior. Post-filtering a small approximate set can miss eligible neighbors even when the unfiltered recall looks good. Keep encoder and distance identity fixed in the comparison, measure filtered recall and inspect skew and update behavior. A storage payload calculation excludes graph links, list metadata, replicas and runtime workspace unless separately counted.

“The collection is large” is incomplete. Work depends on vector count, dimension, eligible scope, scoring rule, request rate, hardware, batching, and the target latency distribution. A scan can be a good baseline even if a later design needs acceleration. An approximate index can be a poor choice if its maintenance or memory cost exceeds the value of saved query work.

Nor does an exact nearest neighbor mean the correct answer passage. Exactness refers to the chosen vectors and score. If the representation ranks irrelevant material first, reproducing that ranking perfectly does not solve relevance. Keep approximation error separate from semantic retrieval error.

The HNSW paper describes a graph-based approximate nearest-neighbor method. Evaluate recall against the exact reference under the same corpus and score function; a faster candidate search does not establish that it always returns the exact highest-scoring set.

An exact top-k reference needs a fixed corpus revision, the same eligible documents, a scoring rule, a value of k, and a tie policy. Here, “eligible” includes the request's access and scope restrictions. A comparison against unrestricted global neighbors is not a valid reference for a restricted request.

A flat scan scores all eligible vectors and selects the best results. Approximate designs organize a route through the collection: a partitioning method can examine selected regions, while a graph method follows connections between vectors. Quantization can reduce representation size or scoring work while introducing another approximation. These techniques can be combined, but their effects should be evaluated separately where possible.

Malkov and Yashunin's HNSW paper describes a hierarchy of proximity graphs. Upper levels contain subsets of elements; a search navigates through that hierarchy before a broader search near the bottom. It is not an ordinary sorted index with a guarantee of exact nearest neighbors.

Graph connectivity and construction effort affect the built structure; query-time search effort affects how extensively it is explored. Implementations commonly expose controls such as M, efConstruction, and efSearch, but their supported ranges and exact behavior belong to the chosen implementation. More exploration can improve measured neighbor recovery at extra work; it does not establish a universal latency or recall guarantee.

Hypothetical scenario. Store N = 100,000 vectors, each with d = 128 coordinates, using four bytes per coordinate. The raw vector payload is N × d × 4 = 100,000 × 128 × 4 = 51,200,000 bytes. That is 51.2 decimal MB, or 51,200,000/1,048,576 = 48.828125 MiB.

This excludes identifiers, source text, access metadata, graph links, allocator overhead, and query buffers. Holding old and new vector payloads together during a representation migration requires 2 × 51.2 = 102.4 MB before those other items. The calculation is a floor for those two payloads, not a complete RAM or deployment recommendation.

For an exhaustive dot-product scan over all these vectors, each query uses N × d = 12,800,000 coordinate multiplications and N × (d − 1) = 12,700,000 additions under a straightforward arithmetic count. At a chosen demand of 20 queries per second, multiplication demand is 20 × 12,800,000 = 256,000,000 per second. This excludes query encoding, selection, filtering, and service overhead. It is not a measured throughput or latency prediction.

Layer 3 · Internals

An approximate nearest-neighbor index trades search work for recall under a defined distance function and dataset. HNSW uses a graph navigation structure; inverted-file approaches narrow candidate partitions, and quantization can reduce vector storage at the cost of approximation. These mechanisms do not make metadata filters or document deletion automatic.

A hypothetical uncompressed vector with 768 float32 components uses 768 × 4 = 3,072 bytes of component payload. One million such vectors require 3,072,000,000 decimal bytes before graph edges, metadata, IDs, replicas and allocator overhead. A memory plan based only on this payload can be seriously incomplete. Evaluate recall using the actual permission and category filters: retrieving a small unfiltered candidate set and removing most of it afterward can leave no eligible answer even when eligible neighbors exist. Model-version changes require compatible embeddings or a reindex strategy; comparing vectors from unrelated representation spaces is not a transparent schema migration.

Trade-offs and limits

ApproachProvidesRequires
Exact vector scanProvides a useful recall reference for a bounded dataset.Distance work grows with candidates and dimensions.
Approximate graph or partition indexReduces candidate work for a measured recall target.Filters, updates and distribution shift can change observed recall.

Recovery decision

Hypothetical scenario: A deleted or unauthorized vector remains reachable in an old graph generation. Enforce source eligibility even when physical collection is delayed.

No. Candidate search effort, filter selectivity, topology and ranking all matter. Measure filtered recall and latency under realistic scopes rather than treating a larger result count as proof.

Write your design before revealing the review

Does increasing top-k always repair filtered retrieval quality?

Evidence you can explain in your own design

Drafts and self-review are stored only in this browser. They are separate from reading completion.

Compare your decision

No. Candidate search effort, filter selectivity, topology and ranking all matter. Measure filtered recall and latency under realistic scopes rather than treating a larger result count as proof.

A deleted or unauthorized vector remains reachable in an old graph generation. Enforce source eligibility even when physical collection is delayed.

Check your understanding

Does increasing top-k always repair filtered retrieval quality?

No. Candidate search effort, filter selectivity, topology and ranking all matter. Measure filtered recall and latency under realistic scopes rather than treating a larger result count as proof.

How would you recover from this failure: A deleted or unauthorized vector remains reachable in an old graph generation. Enforce source eligibility even when physical collection is delayed.

Start with the exact boundary that failed. Bind vectors to source and embedding version. Build or update the chosen ANN structure. Publish a coherent index and deletion lifecycle. Then recover evidence through the observation path: Apply required scope constraints. Search with a bounded effort setting. Evaluate returned candidates against an exact baseline on a representative sample. Preserve the distinction between a confirmed state change and an unavailable response.

Which assumption in the worked calculation would a burst or concentrated tenant invalidate first?

Hypothetical 1,000,000 vectors × 768 dimensions × four bytes = 3.072 GB raw before graph/allocator/metadata overhead. Returning 20 approximate neighbors from that corpus does not establish recall; compare with the exact top-20 for sampled queries under the same filters. Recompute the affected resource rather than multiplying unrelated storage and network budgets by the same factor. Retrieve approximate nearest neighbors under a defined distance, corpus and permission scope. Index tuning trades work/memory against measured recall; approximate similarity is not a correctness guarantee for the downstream answer.

Which component in this topology could be removed from a smaller first deployment?

Embedding versions, Vector index, Filtered search, Recall evaluation name responsibilities, not a requirement for separate processes. Co-locate responsibilities when their transaction, trust and capacity boundaries permit it. Bind vectors to source and embedding version.

What evidence must a caller have before relying on the observation path?

Apply required scope constraints. Search with a bounded effort setting. Evaluate returned candidates against an exact baseline on a representative sample. No. Candidate search effort, filter selectivity, topology and ranking all matter. Measure filtered recall and latency under realistic scopes rather than treating a larger result count as proof.

45-minute interview rubric

  1. 00–05: scope vector and embedding and filter versions.
  2. 05–12: identify the limiting resource and derive the domain workload above, retaining units and assumptions.
  3. 12–28: draw embedding and filter versions, numbered writes and reads.
  4. 28–40: challenge recovery: Measure recall under the actual filter and update distribution.
  5. 40–45: defend vector_id placement, observations and remaining assumptions.

Go deeper

Decision log

Measure recall under the actual filter and update distribution.

Preserve vector identity and embedding and filter versions ownership.

Revisit changed workload, observations or recovery objectives.