Technology RadarTechnology Radar

pgvector

raginference
This item was not updated in last three versions of the Radar. Should it have appeared in one of the more recent editions, there is a good chance it remains pertinent. However, if the item dates back further, its relevance may have diminished and our current evaluation could vary. Regrettably, our capacity to consistently revisit items from past Radar editions is limited.
Adopt

pgvector is a PostgreSQL extension that adds vector search to your existing Postgres database — enabling semantic search and RAG (retrieval-augmented generation) without introducing a new service into your infrastructure.

Buy vs Build

Purely build in the sense that you manage it yourself — but it runs inside Postgres, which your team already operates. Available managed on every major cloud: Amazon RDS, Google Cloud SQL, Azure Database for PostgreSQL, Supabase, and Neon all support pgvector out of the box. That makes the operational cost close to zero if you're already on a managed Postgres.

Why It's in Adopt

The "should we add a vector database" question has a straightforward answer for most software teams: if you're already running PostgreSQL, pgvector is where to start. The reasons:

  • No new service: Vector search in the same database as your application data — fewer moving parts, simpler operations, unified backups and failover
  • Familiar tooling: Your team already knows SQL, psql, pg_dump, migrations, and your Postgres monitoring stack
  • Hybrid queries: Filter by structured data (e.g., WHERE user_id = 123) AND similarity search in a single query — something that requires extra steps in dedicated vector databases
  • Production-ready: pgvectorscale (by Timescale) adds DiskANN-based indexing that makes pgvector competitive at tens of millions of vectors with a 75% cost advantage over Pinecone at that scale

When You'll Need to Move Beyond pgvector

pgvector is not the right choice for everyone:

  • Scale: Beyond ~100M vectors, purpose-built databases (Milvus, Qdrant) handle indexing and memory more efficiently
  • Hybrid search (vector + keyword BM25): pgvector doesn't support BM25 natively — you'd need a separate full-text search
  • Teams without Postgres: If you're on MongoDB or another database, using Postgres solely for vectors adds operational complexity

Getting Started

-- Enable the extension
CREATE EXTENSION vector;

-- Add a vector column to your table
ALTER TABLE documents ADD COLUMN embedding vector(1536);

-- Create an index for fast approximate search
CREATE INDEX ON documents USING hnsw (embedding vector_cosine_ops);

-- Search for similar documents
SELECT content FROM documents
ORDER BY embedding <=> '[0.1, 0.2, ...]'  -- your query embedding
LIMIT 5;

Key Characteristics

Property Value
Runs in PostgreSQL (any version 11+)
Index types HNSW, IVFFlat
Practical scale Up to ~100M vectors
Managed support RDS, Cloud SQL, Azure, Supabase, Neon
License PostgreSQL License (open source)
GitHub pgvector/pgvector

Further Reading