pgvector
A Postgres extension that stores embeddings and runs similarity search in the database you already have, including Supabase.
What it is
An open-source extension that adds vector columns and similarity search to PostgreSQL. You store an embedding next to the row it describes, then ask for the nearest rows with plain SQL:
select id, content
from documents
order by embedding <=> $1 -- cosine distance to the question's embedding
limit 4;
It supports two index types, HNSW and IVFFlat. On Supabase it’s already installed;
you switch it on with create extension vector with schema extensions; or from the
dashboard (Database → Extensions → vector). The extension’s name in SQL is vector.
When to use it
- You already use Postgres or Supabase and want retrieval without running another service.
- You want vectors in the same transactions, joins, and row-level security as the rest of your data, so a deleted document can’t leave an orphaned embedding behind.
When NOT to
- Your vectors and index no longer fit comfortably in the database’s memory, or you need fast search with heavy filters at high query volume. A dedicated vector database such as Qdrant is built for that.
Gotchas worth knowing up front
- Index limits: HNSW and IVFFlat index
vectorcolumns up to 2,000 dimensions. For larger embeddings, store them ashalfvec(up to 4,000 dimensions indexed), which also halves storage. - Filters can return fewer rows than you asked for, because the filter is applied
after the index scan. Since version 0.8.0, turn on iterative scans
(
set hnsw.iterative_scan = strict_order;) so Postgres keeps looking. - Match the dimension to your model. A
vector(384)column only accepts 384-dimension embeddings; changing models means a new column and re-embedding.
Used in
No workflows use this yet. Browse all →