Overview
Vector databases are specialized storage systems optimized for indexing and querying high-dimensional vector embeddings. Unlike traditional databases that search by exact match or range queries, vector databases perform approximate nearest neighbor (ANN) search to find the most similar vectors to a query vector. This capability is essential for semantic search, recommendation systems, and RAG architectures where meaning matters more than exact keywords. Popular implementations include Pinecone, Weaviate, Qdrant, ChromaDB, and pgvector (PostgreSQL extension), each offering different trade-offs between scale, latency, and operational complexity.
Key Concepts
- Embeddings — Dense numerical vectors that capture semantic meaning. Generated by embedding models (e.g., OpenAI ada-002, Cohere embed, sentence-transformers).
- ANN algorithms — Approximate Nearest Neighbor algorithms trade perfect accuracy for dramatically faster search. Common approaches: HNSW (graph-based), IVF (inverted file), and LSH (locality-sensitive hashing).
- Distance metrics — Cosine similarity, Euclidean distance, and dot product measure how “close” two vectors are. Choice depends on the embedding model used.
- Metadata filtering — Combining vector similarity search with traditional filters (date, category, source) to constrain results.
- Dimensionality — Number of values in each vector (typically 384–1536). Higher dimensions capture more nuance but increase storage and computation cost.
- Index types — Flat (exact, slow), HNSW (fast, memory-intensive), IVF (balanced), PQ (compressed, approximate). Selection depends on dataset size and latency requirements.
Trade-offs
- ANN search sacrifices perfect recall for speed (configurable trade-off)
- Dedicated vector DBs vs embedded solutions (pgvector) — operational complexity vs simplicity
- High dimensionality improves semantic precision but increases storage costs
- Index rebuild cost on data changes varies significantly by algorithm
Related
- RAG is the primary use case driving vector database adoption
- Embeddings are the data type that vector databases store and search
- Caching Strategies apply to vector search results to reduce latency