What Is a Vector Database?
A vector database is a specialized database designed to store, index, and query high-dimensional vectors (embeddings). Unlike traditional databases that search by exact matches or range queries, vector databases find the most similar vectors to a given query vector — enabling semantic search, recommendation systems, and RAG pipelines at scale.
Why Traditional Databases Can't Do This
Traditional relational databases are optimized for exact matches (WHERE name = 'John') and range queries (WHERE price < 100). But finding semantically similar text requires comparing a 1536-dimension vector against millions of other vectors — an operation traditional databases handle poorly.
Vector databases solve this with specialized indexing algorithms that make similarity search fast even across billions of vectors.
How Vector Databases Work
Storage
Vectors (arrays of floating-point numbers) are stored alongside metadata (source document, timestamps, categories) that enables filtering.
Indexing
Specialized indexes organize vectors for fast approximate search:
| Index Type | Description | Speed | Accuracy |
|---|---|---|---|
| HNSW | Hierarchical Navigable Small World graphs | Very fast | High |
| IVF | Inverted File Index with clustering | Fast | Good |
| Flat | Brute-force comparison (no index) | Slow | Perfect |
| PQ | Product Quantization (compressed) | Fast | Moderate |
Querying
- Convert the search query into an embedding vector
- Search the index for the nearest neighbors
- Apply metadata filters (optional)
- Return top-K most similar results with similarity scores
Key Vector Databases
| Database | Type | Highlights |
|---|---|---|
| Pinecone | Managed cloud | Fully managed, serverless option |
| Weaviate | Open-source | Hybrid search, multi-modal |
| Milvus | Open-source | Highly scalable, GPU-accelerated |
| Chroma | Open-source | Lightweight, developer-friendly |
| Qdrant | Open-source | Rust-based, high performance |
| pgvector | PostgreSQL extension | Add vector search to existing Postgres |
Vector Databases in RAG
In Retrieval-Augmented Generation systems, vector databases serve as the knowledge retrieval layer:
- Documents are chunked and embedded during ingestion
- Embeddings are stored in the vector database
- At query time, the user's question is embedded
- The vector database returns the most semantically similar document chunks
- These chunks are provided as context to the LLM for grounded generation
Key Considerations
- Dimensionality — Higher dimensions capture more meaning but require more storage and compute
- Distance Metric — Cosine similarity, dot product, or Euclidean — must match the embedding model
- Filtering — Ability to combine vector search with metadata filters
- Scalability — From thousands to billions of vectors
- Freshness — How quickly new data becomes searchable