A vector database stores documents alongside their embeddings and answers queries by nearest-neighbour search in vector space. Because exact nearest-neighbour search is expensive at scale, these systems rely on approximate methods such as the HNSW graph index of Malkov & Yashunin (2018), and GPU-accelerated search libraries like FAISS (Johnson et al., 2017).
The result is sub-second semantic retrieval over millions of passages — the storage layer that makes retrieval-augmented generation practical.
What is a vector database used for?
A traditional database finds rows that match a value exactly; a vector database finds items that are close in meaning. A search for "how do I reset my password" can return a help article titled "Recovering account access" even though the two share almost no words. That makes vector databases the backbone of:
- Semantic search over help centres, wikis and document archives
- RAG chatbots that answer from private documents
- Recommendations — "more like this" for products, articles or songs
- Duplicate and near-duplicate detection
- Image and audio similarity search
How a vector database works
- 1Embed and store. Each item is converted into an embedding by an embedding model and stored with its original content and metadata.
- 2Index. Vectors are organised in an approximate index such as HNSW, which trades a little accuracy for large speed gains.
- 3Query. The query is embedded with the same model, and the database finds the nearest vectors under a similarity measure such as cosine similarity.
- 4Filter and return. Most systems combine the similarity search with metadata filters (date, author, permissions) and return the top matches, often passed to a reranker.
Vector database vs traditional database
| Traditional database | Vector database | |
|---|---|---|
| Matches on | Exact values and keywords | Closeness in meaning |
| Query | SQL or key lookups | An embedding of the question |
| Index | B-tree or inverted index | Approximate nearest-neighbour index (e.g. HNSW) |
| Result | Every row that matches | The top-k most similar items, ranked |
Options range from dedicated vector databases such as Pinecone, Weaviate, Milvus, Qdrant and Chroma to vector-search extensions for existing databases, such as pgvector for PostgreSQL. For many teams, adding vector search to a database they already run is simpler than operating a separate system.