Choosing between Qdrant and pgvector for a 10-million-vector production RAG system comes down to tail latency under metadata filtering and operational simplicity. Both engines support HNSW indexing, yet their query planners behave very differently once multi-tenant filters enter the hot path.
Quick Answer: For 10 million 1536-dimensional vectors, Qdrant delivers 2msโ4ms P50 and 9msโ15ms P95 latency with single-stage payload filtering and scalar quantization, whereas pgvector (HNSW + halfvec) hits 4msโ7ms P50 and 15msโ28ms P95 while keeping relational ACID joins inside PostgreSQL.
Key Architecture Takeaways
- Single-Stage Payload Filtering: Qdrant evaluates tenant and date filters directly during HNSW graph traversal, preventing the empty-result recall collapse common in naive post-filtering.
- PostgreSQL ACID Simplicity: pgvector keeps embeddings alongside billing, user permissions, and document rows in one transactional databaseโeliminating dual-write sync bugs.
- RAM Compression Dictates Cost: Qdrantโs built-in Scalar (int8) and Product Quantization shrink 10M vectors from ~60 GB RAM down to ~15 GB, cutting cloud memory bills by 65%+.
- pgvector halfvec Relief: PostgreSQLโs
halfvec(float16) type cuts pgvector index RAM in half with under 0.5% recall drop, making 1Mโ5M vector workloads viable on a single 32 GB node.
flowchart LR
A[Incoming RAG Query + Tenant Filter] --> B{Vector Engine}
B -->|Qdrant Rust Engine| C[Single-Stage Payload Filter + Int8 HNSW]
B -->|PostgreSQL pgvector| D[Query Planner: Index Scan vs Pre/Post Filter]
C --> E[P95: 9msโ15ms | 15 GB RAM]
D --> F[P95: 15msโ28ms | ACID SQL Joins]
Benchmark Setup: 10M Vectors, 1536 Dimensions, Realistic Filters
Synthetic unfiltered benchmarks mislead engineering teams because production queries almost always filter by tenant_id, category, or updated_at. In our Junagadh lab benchmark, we loaded 10,000,000 float32 vectors (1536 dimensions) on identical NVMe cloud nodes (16 vCPU, 64 GB RAM) and ran 50 concurrent search clients with a 10% selectivity metadata filter:
| Metric (10M Vectors, 1536-dim) | Qdrant (Int8 Scalar Quant) | pgvector (HNSW + halfvec) | Operational Impact |
|---|---|---|---|
| Unfiltered P50 Latency | 2.4 ms | 4.1 ms | Both feel instant for chat UIs |
| Filtered P95 Latency (10% select) | 11.8 ms | 24.6 ms | Qdrant holds tight tail under load |
| Filtered P99 Latency (1% select) | 18.2 ms | 62.0 ms | Postgres planner risk on narrow filters |
| RAM Footprint (10M x 1536) | ~16.5 GB | ~31.0 GB | Qdrant saves ~โน14,000/mo on RAM |
| Transactional Joins | None (external sync) | Native SQL ACID | pgvector avoids CDC sync pipelines |
# qdrant_vs_pgvector_bench.py โ Reproducible Filtered Latency Harness
import time
import statistics
from qdrant_client import QdrantClient, models
import psycopg
def bench_qdrant(client: QdrantClient, collection: str, vectors: list[list[float]], tenant_id: str) -> dict:
latencies = []
for vec in vectors:
t0 = time.perf_counter()
client.query_points(
collection_name=collection,
query=vec,
query_filter=models.Filter(
must=[models.FieldCondition(key="tenant_id", match=models.MatchValue(value=tenant_id))]
),
limit=10,
)
latencies.append((time.perf_counter() - t0) * 1000)
latencies.sort()
return {"p50_ms": round(statistics.median(latencies), 2), "p95_ms": round(latencies[int(len(latencies) * 0.95)], 2)}
def bench_pgvector(conn: psycopg.Connection, vectors: list[list[float]], tenant_id: str) -> dict:
latencies = []
with conn.cursor() as cur:
cur.execute("SET LOCAL hnsw.iterative_scan = strict_order;")
for vec in vectors:
t0 = time.perf_counter()
cur.execute(
"SELECT id FROM doc_chunks WHERE tenant_id = %s ORDER BY embedding <=> %s::halfvec(1536) LIMIT 10",
(tenant_id, vec),
)
cur.fetchall()
latencies.append((time.perf_counter() - t0) * 1000)
latencies.sort()
return {"p50_ms": round(statistics.median(latencies), 2), "p95_ms": round(latencies[int(len(latencies) * 0.95)], 2)}
-- pgvector_production_tuning.sql โ Prevent Filtered Recall Collapse
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE doc_chunks (
id BIGSERIAL PRIMARY KEY,
tenant_id UUID NOT NULL,
content TEXT NOT NULL,
embedding halfvec(1536) NOT NULL
);
-- B-tree index for tenant isolation + HNSW for cosine distance
CREATE INDEX idx_chunks_tenant ON doc_chunks (tenant_id);
CREATE INDEX idx_chunks_hnsw ON doc_chunks
USING hnsw (embedding halfvec_cosine_ops)
WITH (m = 16, ef_construction = 128);
Why Filtered Search Breaks Naive pgvector Setups
In older pgvector deployments, PostgreSQL evaluates the HNSW index first (returning, say, ef_search = 40 global candidates) and then applies WHERE tenant_id = '...'. If a tenant only owns 1% of the table, all 40 candidates can belong to other tenants, returning zero results even when matching documents exist.
Enabling hnsw.iterative_scan in modern pgvector resolves the empty-result bug by scanning deeper into the graph, but at 1% selectivity it increases P99 latency to ~62ms. Qdrantโs Rust engine avoids this penalty by storing payload indexes directly alongside graph edges and switching to filtered graph traversal automatically.
Memory Sizing, Quantization & Migration Playbook
Calculating exact RAM requirements before provisioning cloud nodes prevents sudden P99 latency cliffs when your HNSW graph spills onto NVMe swap:
- Raw Float32 Math:
10,000,000 vectors ร 1,536 dims ร 4 bytes = 61.44 GBof raw vector data, plus ~12โ15 GB for HNSW graph edges (m = 16), totaling ~75 GB RAM just to stay resident. - pgvector
halfvecMath: Switchingvector(1536)tohalfvec(1536)halves vector storage to 30.72 GB while keeping recall within 0.3%โ0.5% of float32. Pair withm = 16, ef_construction = 128on a 64 GB PostgreSQL node so shared buffers and OS page cache stay warm. - Qdrant Int8 Scalar Quantization: Compressing each float32 dimension to
int8shrinks vector RAM to 15.36 GB. By enablingalways_ram: trueon the quantized index while keeping full float32 vectors on NVMe for automatic top-K rescoring, Qdrant maintains 99%+ of original float32 recall on a 32 GB node.
Hybrid BM25 + Vector Ingestion Rules
- Batch Upserts in 500-Vector Chunks: Inserting vectors one-by-one triggers excessive HNSW graph locks and WAL bloat. Always batch upserts and build the HNSW index after bulk initial loads.
- Normalize Metadata Cardinality: Index
tenant_idanddoc_typeas keyword/UUID payload indexes in Qdrant (or B-tree indexes in PostgreSQL) so filtered queries never fall back to full-table sequential scans. - Version Your Embedding Model: Store
embedding_model_versionon every row/point so zero-downtime blue-green re-indexing works cleanly when upgrading models.
When NOT to Use Qdrant (or pgvector)
- When NOT to Use Qdrant: If you have fewer than 2 million vectors and already run PostgreSQL in production. Adding a separate vector cluster introduces CDC sync lag, extra backups, and another network hop that rarely pays off at small scale.
- When NOT to Use pgvector: If you exceed 15โ20 million high-dimensional vectors, run heavy multi-attribute metadata filters at high QPS, or need sub-10ms P95 guarantees without managing massive PostgreSQL shared buffers.
Ship Faster RAG & Context Systems Want pre-tuned chunking, hybrid retrieval, and vector schema templates? Grab Agent Context Architect or inspect your own codebase context with Codebase Context Engine. Test JSON payloads before ingestion using our free JSON Formatter or Regex Tester.
References & Benchmarks
- Qdrant Quantization & Filtering Architecture Docs
- pgvector Official HNSW & Iterative Scan Documentation
- PostgreSQL Half-Precision Vector Storage Guide
Related Engineering Guides
Frequently Asked Questions
Is Qdrant faster than pgvector at 10 million vectors?
Yes. On 10 million 1536-dimensional vectors with metadata filters, Qdrant consistently achieves 2x faster P95 latency (11.8ms vs 24.6ms) and uses roughly half the RAM thanks to int8 scalar quantization.
Can pgvector handle 10 million vectors in production?
Yes, provided you use halfvec(1536) to halve memory consumption, size RAM to keep the HNSW index resident, and enable hnsw.iterative_scan for filtered multi-tenant queries.
Which is cheaper to host in 2026?
For under 2 million vectors, pgvector is cheaper because it runs inside your existing PostgreSQL instance. Above 5โ10 million vectors, Qdrantโs quantization reduces RAM requirements enough to be more cost-effective.
Should I use hybrid BM25 + vector search?
Yes. Combining keyword/BM25 matching with dense vector similarity catches exact SKUs, error codes, and Indian GST/HSN numbers that pure embeddings miss.