pgvector is an open-source PostgreSQL extension that adds vector storage and similarity search directly inside Postgres, turning an ordinary relational database into a capable vector store without any external infrastructure. It matters because it lets teams build RAG pipelines, semantic search, and recommendation engines while keeping all their data in a single ACID-compliant system they already operate. The key mental model to carry into the tables: every vector distance operator you use in a query must match the operator class chosen when the index was built β a mismatch silently falls back to a sequential scan that can be thousands of times slower.
What This Cheat Sheet Covers
This topic spans 17 focused tables and 109 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Installation and Extension Setup
Enabling pgvector is a single SQL statement, but the exact steps vary by platform. Every major managed Postgres provider β Supabase, Neon, AWS RDS, Aurora, Azure, and Google Cloud SQL β ships with pgvector pre-installed; you only need to activate it per-database.
| Type | Example | Description |
|---|---|---|
CREATE EXTENSION IF NOT EXISTS vector; | Activates pgvector in the current database; note the registered name is vector, not pgvector. | |
SELECT extversion FROM pg_extension WHERE extname = 'vector'; | Confirms the extension is active and shows the installed version. | |
CREATE EXTENSION vector WITH SCHEMA extensions; | Supabase best practice places pgvector in the extensions schema to keep the public schema clean. | |
SHOW azure.extensions; then CREATE EXTENSION vector; | Azure requires allowlisting vector (not pgvector) in the server parameter before the CREATE EXTENSION command can succeed. |