Blog
3 min read

What Is a Vector Database? Explained for Beginners

A vector database stores embeddings — lists of numbers that capture meaning — and finds the ones closest to a query. Why AI apps use them for search and RAG, how they work, the main options (pgvector, Pinecone, Qdrant, Chroma), and why you may not need a separate one.

A vector database is a database built to answer one kind of question very fast: "which of these items is most similar in meaning to this one?"

It's a key piece of many AI features — searching documents by meaning, chatbots that answer from your own content, recommendations.

First: what's a vector?

AI models can turn a piece of text (or an image) into a list of numbers called an embedding or vector — often 768, 1,024 or 1,536 numbers long. (What are embeddings?)

The useful property: texts with similar meanings get similar numbers. "How do I reset my password?" and "I forgot my login" end up close together, even though they share no words. "Refund policy" ends up far away.

You can picture each vector as a point in space. Similar meanings cluster together.

What a vector database does

  1. Store vectors, each linked to the original item (a document chunk, a product, a support article) and some metadata.
  2. Search: given a new vector (from the user's question), find the stored vectors nearest to it.

That's called similarity search or nearest-neighbour search. Closeness is usually measured with cosine similarity — roughly, whether two vectors point in the same direction.

Why not just use a normal database?

A normal query asks "find rows where title contains 'password'". That only matches exact words. (Semantic vs keyword search)

Comparing a query against millions of vectors one by one would be slow, so vector databases use special indexes (with names like HNSW or IVF) that find approximately the nearest neighbours very quickly. "Approximately" is fine — the results are almost always the same as a perfect search.

What it's used for

  • RAG (retrieval-augmented generation): find the most relevant chunks of your documents, then give them to an LLM to answer a question. This is how "chat with your docs" bots work. (What is RAG?)
  • Semantic search: a search box that understands meaning.
  • Recommendations: "products similar to this one".
  • Deduplication: spotting near-identical support tickets or listings.

The main options

Postgres with pgvector — an extension that adds vector columns and indexes to the Postgres database you may already have. One database for everything. (pgvector tutorial)

Dedicated vector databases — Pinecone (hosted service), Qdrant, Weaviate, Milvus, Chroma. Built for vectors first, with features for very large scale.

Built into other tools — Supabase (via pgvector), MongoDB Atlas, Redis, Elasticsearch and others now offer vector search too.

Do you need a separate one?

Usually not, at first. If your app already uses Postgres, pgvector handles hundreds of thousands to millions of vectors comfortably, and keeps your vectors next to the data they describe — so you can filter by user, permissions or date in the same query.

A dedicated vector database starts to make sense when you have many millions of vectors, very high query volumes, or need features your main database lacks. That's a good problem to have later.

A tiny example with pgvector

CREATE EXTENSION vector;

CREATE TABLE docs (
  id bigserial PRIMARY KEY,
  content text,
  embedding vector(1024)
);

-- find the 5 chunks closest to a query embedding
SELECT content
FROM docs
ORDER BY embedding <=> $1
LIMIT 5;

<=> is cosine distance. Your app creates the query embedding with an embeddings API, then passes it in as $1.

The summary

  • Embeddings turn meaning into numbers; similar meaning → nearby vectors.
  • A vector database stores them and finds the nearest ones fast.
  • It powers RAG, semantic search and recommendations.
  • Start with pgvector in Postgres; move to a dedicated one only if you outgrow it.

EasySpawn gives each app a Postgres database with pgvector available, so your data and your embeddings live in one place with daily backups. See how it works or join the waitlist.

Related: What Are Embeddings? · What Is RAG? · pgvector Tutorial · What Is a Database?

Keep reading