What is Vector Database?
A vector database is a datastore that persists vector embeddings and retrieves nearby records under a defined distance metric. Production implementations also manage stable identifiers, metadata filters, updates, deletion, durability, observability, and access control around exact or approximate nearest-neighbor search.
Quick Facts
| Created | Concept emerged in 2010s, popularized with LLMs in 2022-2023 |
|---|---|
| Specification | Official Specification |
How It Works
Exact and approximate search
Exact search compares every eligible vector and returns the true top-k under the configured metric. It is a useful small-scale solution and the Ground Truth for evaluating an ANN index. HNSW navigates a layered proximity graph; IVF searches selected clusters; product quantization stores lossy codes to reduce the working set. None is universally best because recall, tail latency, memory, build time, filtering, and update rate move together.
Filtering and authorization
Tenant, ACL, lifecycle, language, and document filters are part of retrieval correctness. Post-filtering ANN candidates can return fewer than k eligible records or miss relevant authorized neighbors, while pre-filtering and filter-aware traversal have different cost profiles. Authorization scope must come from trusted server-side identity and must also be present in cache keys, rebuilds, retries, and failover tests.
Embedding lifecycle
Vectors generated by different model revisions, task modes, preprocessing rules, dimensions, normalization policies, or metrics should be treated as separate embedding generations. A safe migration backfills a new generation, reconciles records and deletions, shadow-tests both generations on the same labeled queries, switches an alias after quality gates pass, and keeps the previous generation for rollback.
System boundary
The vector database is a candidate-retrieval layer, not the complete search or RAG system. Chunking, embedding quality, lexical retrieval, reranking, context assembly, citation, and answer evaluation remain separate responsibilities. The vector database guide explains storage selection, benchmark design, recovery, and total cost.
Key Characteristics
- Stores vectors together with stable IDs, model-generation metadata, filter fields, and source references
- Supports exact search and/or ANN indexes whose recall must be measured against an exact baseline
- Uses a distance metric that must match the embedding model and normalization contract
- Combines similarity retrieval with metadata, tenant, ACL, and lifecycle predicates
- Defines observable insert, update, delete, rebuild, backup, and restore behavior
- Trades recall, p95/p99 latency, memory, freshness, and cost rather than maximizing one metric in isolation
Common Use Cases
- Semantic search over documents, code, products, images, or audio
- RAG candidate retrieval with source IDs and authorization filters
- Recommendation and similar-item retrieval
- Duplicate detection, clustering support, and anomaly candidate discovery
- Multimodal retrieval when compatible representations share a search contract
Example
Loading code...Frequently Asked Questions
What is the difference between a vector index and a vector database?
A vector index is the search data structure or library that finds nearest neighbors. A vector database surrounds that index with durable records, identifiers, metadata filtering, mutation APIs, replication or backup, observability, and security controls. Faiss is an index library; pgvector adds vector indexing to PostgreSQL; dedicated services package indexing with their own storage and operational model.
Does every RAG system need a separate vector database?
No. Exact search can be sufficient for a small or tightly partitioned corpus. PostgreSQL plus pgvector can keep vectors with transactional data, while a search engine can combine lexical ranking, facets, and vectors. Add a dedicated system only when measured recall, filtered latency, write rate, distribution, or operational requirements exceed the simpler option.
How do HNSW and IVF differ?
HNSW searches a layered proximity graph and often offers a strong recall-latency trade-off, with graph memory and build or maintenance cost. IVF trains centroids, assigns vectors to lists, and probes selected lists, often using less index memory but depending on representative training data and probe count. Compare both at the same Recall@K target.
Why can metadata filtering reduce ANN recall?
Some systems retrieve approximate neighbors first and apply filters afterward. If only a small fraction of candidates pass a tenant, date, or ACL filter, the query may return fewer than k results or miss closer eligible records. Filter-aware traversal, iterative scans, partitioning, oversampling, or exact search can help, but the right choice depends on measured selectivity.
Can embeddings from different models share one vector index?
They should not be compared unless the model provider explicitly guarantees a compatible vector space. Model revision, task mode, preprocessing, dimensions, normalization, and metric form one embedding contract. Store generations separately, backfill the new generation, evaluate both on the same queries, switch through an alias, and preserve rollback.