Skip to main content
AI Backend GlossaryGlossary

pgvector

A PostgreSQL extension that adds vector similarity search.

Definition

pgvector is an open-source PostgreSQL extension that adds a `vector` column type and operators for L2 distance, cosine distance, and inner product similarity search. It enables you to store embedding vectors alongside your regular data in Postgres — no separate vector database required.

Why it matters for AI APIs

For most applications, pgvector is the right default for RAG: it lives in your existing Postgres, shares transactions with your app data, is ACID-compliant, and scales to millions of vectors. You only need a dedicated vector database like Qdrant at very large scale or when you need advanced filtering.

In FastAPI AI Kit

pgvector is installed via an Alembic migration and used in the kit's `Document` and `Embedding` models. The RAG pipeline automatically uses pgvector when `VECTOR_STORE=pgvector` (the default). Similarity search uses `ORDER BY embedding <=> query_vector LIMIT k`.

Related terms