RAG with Postgres and pgvector in production: from PoC to SLO
Embeddings, HNSW indexing, reranking, evaluation, context window, latency under load. Full stack with code and measurable SLOs.
Tag
Embeddings, HNSW indexing, reranking, evaluation, context window, latency under load. Full stack with code and measurable SLOs.
This guide installs PostgreSQL 16 with pgvector on Debian or Ubuntu using the official PGDG repository, creates a dedicated role and database, tunes memory for production, and explains when the HNSW index beats IVFFlat depending on vector volume and the available maintenance window.
pgvector matured in 2023-2024 with the HNSW index type and parallel construction that arrived in version 0.6. For projects already running PostgreSQL, a dedicated vector database is not needed in most cases: this guide explains when PostgreSQL is enough, how to configure the index, and where it starts to fall short.
pgvector turns PostgreSQL into a fully functional vector database without adding a separate service to the stack. It extends Postgres with the vector type, IVFFlat indexes for approximate nearest-neighbour search (ANN), and the ability to combine relational SQL filters with vector ranking in a single query. For most RAG projects and internal chatbots, those limits never become a problem.