web dev//SQL//vector extension

A vector extension is a database extension that adds vector storage and cosine similarity search to an existing relational database, so that the SQL database handles embeddings instead of a dedicated vector database. Its main advantage is relational queries and vector search in the same database and the same query, with no syncing of IDs between two systems.


A vector extension is a database extension that adds vector storage and cosine similarity search to an existing relational database, so that the SQL database handles embeddings instead of a dedicated vector database. Its main advantage is relational queries and vector search in the same database and the same query, with no syncing of IDs between two systems.

It adds a vector column type, which stores arrays of floats (embeddings) as first-class data alongside normal columns.

It adds distance functions (cosine similarity, Euclidean distance, inner product) usable directly in SQL queries.

It adds specialized indexes (HNSW, IVF) for approximate nearest neighbor search without scanning every row.

pgvector is the most popular implementation (for PostgreSQL). Vectorize is Cloudflare's approach, but as a standalone service rather than a database extension.

Against dedicated vector databases (Pinecone, Weaviate), extensions cannot match the raw speed and scale for millions of embeddings, but they keep everything in one place: one query, one system, one source of truth.