pgvector
ELI5 - The Vibe Check
pgvector turns your regular Postgres database into a vector database without making you run a whole separate system just to store AI embeddings. You add a new column type that holds arrays of numbers, and suddenly you can ask Postgres to find the rows most similar to this one using the same database that already stores everything else.
Real Talk
pgvector is a PostgreSQL extension that adds a vector data type and similarity search operators (L2 distance, cosine distance, inner product), along with approximate nearest neighbor indexes like IVFFlat and HNSW for fast similarity search at scale. It lets teams store embeddings alongside relational data instead of standing up a dedicated vector database.
Show Me The Code
CREATE EXTENSION vector;
CREATE TABLE docs (id serial, embedding vector(1536));
SELECT * FROM docs
ORDER BY embedding <-> '[0.1, 0.2, 0.3]' LIMIT 5;
When You'll Hear This
"We skipped a separate vector database and just added pgvector to our existing Postgres." / "The HNSW index made similarity search fast enough for production."
Related Terms
Embedding
An embedding is turning words, sentences, or entire documents into lists of numbers (vectors) that capture their meaning.
Index
A database index is like the index in the back of a book. Without it, the database reads every single row to find what you want.
PostgreSQL
PostgreSQL (just say 'Postgres') is the Swiss Army knife of databases.
Vector Database
A vector database is a special database built to store and search embeddings.