A vector database stores embeddings and returns the vectors closest to a query vector. It does this with an approximate nearest neighbor (ANN) index, which finds close vectors without scoring every row.
A relational database indexes for exact matches and ranges. A B-tree keeps values in one sorted order. Similarity has no such order, because closeness depends on every dimension at once. So plain SQL scores every row against the query.
-- no ordinary index helps: every row gets a distance
SELECT id FROM docs
ORDER BY embedding <-> :query_vector
LIMIT 10;
That is fine for 10,000 rows and painful for 10 million. A vector database adds the ANN index, metadata filters in the same query, and storage sized for large vectors. Extensions like pgvector bring those indexes into Postgres, which blurs the line.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓