Postgres + pgvector: Why You Might Not Need a Dedicated Vector DB
HNSW indexes, halfvec quantization, and the operational bliss of keeping relational and semantic data in one ACID home.
Devon Reed
Data Infrastructure Lead
Dedicated vector databases claimed Postgres would never scale for semantic embeddings. With pgvector 0.7+, HNSW indexing, and fp16/halfvec compression, Postgres comfortably handles up to 50M vectors with sub-10ms latency.
Postgres + pgvector: Why You Might Not Need a Dedicated Vector DB Evaluation
Why It Matters
- •Zero data synchronization headaches between your primary relational database and an external vector service.
- •Filter by tenant ID, user permissions, and metadata using standard SQL indexes in a single query.
- •Huge cost savings by reusing existing Supabase, Neon, or RDS instances.
Who Should Care
- •Backend developers and architects designing RAG and semantic search pipelines.
- •Teams wanting to simplify infrastructure complexity and reduce monthly SaaS bills.
HNSW Query Performance in SQL
By combining cosine similarity operators with standard relational WHERE clauses, pgvector executes both hybrid search and strict row-level tenant security in one step:
CREATE INDEX ON documents
USING hnsw (embedding vector_cosine_ops)
WITH (m = 16, ef_construction = 64);
-- Query with tenant filter and semantic distance
SELECT id, title, content, 1 - (embedding <=> $1) AS similarity
FROM documents
WHERE organization_id = $2 AND is_published = TRUE
ORDER BY embedding <=> $1
LIMIT 10;Actionable Next Steps
- 1Use HNSW indexing over IVFFlat for production workloads requiring high recall.
- 2Leverage halfvec (fp16) quantization to cut RAM usage by 50% with <1% recall degradation.
- 3Don't add Pinecone or Qdrant until you have proven you exceed 100 million vectors.
Stay ahead of tech shifts like Postgres + pgvector: Why You Might Not Need a Dedicated Vector DB
Subscribe to Prompt N Prod Tech Radar for weekly architectural breakdowns and production insights.
Discussion — Postgres + pgvector: Why You Might Not Need a Dedicated Vector DB
Persisted live to Neon Serverless PostgreSQL
Ready to master this in depth?
Explore step-by-step milestones in our interactive learning tracks.
