Vector databases are the backbone of RAG (Retrieval Augmented Generation). This guide compares all top options.

Quick Overview

Database Price Self-Hosted Scalability RAG-Ready Best For
Pinecone $8+/Mo No Very High βœ… Managed Production
Qdrant Free/$150/Mo βœ… Yes Very High βœ… Open-Source + Scale
ChromaDB Free/$10/Mo βœ… Yes Low-Medium βœ… Development/MVP
Weaviate Free/$250/Mo βœ… Yes Very High βœ… Enterprise
pgvector $14+/Mo βœ… Yes High βœ… PostgreSQL-Native

Pinecone β€” Fully Managed

Pricing:

  • Starter (Free): 2GB storage, us-east-1 only
  • Standard Pay-as-you-go:
    • $0.00055 per 1000 vectors stored
    • $8.25 per 1M read units
    • $2 per 1M write units

Example Cost (1M vectors, 10k daily queries):

  • Storage: $0.55/Mo
  • Reads: $0.08/Mo
  • Minimum: $8/Mo
  • Realistic: $50-100/Mo

Strengths:

  • Easiest to deploy (signup β†’ code β†’ done)
  • Guaranteed performance (99.99% SLA)
  • Serverless scaling
  • Hybrid search capabilities

Weaknesses:

  • No self-hosting (vendor lock-in)
  • Expensive at 100M+ vectors scale
  • Minimum $8/Mo

RAG Integration:

from pinecone import Pinecone
pc = Pinecone(api_key="xxx")
index = pc.Index("my-index")

# LangChain integration
from langchain.vectorstores import Pinecone as PineconeVectorStore
vectorstore = PineconeVectorStore.from_documents(docs, embeddings)

Qdrant β€” Open-Source Flexibility

Pricing:

  • Self-Hosted: Free (open source)
  • Cloud Standard: ~$150/Mo (8GB RAM)
  • Self-Hosted VPS: $5-20/Mo

Best Feature: Open-source + production-ready

Benefits:

  • Free & open source (Rust, fast)
  • Self-hosting is first-class citizen
  • Hybrid search (vector + keyword)
  • Powerful filtering
  • Best value at scale

Cost Comparison (1M vectors, 10k queries):

  • Qdrant Self-Hosted: $15-25/Mo (VPS)
  • Pinecone: $8-50+/Mo (depends)
  • Qdrant wins at scale >10M vectors

Self-Hosted Setup:

docker run -p 6333:6333 qdrant/qdrant:latest

ChromaDB β€” MVP Speed

Pricing:

  • Open Source: Free
  • Cloud: ~$10/Mo (managed)
  • Self-Hosted: $5-10/Mo

Best For: Prototyping, learning, small projects

Strengths:

  • Fastest to MVP (code in 5 min)
  • Python-first API
  • Embedded mode (in-process)
  • Active community

Weaknesses:

  • Not for production >10M vectors
  • Limited features
  • Scaling is challenging

Simple Setup:

import chromadb
client = chromadb.Client()
collection = client.create_collection("docs")
collection.add(ids=["id1"], embeddings=[[1.1, 2.3]])

Sizing Guide

Vectors Timeline Recommended Cost
<100k MVP ChromaDB (Free) $0
100k-1M Early Qdrant Cloud or Pinecone Free $0-30
1M-10M Growth Qdrant Self or Pinecone Standard $20-100
10M-100M Scale Qdrant Cluster or Pinecone Scale $100-1000
100M+ Enterprise Milvus or Qdrant Enterprise $1000+

Practical Scenarios

Scenario #1: Startup Building RAG Product

Requirements: 100k-1M vectors, simple search, <$50/Mo

Best Choice: Qdrant Cloud or Pinecone Free

  • Qdrant: Self-hosted ($15/Mo VPS) for control
  • Pinecone: Cloud free tier + pay-as-you-go

Scenario #2: Enterprise Knowledge Base

Requirements: 10M+ vectors, complex filtering, data privacy

Best Choice: Qdrant Self-Hosted on Kubernetes

  • Full data control
  • Horizontally scalable
  • Cost-effective at scale

Scenario #3: Rapid Prototyping

Requirements: Quick iteration, local, free

Best Choice: ChromaDB In-Memory

  • 5-minute setup
  • Zero cost
  • Perfect for testing

Scenario #4: Hybrid Search (Semantic + Keyword)

Requirements: Vectors + text search, excellent performance

Best Choice: Qdrant or Weaviate

  • Qdrant: Faster, simpler
  • Weaviate: More features, GraphQL

Advanced Indexing Strategies

HNSW (Hierarchical Navigable Small World) Deep Dive

How it works:

  1. Builds hierarchical layers of graphs
  2. Search navigates through layers hierarchically
  3. Logarithmic time complexity O(log N)

Performance characteristics:

  • Search time: 10ms for 1M vectors
  • Build time: Slow (hours for 100M)
  • Memory: ~8-12 bytes per vector overhead
  • Best for: <100M vectors, real-time search

When to use: Pinecone, Qdrant, Weaviate (most production use)

IVF (Inverted File) Indexing

How it works:

  1. Clusters vectors into k groups
  2. Search finds nearest cluster, then nearest vector
  3. Can skip far clusters (approximate)

Performance characteristics:

  • Search time: 5-20ms for 100M+ vectors
  • Build time: Fast (minutes)
  • Memory: Minimal overhead
  • Best for: 100M+ vectors, batch search

Trade-off: Faster but less accurate (can miss neighbors in wrong cluster)

When to use: Milvus, large-scale systems

Hybrid Search (Vector + BM25 Text)

# Qdrant hybrid search
results = client.search(
    collection_name="documents",
    query_vector=embedding,  # Semantic search
    query_filter=Filter(  # Text search
        must=[
            FieldCondition(
                key="content",
                match=MatchText(text="important")
            )
        ]
    ),
    limit=5
)

Benefits:

  • Semantic search (vector) + keyword search (text)
  • Better recall than vector-only
  • Catch results both methods might miss

Use cases: Document search, e-commerce search, knowledge bases

Real-World Implementation Patterns

Pattern 1: RAG with Context Window Management

Problem: Document too large for LLM context

Solution:

# Retrieve top 5 chunks from vector DB
chunks = vector_store.search(query, k=5)

# Calculate total tokens
total_tokens = sum(len(chunk.split()) * 1.3 for chunk in chunks)

# If exceeds limit, reduce to top 3
if total_tokens > 8000:
    chunks = chunks[:3]

# Pass to LLM
answer = llm.invoke(f"Context: {chunks}\n\nQuestion: {query}")

Result: Never exceeds context limits, consistent behavior

Pattern 2: Re-ranking for Quality

Problem: Top 5 results from vector DB not always best

Solution: Use semantic ranking

from sentence_transformers import CrossEncoder

# Get top 20 from vector DB (fast)
candidates = vector_store.search(query, k=20)

# Re-rank with more powerful model (slower)
ranker = CrossEncoder('cross-encoder/mmarco-mMiniLMv2-L12-H384')
scores = ranker.predict([[query, chunk.text] for chunk in candidates])

# Return top 5 re-ranked
top_5 = [candidates[i] for i in scores.argsort()[-5:][::-1]]

Quality improvement: 20-30% better answer accuracy

Pattern 3: Batch Indexing for Large Datasets

Problem: Indexing 10M documents takes hours

Solution: Parallel processing

from langchain.vectorstores import Qdrant
from langchain.document_loaders import DirectoryLoader

# Load documents in parallel
documents = DirectoryLoader("documents/", num_workers=4).load()

# Index in batches
batch_size = 10000
for i in range(0, len(documents), batch_size):
    batch = documents[i:i+batch_size]
    vector_store = Qdrant.from_documents(batch)
    print(f"Indexed {i+batch_size} documents")

Time saved: 8 hours β†’ 2 hours (4Γ— faster)

Performance Optimization Tips

Tip #1: Use dimensionality reduction

# Don't store 1536-dim embeddings, reduce to 256
from sklearn.decomposition import PCA

pca = PCA(n_components=256)
reduced_embeddings = pca.fit_transform(embeddings)

# Store reduced embeddings
# Query performance: 6Γ— faster
# Accuracy: Only 2-3% loss

Tip #2: Enable caching

from cachetools import TTLCache

cache = TTLCache(maxsize=1000, ttl=3600)  # 1 hour TTL

def search_with_cache(query: str):
    if query in cache:
        return cache[query]

    result = vector_store.search(query)
    cache[query] = result
    return result

# Repeat queries: 10ms β†’ 1ms (instant)

Tip #3: Batch queries

# DON'T: Individual searches
for query in queries:
    result = vector_store.search(query)

# DO: Batch search
results = vector_store.search_batch(queries)

# Speed: 1000 queries 100ms each vs 10ms batch
# Throughput: 10/sec β†’ 100/sec (10Γ— improvement)

Scaling Strategies

Stage 1: MVP (< 1M vectors)

Tools: ChromaDB (free, easy) Cost: $0 (self-hosted) Time to market: <1 week

Stage 2: Growth (1M - 10M vectors)

Tools: Pinecone Free or Qdrant Cloud Cost: $0-150/month Additional effort: None (managed service)

Stage 3: Scale (10M - 100M vectors)

Tools: Qdrant Self-Hosted or Milvus Cost: $200-2000/month Additional effort: DevOps setup (1-2 weeks)

Stage 4: Enterprise (100M+ vectors)

Tools: Milvus Cluster or proprietary Cost: $5000+/month Additional effort: Dedicated team

Migration path: Each step is 1-2 hour code change

Top-5 Mistakes

Mistake #1: "Start with Pinecone"

  • Reality: Pinecone is managed but expensive at scale
  • Solution: Start with ChromaDB free, migrate later
  • Savings: $8/month β†’ free for first 100k vectors

Mistake #2: "More dimensions = better vectors"

  • Reality: 1536-dim vs 384-dim gives only 5% quality gain
  • Solution: Use 384-dim (10Γ— faster, 10Γ— less storage)
  • Savings: 90% faster search, 90% less storage

Mistake #3: "Don't cache queries"

  • Reality: 30-40% of queries are duplicates
  • Solution: Add caching layer (Redis, local)
  • Improvement: Average latency -70% for active users

Mistake #4: "Index everything"

  • Reality: Not all documents are equally important
  • Solution: Index only searchable content, filter rest
  • Savings: 50-70% fewer vectors, same relevance

Mistake #5: "Use free embedding model"

  • Reality: Free models (sentence-transformers) 85% quality of paid
  • Solution: Use free for MVP, upgrade later
  • Cost-quality trade-off: Excellent initial choice

Budget by Profile (Detailed)

Profile Tools Setup Monthly Annual Scale
Hobby ChromaDB $0 $0 $0 <100k vectors
Startup Pinecone Free + Qdrant $0 $0-50 $0-600 100k-10M vectors
Growth Qdrant Cloud $0 $150 $1,800 10M-100M vectors
Enterprise Milvus Cluster $2k $500-5k $6k-60k 100M+ vectors

Complete Comparison Matrix

Feature ChromaDB Pinecone Qdrant Weaviate Milvus pgvector
MVP Speed 2 hours 1 hour 4 hours 6 hours 8 hours 3 hours
Max Vectors 10M Unlimited 500M 100M Unlimited 100M
Query Latency 50-200ms 30-100ms 20-50ms 100-300ms 50-100ms 100-200ms
Setup Cost $0 Free tier Free $0 Free $5-20
Monthly Cost $0-20 $8-500+ $0-500 $500+ $0-5k $10-100
Learning Curve Easy Easy Medium Hard Hard Medium
Production Ready Medium Yes Yes Yes Yes Yes

Advanced Resources

Last Updated: 21.03.2026 | Total Lines: 450+