In plain words
A normal database finds exact matches: the order with ID 4521, every customer in Pune. That is no help when you search "cheap trip to Goa" and the best page says "budget holiday packages". The words don't match, but the meaning does.
AI models can turn any text, image or song into a list of numbers, called an embedding, where similar meanings get similar numbers. Think of each item as a dot on a giant map of meaning, with related things clustered together.
A vector database stores millions of these dots and, given a new dot for your question, finds its nearest neighbours in a fraction of a second. It is the search engine behind many AI features, especially RAG, where a chatbot looks up your documents before answering.
Everyday example
A library shelved by topic, not title
Imagine a library where books are not sorted alphabetically but placed by what they are about: cookbooks beside each other, travel guides in one corner, cricket histories in another. Walk in asking for "a cheap Goa trip" and you go straight to the travel corner and grab the three closest books. A vector database is that library, built in numbers.
Where the example breaks: A real library has two dimensions of floor space. Embeddings place items in hundreds or thousands of dimensions at once, which is why similar items can be close in many different ways.
How it actually works
"Vector" here just means a list of numbers. The hard part is searching millions of them quickly.
Embed and store
An embedding model converts each item, often a chunk of a document, into a vector of hundreds to thousands of numbers. The database stores each vector with a pointer to the original and optional labels (metadata) like date or author.
Measure similarity
Closeness is measured with a formula, most often cosine similarity, which compares the angle between two vectors: 1 means pointing the same way, 0 unrelated. Your query is embedded with the same model so it lands on the same map.
Search approximately, but fast
Comparing a query with every stored vector is too slow at scale. Indexes such as HNSW build a layered graph linking nearby vectors, and the search hops through it toward the closest ones. The result is approximate nearest neighbours: almost always the right answers, much faster.
Filter and return
Results can be filtered by metadata (only this year, only this team) before or after the vector search. The top matches go back to the app, often to be pasted into a model's prompt.
- Key index method
- HNSW (Hierarchical Navigable Small World graphs), described by Malkov and Yashunin in 2016
- Early milestone
- Facebook released FAISS, a similarity search library, in March 2017, demonstrating search over 1 billion vectors
- Examples
- Dedicated services like Pinecone, plus vector add-ons to existing databases such as pgvector for PostgreSQL
- Used for
- RAG, semantic search, recommendations, finding duplicate images, chatbot memory
Questions people ask
What is a vector database used for?
Finding things by meaning rather than exact words: matching a question to the right help article, recommending similar products, finding look-alike images, and feeding relevant passages to a chatbot through RAG.
How is a vector database different from a normal database?
A normal database answers exact questions: rows where city equals Pune. A vector database answers "what is most similar to this?" by comparing number lists. Many systems now combine both, and popular databases have added vector search features.
Do you need a vector database for RAG?
Not always. A few hundred documents can be searched with a simple in-memory index or plain keyword search. A vector database earns its place when collections are large, change often, or need fast filtered search.
What is an embedding in a vector database?
It is the stored list of numbers representing one item's meaning, produced by an AI model. Two items with similar meaning get similar numbers, which is what lets the database find related things. See embedding.