web dev//SQL//PostgreSQL//pgvector

pgvector is an extension for PostgreSQL that adds vector columns, storage and similarity search directly inside the database, so that vector search runs next to ordinary relational data instead of in a separate system.


pgvector is an extension for PostgreSQL that adds vector columns, storage and similarity search directly inside the database, so that vector search runs next to ordinary relational data instead of in a separate system.

It adds a VECTOR(n) column type that stores embeddings alongside normal relational data in the same table, and it computes cosine similarity, Euclidean distance and inner product inside SQL queries.

Relational filtering and vector search run in one query, as in SELECT * FROM docs WHERE category='X' ORDER BY embedding <-> query_vector LIMIT 5, so no IDs have to be synced between two systems.

Approximate nearest neighbour search runs on HNSW indexes.

It turns PostgreSQL into a lightweight vector database with zero extra infrastructure. Against Weaviate, pgvector is slower at pure vector search scale (millions of embeddings), and in exchange everything stays in one database.