LearnThatStack Ace your next interview
Embeddings & Vector Databases · question
Question 4 of 56

What is a vector database, and why can't you just use a regular relational database for similarity search?

beginner
← All Embeddings & Vector Databases questions
Re-explain

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.

Rewriting in plainer words…

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 ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for Embeddings & Vector Databases One question at a time. Answer out loud, get graded, see what you missed.
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

What you can say

  1. A vector database stores embeddings and, given a query vector, returns the stored vectors closest to it.
  2. It does that with an approximate nearest neighbor index, which finds close vectors without scoring every row.
  3. A relational index like a B-tree keeps values in one sorted order, and that works for exact matches and ranges.
  4. Similarity has no single order, because closeness depends on every dimension at once, so plain SQL ends up computing a distance for every row.
  5. That full scan is fine for ten thousand rows and painful for ten million, so vector databases add the ANN index, filters in the same query, and storage for big vectors.
  6. The line has blurred, though. Extensions like pgvector put ANN indexes inside Postgres, so often the real question is whether you need a separate system at all.

Weak answers to avoid

  • Claims SQL databases can't store vectors They store them fine as arrays or a vector column. The real limit is the index. A B-tree can't order by closeness, so each query scans every row.
  • Treats ANN results as exact ANN trades some recall for speed and can miss true neighbors. Say it is approximate and that you would measure recall against an exact scan.
  • Says relational databases are useless here pgvector adds ANN indexes to Postgres, so one database can be enough. Say what would make you move to a dedicated system.
  • Stops at 'it stores embeddings' That skips the 'why not SQL' half. Explain that similarity has no single sort order, so an ordinary index can't answer 'closest to this vector'.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the Embeddings & Vector Databases cheatsheet.

← Back to all Embeddings & Vector Databases questions
Pro · $10/mo

49 of 56 Embeddings & Vector Databases answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime