AI Model Wiki

    Skip to main content
    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

    DatabaseTypeBest ForPricing Model
    PineconeManaged cloudProduction SaaS appsPer-vector storage + queries
    WeaviateSelf-hosted/cloudMultimodal searchOpen source + cloud tiers
    ChromaDBEmbedded/localPrototyping, small appsFree (open source)
    QdrantSelf-hosted/cloudHigh-performance filteringOpen source + cloud tiers
    MilvusSelf-hostedLarge-scale enterpriseOpen source
    pgvectorPostgreSQL extensionExisting Postgres usersFree (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:

    1. Scale: <100K vectors? pgvector or ChromaDB. Millions? Pinecone or Qdrant. Billions? Milvus.
    2. Latency requirements: Real-time search needs HNSW. Batch processing can use IVF.
    3. Filtering complexity: Need complex metadata filters? Qdrant and Weaviate excel here.
    4. Deployment preference: Managed (Pinecone) vs. self-hosted (Qdrant, Milvus).
    5. 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.