vector
Store embeddings and find the nearest ones (pgvector, HNSW and IVFFlat indexes).
What it is for
pgvector adds a vector column type and distance operators: <-> for Euclidean distance, <=> for cosine distance and <#> for negative inner product. With an HNSW or IVFFlat index, nearest-neighbour queries over embeddings stay fast as the table grows.
Keep embeddings next to the rows they describe, so one query can filter by tenant or permissions (and row level security) and rank by similarity at the same time.
Enable it
create extension if not exists vector with schema extensions;Example
create table documents (
id bigserial primary key,
content text not null,
embedding vector(1536)
);
create index on documents using hnsw (embedding vector_cosine_ops);
-- five closest documents to a query embedding
select id, content
from documents
order by embedding <=> $1
limit 5;Notes
- The console and API can also create a ready-made semantic search table: POST .../extensions/vector/search-table.
Questions
How do I enable vector?
Run create extension if not exists vector with schema extensions; in the SQL editor, or switch it on from the Extensions page in the console. You do not need superuser access.
Which version of vector is installed?
0.8.7, on Postgres 17.6, as read from the running engine on 2026-10-08. Check yours with: select extversion from pg_extension where extname = 'vector';
Upstream project: github.com/pgvector/pgvector