Vector Database
What is Vector Database?
A vector database is a database designed to store embeddings, numerical representations of the meaning of text, images or other data, and to search them quickly for items with similar meaning.
Updated November 2026 · 2 min read
A vector database is a database designed to store embeddings and find the ones closest in meaning to a query. An embedding is a list of numbers that represents the meaning of a piece of text, an image or other data, produced by an embedding model. Texts with similar meanings get similar numbers, so "how do I cancel my subscription?" and "steps to end my membership" end up close together, even though they share few words. A vector database makes it possible to search millions or billions of these embeddings in milliseconds.
Vector databases became widely used with retrieval-augmented generation (RAG), where an AI assistant searches an organization's documents for relevant passages and uses them to answer questions. Options range from dedicated vector databases, such as Pinecone, Weaviate, Milvus and Qdrant, to vector search added to existing databases, such as the pgvector extension for PostgreSQL, and to search engines and cloud data platforms.
How does a vector database work?
Comparing a query with every stored embedding would be too slow at scale. Vector databases use approximate nearest neighbor (ANN) indexes, which trade a tiny amount of accuracy for very large speed gains. HNSW (hierarchical navigable small world), described in research by Yury Malkov and Dmitry Yashunin in 2016, is one of the most widely used index types.
What are vector databases used for?
- Retrieving relevant documents for AI assistants.
- Semantic search across knowledge bases.
- Recommendations based on similarity.
- Finding duplicate or near-duplicate content.
- Semantic caching of AI responses.
- Giving agents long-term memory.
Cost drivers
- Embedding generation: creating embeddings for every document, and again when the embedding model changes.
- Storage and memory: many indexes perform best when held in memory, which is expensive at scale. Embedding dimensions and precision affect size.
- Query volume.
- Updates: keeping embeddings current as documents change.
An example
Consider a hypothetical law firm building an assistant over 2 million documents. Its first design uses a dedicated vector database holding full-precision embeddings in memory, which is fast but expensive. Testing shows that storing embeddings as 8-bit integers instead of 32-bit floating-point numbers cuts memory needs by about three-quarters with no measurable effect on retrieval accuracy for its test questions. The firm also adds metadata filters for client and matter, so searches only cover documents each lawyer is permitted to see, which both enforces access rules and speeds up search.
Common pitfalls
- Adding a new database when an existing one with vector search would do.
- Ignoring access controls, so retrieval surfaces documents users should not see. See AI data governance.
- Poor chunking, splitting documents in ways that separate questions from their answers.
- Not budgeting for re-embedding when switching embedding models.
Vector search often works best combined with keyword search, and connects to broader approaches such as knowledge graphs and GraphRAG.
Frequently asked questions
How does a vector database search millions of embeddings so quickly?
A vector database avoids comparing a query with every stored embedding by using approximate nearest neighbor indexes, which give up a tiny amount of accuracy for very large speed gains. HNSW, short for hierarchical navigable small world and described by Yury Malkov and Dmitry Yashunin in 2016, is one of the most widely used index types.
Do you need a dedicated vector database for retrieval-augmented generation?
Not always. Dedicated vector databases such as Pinecone, Weaviate, Milvus and Qdrant are one option, but vector search is also available in existing databases, such as the pgvector extension for PostgreSQL, and in search engines and cloud data platforms. Adding a new database when an existing one with vector search would do is a common mistake.
What drives the cost of running a vector database?
Vector database costs come from generating embeddings, including re-embedding everything when the embedding model changes, from storage and memory, query volume and keeping embeddings current as documents change. Many indexes perform best in memory, which is expensive at scale. Storing embeddings as 8-bit integers instead of 32-bit floats cuts memory needs by about three-quarters.
Related terms
Semantic Caching
Reusing answers for requests that mean the same thing, however worded.
Serverless Inference
Running models with provider-managed scaling and no charge for idle time.
Self-Hosted LLM
A language model run on infrastructure the organization controls.
Open-Weight Models
Models whose weights anyone can download, run and adapt under license.