What is a vector database? Search by meaning, explained simply

A normal database finds exact matches. A vector database finds things that mean something similar, even with different words. Here is what a vector database is, how it searches millions of items fast, and when you actually need one.

Two search boxes side by side, both searching for: cheap phone. On the left, a regular database looks for the exact words and finds nothing in a list that contains budget mobile under 10,000 rupees and affordable smartphone deals. On the right, a vector database compares meanings and returns both of those items as close matches, with similarity scores marked illustrative.
Fig. 1 — A regular database matches words. A vector database matches meaning. (Scores are illustrative.)

Search an online shop for “cheap phone”. An old-style search looks for products whose titles contain the words “cheap” and “phone”. A listing called “Budget mobile under ₹10,000” doesn’t match, so you never see it, even though it’s exactly what you wanted.

A vector database fixes that. Instead of matching words, it matches meaning. It’s the storage and search engine behind many AI features, from “similar products” to chatbots that answer from your documents. This guide explains what a vector database is, how it works, and when you need one.

What is a vector database?

A vector database is a database built to store vectors (lists of numbers, usually embeddings) and to quickly find the stored vectors most similar to a given one.

Each item you store, such as a paragraph, a product description, an image or a song, is first turned into an embedding by an AI model. Items with similar meanings get similar numbers. The vector database then answers questions like: “Which 5 stored items are closest in meaning to this one?”

Regular database vs vector database

Regular database Vector database
Stores Rows of text, numbers, dates Vectors (plus the original text and details)
Typical question “Find orders where city = Pune” “Find the 5 items most similar to this”
Matching Exact values, keywords Closeness in meaning
Example Customer records, invoices Semantic search, recommendations, RAG

They aren’t rivals. Most apps use both: a regular database for facts like prices and stock, and vector search for “find things like this”.

How does a vector database work?

1. Store

For each item, the app creates an embedding with an embedding model and saves it in the vector database, along with the original text or a link to it, and useful details (metadata) like category, date or price.

When a user searches, the app turns their query into an embedding using the same model, and asks the vector database for the nearest neighbours: the stored vectors closest to the query vector. Closeness is usually measured with cosine similarity or a distance measure.

3. Filter and return

The results can be filtered by metadata (for example “only products in stock” or “only documents this user can see”) and returned, closest first.

Two panels of scattered dots representing stored vectors, with a red star for the query. Left, check every vector: lines run from the star to every single dot, labelled exact, but slow at millions. Right, use an index like HNSW: the search starts at a far-away dot and hops through a few neighbouring dots, each closer to the star, labelled checks a small fraction: fast, approximate.
Checking every vector is exact but slow at large scale. An index jumps through a graph of neighbours to find close matches quickly. (Simplified.)

How does it search millions of vectors so fast?

Comparing a query with every stored vector works fine for small collections (thousands, even hundreds of thousands of items). With many millions or billions, it’s too slow. So vector databases build an index that allows approximate nearest neighbour (ANN) search: finding very close matches quickly, without checking everything.

A popular index is HNSW (Hierarchical Navigable Small World), introduced by Yury Malkov and Dmitry Yashunin. It links each vector to some of its neighbours in a layered graph. A search starts at the sparse top layer, takes big jumps towards the query, then moves down into denser layers for finer steps, like zooming in on a map: country, then city, then street.

The trade-off: ANN results are usually almost the same as a full search, but not guaranteed to be perfect. Settings let teams balance speed, memory and accuracy.

What are vector databases used for?

  • RAG (retrieval-augmented generation): finding the right passages from your documents before an AI answers. See what RAG is.
  • Semantic search: search help articles, products or files by meaning.
  • Recommendations: “you might also like” for products, songs, films or articles.
  • Image search: find similar photos, or search photos by describing them.
  • Duplicate detection: spot near-identical support tickets, listings or documents.
  • Memory for AI assistants: store and recall relevant past notes or conversations.

There are many choices, and they keep changing. Some well-known ones:

  • Dedicated vector databases such as Pinecone, Milvus, Weaviate and Qdrant
  • Lightweight, developer-friendly stores such as Chroma
  • Vector search added to existing databases, such as the pgvector extension for PostgreSQL, and vector search features in many other databases and search engines
  • Libraries such as FAISS, from Meta, for building vector search into your own code

For a small project, vector search inside a database you already use is often the simplest start.

Do you actually need a vector database?

  • A few dozen short documents? You might not need one. Simple in-memory search, or pasting the relevant documents into the prompt, can be enough.
  • Thousands to millions of items, searched often? A proper vector index makes a big difference.
  • Need exact matches, like order numbers or names? Use regular search or a normal database, sometimes alongside vector search. Many systems use hybrid search: keyword and vector search together.

Things to watch

  • Use one embedding model consistently. Vectors from different models can’t be compared. Changing models means re-embedding everything.
  • Search quality depends on the embeddings and the chunks, not just the database.
  • Keep it in sync. When a document changes or is deleted, update or remove its vectors.
  • Protect it. Embeddings of private text should be treated as sensitive data, and access rules should apply to search results too.

Common misconceptions

“A vector database understands meaning.” The embedding model captures meaning; the database stores the vectors and finds the closest ones quickly.

“You need a vector database to use AI.” Many AI apps don’t. It’s mainly useful when you search large collections by meaning.

“Vector search replaces keyword search.” They’re good at different things. Combining them often works best.

“Vector search results are always exact.” Large systems usually use approximate search, which is very close but not guaranteed perfect.

Key takeaways

  • A vector database stores embeddings and finds the ones closest in meaning to a query.
  • It works in three steps: store embeddings, search with the query’s embedding, filter and return.
  • Approximate nearest neighbour indexes like HNSW make search fast at large scale.
  • It powers RAG, semantic search, recommendations, image search and duplicate detection.
  • Options range from dedicated databases to pgvector in PostgreSQL; small projects may not need one at all.

Frequently asked questions

What is a vector database in simple words?

It’s a database that finds things by meaning instead of exact words, by storing lists of numbers (embeddings) and looking for the closest ones.

What is the difference between a vector database and a regular database?

A regular database finds exact matches, like a customer ID or a city name. A vector database finds items that are similar in meaning, even if they share no words.

Why do RAG systems use vector databases?

To quickly find the document passages most relevant to a question, so the AI can answer from them.

It’s a way to find very close matches quickly without comparing the query to every stored vector. It’s much faster at large scale, and the results are usually almost identical to a full search.

Can I use PostgreSQL as a vector database?

Yes. The pgvector extension adds vector storage and similarity search to PostgreSQL, including HNSW indexes.

Comments

LEAVE A COMMENT
No sign-up. Comments appear after a quick review.