StudyVisuallyStart studying
Part 05 · Embeddings + RAG · Card 4 of 14

Vector database

A database that stores embeddings and finds the nearest ones fast. pgvector (Postgres), MongoDB Atlas Vector Search and Pinecone are common.

Last updated

Analogy

An index, but for meaning. Postgres with one extension and a new operator.

Code example

search.sqlSQL
-- <=> is cosine distance in pgvector (smaller = closer)
SELECT content
FROM docs
ORDER BY embedding <=> $1
LIMIT 3;

In an agent

It's the long-term library your agent searches. Postgres + pgvector can also hold memory and checkpoints.

Practice

Flashcards

  • What is a vector database?A database that finds the nearest embeddings fast, like pgvector or Pinecone.

Questions people ask

Which vector database should a JavaScript developer use?

If you already run Postgres, start with the pgvector extension: one extension, one new column type, and your vectors live next to your normal data. MongoDB Atlas Vector Search and Pinecone are common alternatives. For learning and small projects, any of them is fine.

What does a vector database actually do?

It stores embeddings with their text and finds the nearest ones to a query vector quickly, even across millions of rows. In pgvector you order by embedding <=> your query vector and take the top few. For an agent it is the long-term library that the search tool reads from.