16 min read
Lesson 2 of 6
Vector Databases: Architecture & Options
From the course AI Embeddings & Vector Databases
Storing and searching millions of vectors efficiently requires specialized databases. Traditional databases use B-trees for exact lookups; vector databases use approximate nearest neighbor (ANN) algorithms for similarity search.
Why Not Just Use PostgreSQL?
You can store vectors in PostgreSQL with pgvector, and for small-to-medium datasets (<1M vectors), this works well. But dedicated vector databases offer:
- Faster search at scale: Optimized ANN indexes that search billions of vectors in milliseconds
- Filtering: Combine vector similarity with metadata filters efficiently
- Managed infrastructure: Auto-scaling, replication, backups
Top Vector Databases Compared
| Database | Type | Best For | Pricing Model |
|---|---|---|---|
| Pinecone | Managed cloud | Production SaaS apps | Per-vector storage + queries |
| Weaviate | Self-hosted/cloud | Multimodal search | Open source + cloud tiers |
| ChromaDB | Embedded/local | Prototyping, small apps | Free (open source) |
| Qdrant | Self-hosted/cloud | High-performance filtering | Open source + cloud tiers |
| Milvus | Self-hosted | Large-scale enterprise | Open source |
| pgvector | PostgreSQL extension | Existing Postgres users | Free (extension) |
ANN Index Types
- HNSW (Hierarchical Navigable Small World): Best all-around. Fast queries, good recall, but memory-intensive. Used by most modern vector DBs.
- IVF (Inverted File Index): Clusters vectors and searches relevant clusters. Lower memory but requires training.
- ScaNN: Google's ANN library. Excellent for large-scale deployments.
Choosing the Right Database
Consider these factors:
- Scale: <100K vectors? pgvector or ChromaDB. Millions? Pinecone or Qdrant. Billions? Milvus.
- Latency requirements: Real-time search needs HNSW. Batch processing can use IVF.
- Filtering complexity: Need complex metadata filters? Qdrant and Weaviate excel here.
- Deployment preference: Managed (Pinecone) vs. self-hosted (Qdrant, Milvus).
- Budget: Open-source options are free but require ops expertise.
Key Takeaways
- •Vector databases use ANN algorithms like HNSW for sub-millisecond similarity search at scale
- •pgvector works well under 1M vectors; dedicated vector DBs are needed beyond that
- •HNSW is the most popular index type — fast queries with high recall
- •Choose based on scale, latency needs, filtering complexity, and ops capacity
0 of 6 lessons marked complete
Progress is kept in this browser only.