Why Vector Database Performance Is Different: Recall vs Latency
Content reflects the state as of March 2026. AI tooling and model capabilities in this area change frequently.
In relational and document databases, an index either matches a row or does not; in vector databases, index performance is a continuous negotiation between query latency, memory consumption, and retrieval accuracy. Tuning vector search requires measuring Recall@K against index hyperparameters rather than treating query execution as deterministic boolean matching.
Technology and product capabilities in this series are evaluated as of June 30, 2026.
Situation
Enterprise AI systems, retrieval-augmented generation (RAG) pipelines, and semantic search platforms rely on vector databases and vector extensions (such as pgvector, Qdrant, Milvus, and Elasticsearch vector search). Unlike traditional B-trees or inverted indices that execute exact predicate evaluation, vector engines execute Approximate Nearest Neighbor (ANN) search across high-dimensional embedding spaces (e.g., 768, 1536, or 3072 dimensions).
Vector performance evaluation departs fundamentally from classical database benchmarking:
- Accuracy is Approximate: An ANN query returns the closest $K$ candidates found by a heuristic graph or clustering traversal, not the mathematically guaranteed top-$K$ nearest neighbors. Retrieval quality is governed by Recall@K (the percentage of true nearest neighbors retrieved relative to an exact brute-force scan).
- Extreme Memory Footprint: Graph-based indices like HNSW (Hierarchical Navigable Small World) perform best when the hot graph and its vectors fit in RAM, because traversal is a pointer-chasing workload whose access pattern defeats read-ahead. This is a latency characteristic, not a correctness requirement: several engines support disk-backed or memory-mapped operation with a latency tradeoff. Qdrant offers memory-mapped and on-disk vector and index configurations; pgvector’s HNSW index is an ordinary PostgreSQL index stored on disk and paged through shared buffers, though performance still depends heavily on the active graph staying resident. Note also that peak build memory and steady-state query memory are different numbers — sizing against the build peak overprovisions the cluster. A dataset of 10 million 1536-dimensional vectors can easily consume 80–120 GB when held fully in memory as Float32.
- Compute-Intensive Math: Distance metrics (Cosine Similarity, Euclidean Distance $L_2$, Dot Product) require billions of floating-point operations per query, relying heavily on CPU SIMD instructions (AVX-512, ARM Neon) or GPU acceleration.
When downstream LLMs hallucinate due to missed context or when vector search p99 latency degrades from 5 ms to 200 ms, DBAs and SREs cannot simply look for missing indexes. Triage requires understanding the trade-off envelope between index topology, quantization compression, search exploration depth, and metadata filter selectivity.
The Problem
Vector search introduces distinct operational trade-offs where optimizing one system dimension inevitably degrades another:
- The Recall-Latency Curve: In HNSW indices, increasing the search exploration parameter ($efSearch$) expands the candidate queue during graph traversal, raising Recall@K at the cost of latency and throughput. The shape of that tradeoff is universal; the magnitude is not. How much recall a given $efSearch$ increase buys, and how much QPS it costs, depends on dataset size, dimensionality, graph construction parameters ($M$, $efConstruction$), filter selectivity, storage backing, hardware, and query concurrency. Treat any specific pair of numbers as belonging to the benchmark that produced it, and measure Recall@K and latency on your own corpus before committing to a setting.
- Quantization Distortion vs. Memory Savings: Techniques like Scalar Quantization (SQ8) and Product Quantization (PQ) reduce memory usage by 4x–16x by compressing 32-bit floats into 8-bit or sub-vector codebooks. However, quantization introduces distance approximation noise, degrading recall unless paired with expensive raw-vector rescoring (over-fetching).
- The Metadata Filtering Dilemma: Combining boolean metadata filters (e.g.,
tenant_id = "org_42"ANDstatus = "active") with vector search creates structural failure modes:- Post-filtering: Runs ANN search first, then drops non-matching candidates. If metadata selectivity is 1%, an ANN query for $K=10$ returns 0 or 1 valid document (catastrophic recall collapse).
- Pre-filtering: Filters metadata first, but if the remaining candidate set is small, graph traversal fails to navigate disconnected nodes, or falls back to an unindexed brute-force scan.
- Iterative / Single-Stage Filtering: Evaluates metadata during graph traversal, but increases per-node evaluation cost.
- RAM Thrashing on Graph Traversals: Unlike relational tables that leverage sequential disk reads and page caches, HNSW graph traversal performs random memory pointer jumps across millions of vectors. Read-ahead cannot predict the next hop, so when the working set does not fit in RAM the index degrades sharply — each traversal hop can become a synchronous I/O stall rather than a cache hit. The severity spans orders of magnitude depending on storage class, queue depth, and how much of the graph stays resident, and it is qualitatively different from a deliberately disk-backed configuration that the engine plans for. Distinguish the two: unplanned swap thrashing shows as rising major page faults (
majflt) against a resident set that exceeds RAM, whereas a memory-mapped or on-disk index configured on purpose has a higher but stable latency floor. - Dimensionality Scaling Bottlenecks: Doubling embedding dimensionality from 768 to 1536 doubles RAM consumption and vector math instruction cycles while worsening the “curse of dimensionality,” where distance distributions concentrate and make graph clustering less discriminative.
How do we systematically diagnose whether vector retrieval failures stem from index hyperparameter misconfiguration, quantization recall loss, metadata filter mismatch, memory paging, or vector dimension overhead?
Build a Vector-Aware Incident Evidence Pack
flowchart TD
A[RAG retrieval latency and quality alerts] --> E[time-bounded vector evidence pack]
B[Recall-at-K ground truth benchmark validation] --> E
C[index hyperparameters HNSW M efSearch IVF nprobe] --> E
D[vector memory footprint quantization and filter selectivity] --> E
E --> F[calculate Recall-at-K curve vs latency and QPS]
F --> G[reconcile SIMD instructions RAM resident set and cache misses]
G --> H[LLM observations hypotheses contradictions and gaps]
H --> I[AI Platform and Database Engineer verification]
I --> J[index tuning validation and rollback]
To diagnose vector search performance, construct an evidence pack combining system metrics with algorithmic accuracy benchmarks:
- Accuracy Metrics (Recall@K): Measure ground-truth recall against an exact brute-force Flat index ($kNN_{exact}$) across a representative validation query sample (e.g., 500 queries): $$\text{Recall}@K = \frac{| \text{ANN_Results}@K \cap \text{Exact_Results}@K |}{K}$$
- Index Hyperparameters:
- HNSW: $M$ (max links per node, e.g., 16–64), $efConstruction$ (build candidate list, e.g., 100–400), $efSearch$ (runtime candidate list, e.g., 32–256).
- IVF: $nlist$ (total Voronoi cluster centroids), $nprobe$ (centroids scanned during query).
- Vector and Memory Sizing: Vector dimension ($D$), precision (Float32, Float16, SQ8, PQ, BQ), total vector count ($N$), index memory size in RAM, and OS resident memory (RSS).
- Execution and Hardware Telemetry: P50/p95/p99 search latency, queries per second (QPS), CPU SIMD instruction flags (
avx512f,neon), page fault rates (minflt/s,majflt/s), and metadata filter selectivity percentage.
The LLM processes this multi-dimensional bundle to generate four distinct outputs:
- Observations: Quantitative facts correlating parameters to recall and latency (e.g., “Increasing $efSearch$ from 32 to 128 increased Recall@10 from 88.2% to 97.4%, while p99 latency increased from 4.1 ms to 14.8 ms”).
- Hypotheses: Ranked architectural explanations (e.g., “Hypothesis 1: Post-filtering on low-selectivity tenant metadata causing candidate exhaustion; Hypothesis 2: Index size exceeding physical RAM causing minor page faults on graph traversal”).
- Missing Evidence: Unobserved metrics (e.g., “Need validation query ground-truth recall across quantized vs unquantized vectors”).
- Actions: Specific index parameter tuning, quantization adjustments, and filtering architecture changes.
Symptoms
| Symptom | Plausible failure classes | Evidence that separates them |
|---|---|---|
| Low retrieval accuracy / hallucinations | Low $efSearch$/$nprobe$, aggressive PQ quantization, post-filtering | Measured Recall@K < 90%, metadata filter selectivity, quantization mode |
| High p99 latency with low CPU | Index paging to disk/swap, random I/O thrashing during graph hops | OS major page faults (majflt), disk read IOPS on vector volume |
| Latency spikes when metadata filter added | Post-filtering candidate starvation, unindexed filter scan | Latency delta with vs without filter, filter selectivity %, query plan |
| High CPU with low QPS | High $efSearch$, un-quantized high-dimensional math, missing SIMD | efSearch > 256, CPU instruction counters, vector dimension $D \ge 1536$ |
| Memory OOM during index build | $efConstruction$ or $M$ too high, un-quantized vectors in RAM | Memory climb during build, M > 64, efConstruction > 400 |
| Index build takes hours/days | Large $N$, high $efConstruction$, single-threaded build | Build time delta, worker thread count, indexing throughput (vectors/sec) |
First Five Checks
flowchart TD
A[Vector search latency or recall degradation alert] --> B[1. Validate Recall-at-K against exact brute-force baseline]
B --> C[2. Inspect index hyperparameters HNSW efSearch or IVF nprobe]
C --> D[3. Verify index resident memory in RAM and check page faults]
D --> E[4. Analyze metadata filter selectivity and filtering execution strategy]
E --> F[5. Evaluate vector quantization type and distance calculation overhead]
F --> G[Synthesize observations hypotheses and hyperparameter tuning plan]
1. Validate Recall@K against exact brute-force baseline
Never tune vector parameters based on latency alone without measuring retrieval accuracy. Run a test batch of 100–500 representative production queries against both the active ANN index and a ground-truth flat brute-force index (Flat / exact scan).
- If Recall@10 is below 92–95%, the index is dropping true nearest neighbors, causing downstream RAG hallucination.
- If Recall@10 is 99.8%, the index is over-configured for accuracy and wasting compute headroom.
2. Inspect index hyperparameters (HNSW $efSearch$ or IVF $nprobe$)
Check the runtime exploration depth:
- HNSW $efSearch$: In HNSW, $efSearch$ controls the size of the dynamic priority queue during search. If $efSearch = K$ (e.g., $K=10, efSearch=10$), graph search terminates prematurely with poor recall. A standard baseline is $efSearch = 64\text{ to }128$.
- IVF $nprobe$: In IVF, $nprobe$ dictates how many cluster centroids are inspected. If $nlist = 4096$ and $nprobe = 1$, only the single closest centroid is searched, resulting in low recall for boundary vectors.
3. Verify index resident memory in RAM and check page faults
Calculate raw index memory requirements:
$$\text{Memory}_{\text{HNSW}} \approx N \times \left( (D \times 4\text{ bytes}) + (M \times 8\text{ bytes}) \right) \times 1.25$$
For 5 million vectors with $D=1536$ and $M=32$:
$$\text{Memory} \approx 5{,}000{,}000 \times \left( 6144 + 256 \right) \times 1.25 \approx 40.0\text{ GB}$$
Check vmstat 1 for major page faults (majflt). If the index exceeds available RAM and the OS pages vectors from SSD swap, latency spikes by orders of magnitude due to random non-sequential graph memory access.
4. Analyze metadata filter selectivity and filtering execution strategy
Inspect the metadata filters applied to queries:
- High Selectivity (e.g., filter matches 0.1% of data): Pre-filtering or single-stage iterative graph traversal is required. Post-filtering will discard almost all ANN candidates, returning empty results.
- Low Selectivity (e.g., filter matches 90% of data): Post-filtering or standard ANN traversal with bitmap checks operates efficiently without index overhead.
5. Evaluate vector quantization type and distance calculation overhead
Inspect vector representation precision:
- Uncompressed Float32: Maximum distance fidelity, but consumes 4 bytes per dimension.
- Scalar Quantization (SQ8): Compresses floats to 8-bit unsigned integers (1 byte/dimension), providing roughly a 4x RAM reduction. Recall impact is typically small but is data-dependent — validate it against your own corpus rather than assuming a fixed retention figure.
- Product Quantization (PQ): Compresses vectors into compact codebook indices (e.g., 64 bytes total), but requires rescoring the top-$N$ candidates ($N=50\text{ to }100$) using uncompressed vectors to restore final Recall@K.
Decision Tree
flowchart TD
A[Vector search performance or recall incident] --> B{Measured Recall-at-K below target SLA}
B -->|Yes| C{Is quantization active SQ8 PQ BQ}
C -->|Yes| D[Enable top-K over-fetching and raw vector rescoring]
C -->|No| E[Increase efSearch in HNSW or nprobe in IVF]
B -->|No| F{Search p99 latency above SLA}
F -->|Yes| G{Major page faults detected or RSS exceeds RAM}
G -->|Yes| H[Apply SQ8 quantization or upgrade instance memory]
G -->|No| I{Metadata filter present in query}
I -->|Yes| J[Switch from post-filtering to single-stage iterative filtering]
I -->|No| K[Decrease efSearch or optimize CPU SIMD compiler flags]
In Practice
The original HNSW research (Malkov & Yashunin, IEEE TPAMI) proves that hierarchical graph exploration achieves logarithmic search scaling ($O(\log N)$) by constructing multi-layer Delaunay-like graphs. The research establishes that search quality depends directly on $efSearch$; setting $efSearch < K$ destroys recall, while setting $efSearch > 500$ produces diminishing accuracy returns at significant CPU cost.
According to the pgvector official documentation, HNSW index builds require tuning m and ef_construction during index creation, and adjusting hnsw.ef_search dynamically per session. The documentation highlights that memory for HNSW indexes must fit within PostgreSQL’s shared_buffers and OS RAM cache to prevent disk seek bottlenecks.
Qdrant’s quantization documentation documents Scalar Quantization (SQ8) as delivering roughly a fourfold reduction in memory, with accuracy loss that is often small — but it treats that accuracy impact as explicitly data-dependent rather than guaranteed. Do not carry a fixed recall-retention figure across corpora: whether SQ8 costs you 0.5% or 5% of Recall@10 depends on the embedding model, the dimensionality, and how tightly clustered the vectors are in your space. Measure it. In contrast, 1-bit Binary Quantization (BQ) generally requires over-sampling and rescoring against original vectors to avoid severe accuracy regressions in cosine similarity search.
Research on Filtered Vector Search (ACORN / Filtered HNSW) demonstrates that naive post-filtering causes catastrophic recall collapse when metadata selectivity drops below 5%. The documented best practice is single-stage predicate graph traversal, where edge exploration evaluates both vector proximity and boolean predicates simultaneously.
Remediation Options
| Proven root cause | Candidate remediation | Validation criteria |
|---|---|---|
| Low Recall@K due to shallow graph search | Increase efSearch (e.g., from 32 to 96 or 128) in session configuration | Recall@10 increases to >95%; latency remains within SLA |
| Excessive RAM footprint causing page faults | Convert index from Float32 to Scalar Quantization (SQ8) | Index RAM drops by 75%; major page faults drop to 0 |
| Post-filtering causing empty or low-recall results | Migrate to single-stage filtered index or pre-filter by partition | Retrieved candidate count equals requested $K$; recall restores |
| High search latency from high dimensionality | Apply Matryoshka Representation Learning (MRL) truncation or PCA | Vector dimensions reduced (e.g., 1536 to 512); latency drops 2x |
| Product Quantization distance distortion | Implement two-phase search: over-fetch top $3K$ via PQ, rescore with Float32 | Recall@K restores to Float32 parity with low RAM usage |
| Slow index builds blocking ingest pipeline | Increase parallel build workers and tune efConstruction to 128–200 | Build throughput increases (vectors/sec); RAM stays bounded |
Rollback Plan
When modifying vector index parameters, quantization formats, or filtering pipelines, maintain an explicit reversal plan:
- Session-Level Hyperparameter Rollback: Changes to search parameters (such as
hnsw.ef_searchin pgvector orefin Qdrant) are dynamic. If increasingefSearchdegrades throughput, reset the parameter to its baseline value instantly without rebuilding the index. - Quantization Rollback Strategy: When converting an index to SQ8 or PQ, build the quantized index under a separate name or alias. Validate Recall@K against production queries. If accuracy drops below SLA, point query routing back to the unquantized index before dropping the old index.
- Filtering Pipeline Fallback: If deploying single-stage iterative graph filtering causes query planner regressions, toggle an application feature flag to revert to pre-filtered partitioned tables.
- Matryoshka Dimension Truncation Rollback: If truncating vector dimensions (e.g., from 1536 to 512) degrades semantic recall on long-tail queries, update the embedding service configuration to generate full-dimension embeddings.
Where It Breaks
| Failure mode | Why naive reasoning fails | Better diagnostic boundary |
|---|---|---|
| ”Recall is 99%, index is optimal” | Over-configured efSearch wastes CPU; 95% recall at 3x higher QPS may be better | Map the full Recall-vs-Latency Pareto frontier |
| ”Vector indexes behave like B-trees” | B-trees are deterministic; vector search is probabilistic and parameter-dependent | Benchmark accuracy using ground-truth validation queries |
| ”Post-filtering is simple and safe” | Low-selectivity filters eliminate all nearest neighbors, causing empty results | Analyze metadata filter selectivity distribution |
| ”More RAM always fixes slow search” | If $efSearch$ is too high or SIMD math is unoptimized, CPU is the bottleneck | Profile CPU instruction cycles and SIMD utilization |
| ”Quantization always loses accuracy” | SQ8’s accuracy cost is often small relative to its ~4x memory saving, but the magnitude is data-dependent | Measure Recall@K with and without SQ8 on your own corpus before investing in massive RAM upgrades |
| ”Bigger embedding model is always better” | 3072-dim vectors double latency and memory; smaller MRL models often match quality | Benchmark domain retrieval accuracy vs vector dimension |
What the LLM Cannot Do
To prevent hallucinated configurations, data leakage, and system degradation, strict boundaries govern the LLM:
- No Raw Vector Ingestion: The LLM must not receive raw high-dimensional vector arrays or private document embeddings. Telemetry must be restricted to index metadata, recall benchmarks, and system metrics.
- No Speculative Recall Guarantees: The LLM cannot predict exact Recall@K without empirical ground-truth benchmark data. It must request validation query evaluations when accuracy metrics are missing.
- No Direct Index Mutations: The LLM cannot execute
CREATE INDEX, drop indexes, or alter database memory configurations autonomously. - No Autonomous Threshold Redefinition: The LLM cannot decide whether a 92% recall rate is acceptable for business logic without human domain authorization.
What to Do Next
- Problem: Vector search performance diverges from classical databases, requiring continuous optimization across recall, query latency, memory footprint, and metadata filtering.
- Solution: Construct a vector-aware incident evidence pack measuring empirical Recall@K curves against $efSearch$/$nprobe$, memory sizing, and filter selectivity.
- Proof: Formulate hypotheses that explicitly reconcile recall improvements against latency inflation, quantization memory savings against rescoring overhead, and filter strategies against candidate yield.
- Action: Instrument automated Recall@K tracking against a baseline flat index in staging. Then proceed to Part 2 to diagnose embedding model latency, reranking pipelines, and hybrid search regressions.
Sources
- Efficient and Robust Approximate Nearest Neighbor Search Using Hierarchical Navigable Small World Graphs (Malkov & Yashunin, IEEE TPAMI)
- pgvector Documentation — HNSW and IVFFlat Vector Indexing
- Qdrant Vector Database Documentation — Vector Quantization and Index Sizing
- Milvus Vector Database Documentation — In-Memory and Filtered Vector Search
- ACORN: Performant and Accurate Approximate Nearest Neighbor Search with Predicates
- Matryoshka Representation Learning (Kusupati et al., NeurIPS)