A vector database helps software find things that resemble other things. Instead of asking only for an exact word or an order number, an application can ask for documents, images or products whose numerical representations are close to a query.
That makes it useful for modern AI, but it is not a tiny brain in a filing cabinet. It does not understand your documents, guarantee correct answers or automatically give a chatbot a memory. The interesting part is how it helps an application retrieve useful material.
Table of Contents
- What is a vector database?
- Vectors and embeddings
- How the search works
- Why it matters for AI
- Practical uses
- Vector versus traditional databases
- Choosing an approach
- Common pitfalls
- FAQ
What Is a Vector Database?
A vector is an ordered list of numbers. A vector database stores those lists and supports similarity searches, usually alongside identifiers and metadata that connect results to the original material.
Imagine a library where books have positions on a map according to their subject and style. Asking for something similar to a favorite book becomes a search around its position. In a real embedding space there can be hundreds or thousands of coordinates, and the map depends on the model that created it.
The librarian has not become omniscient. A nearby book may still be outdated, misleading or simply the wrong recommendation for you.
Vectors, Embeddings and Meaning
An embedding represents an item as a vector. For semantic text search, an embedding model is trained so that useful relationships in language can be reflected in numerical proximity. Other models represent images, audio or combinations of media.
A search for âa feline sleeping in sunlightâ might retrieve a caption about âa cat napping by the window,â despite the different wording. That is an illustration of the intended behavior, not a guarantee that every model will rank that pair correctly.
The dimensions are not normally neat labels such as âcatness,â âsunshineâ and âlikelihood of knocking over a glass.â Their usefulness comes from the representation as a whole.
Models differ in training, supported languages, input length and the tasks they handle well. A representation that works for short product descriptions may be a poor choice for specialist legal passages. Choosing the database cannot rescue an unsuitable embedding model.
How a Vector Search Works
- Prepare the source material, splitting long documents into useful passages when appropriate.
- Generate embeddings and store them with identifiers and relevant metadata.
- Represent the search query in the compatible embedding space.
- Find nearby vectors using a distance or similarity measure.
- Return the associated material, applying the applicationâs permissions and other requirements.
Cosine similarity, dot product and Euclidean distance are common choices. They are not interchangeable under every setup: normalization and vector magnitude matter. Use the embedding modelâs guidance and evaluate results rather than selecting whichever metric sounds most mathematical.
Exact Search and Approximate Neighbors
Exact search finds the nearest results under the chosen metric. Approximate nearest-neighbor search, or ANN, can reduce the work by using an index to narrow the search. It may miss some of the true nearest neighbors; how much depends on the index, settings and data.
HNSW uses a graph-based approach, while other methods organize or compress the search space differently. The 2017 research behind Faiss explored GPU implementations for brute-force, approximate and compressed search. Even at large scale, the engineering choice is more nuanced than âexact search is impossible.â
A small collection may not need an approximate index at all. At larger scale, compare speed, recall and resource use on representative queries. âFastâ is much less impressive if the missing result was the one you needed.
Why Vector Databases Matter for AI
A language model can generate an answer without searching a database. Its context window can also contain previous messages directly. Neither behavior proves that a vector store is involved.
Retrieval adds a different capability: finding material to supply with a question. Our guide to retrieval-augmented generation, or RAG, explains how that material can inform an answer.
Vector search is one retrieval method. Keyword search, structured database queries and combinations of methods can also be appropriate. An exact invoice number, for example, is not an invitation to return something with a similar emotional atmosphere.
The retrieved text still needs to be relevant and trustworthy. A generator can misunderstand a good source, and a very efficient search can retrieve a bad one. Retrieval is useful infrastructure, not an automatic truth certificate.
Where Similarity Search Is Useful
- Document discovery: finding passages that discuss a question without repeating its exact wording.
- Visual search: retrieving images or products with similar visual features, using a suitable image model.
- Recommendations: generating candidate items that resemble a userâs interests, before other ranking rules apply.
- Code search: looking for relevant functions or examples through representations designed for code.
- Duplicate detection: identifying items worth checking for substantial similarity.
These are possible designs, not a claim that every recommendation feed or coding assistant uses the same architecture. Similarity also needs interpretation: two support tickets can discuss the same product while requiring opposite answers.
Do Vector Databases Replace Traditional Databases?
No. Relational databases remain useful for structured records, relationships, transactions and exact conditions. Similarity search addresses another kind of question, and the two can live together.
Postgres with pgvector, for example, supports vector storage and exact or approximate nearest-neighbor search alongside SQL, joins and PostgreSQLâs transaction features. Its documented indexes include HNSW and IVFFlat.
A dedicated vector service may suit a workload that needs separate scaling or a different operational setup. That does not mean a relational extension becomes unsuitable at a magic number of vectors. Data size, query mix, filters, update frequency and latency requirements all matter.
How to Choose an Approach
Start with the application rather than a vendor popularity contest. Three broad approaches are worth comparing:
- Add vector search to an existing database: potentially convenient when the source records and permissions already live there.
- Use a dedicated service: evaluate the search features, deployment model, backup options and operational responsibilities it offers.
- Use a search library inside an application: useful when you can handle persistence, access control and service behavior yourself.
A library and a managed database are not equivalent packages. One may provide the nearest-neighbor machinery while leaving most of the surrounding plumbing to you.
Test a small representative collection first. Include awkward queries, exact identifiers, restricted documents and recent updatesânot just the five examples that make the demo look psychic. Then estimate the full bill: embedding generation, storage, search, reranking, backups and operations.
The Pitfalls Behind the Demo
Storage Is Not the Same as RAM
One billion vectors with 1,536 coordinates stored as four-byte numbers require about 6.14 TB for those numbers alone. That arithmetic does not mean the entire collection must always sit in RAM. Index design, compression and storage architecture affect memory needs; metadata, indexes and replicas add further storage costs.
Changing Models Changes the Map
Vectors from incompatible models should not be mixed just because they have the same number of dimensions. A migration may require re-embedding the source material. Keeping the previous model and index available can help during a transition; the old vectors do not suddenly cease to work with their original setup.
Similarity Can Miss What Matters
Long, badly split passages can bury the answer. Very short fragments can lose context. Keyword retrieval and reranking can help in some workloads, but they need measurement rather than automatic inclusion in every system.
Build a set of questions with expected useful sources. Check whether the system retrieves them, whether it excludes irrelevant material and whether it respects filters. A polished answer is not evidence that retrieval succeeded.
Permissions and Privacy Still Apply
Enforce authorization before restricted material reaches the language model. Keep deletions and updates consistent across the source records and search index.
Embeddings should not be assumed anonymous. A 2023 embedding-inversion study recovered text and personal information under its experimental conditions. That does not mean every vector can always be decoded, but turning text into numbers is not a privacy guarantee.
Frequently Asked Questions
Does every chatbot need a vector database?
No. A chatbot can use conversation history directly or retrieve information through other methods. Choose vector search when similarity retrieval solves an actual problem.
Is a vector database the same as an LLM?
No. One stores and searches representations; the other generates language. Our guide to how LLMs work explains the model side.
Does a higher similarity score mean an answer is true?
No. It measures a relationship under a particular representation and metric. A false document can be highly relevant to your question.
Do I need one to use MCP?
No. MCP connects AI applications to tools and data; it does not require those tools to use vector storage.
What should I try first?
A small comparison between straightforward keyword retrieval and a suitable embedding search, using real questions. Let the results justify extra machinery. Even an AI project deserves permission to have a boring, effective filing cabinet.




