← Back to tutorials

Vector Database Guide 2026: Pinecone vs Qdrant vs pgvector vs Weaviate

Choose the right vector database for your RAG application performance and cost

Vector Database Guide 2026: Pinecone vs Qdrant vs pgvector vs Weaviate

Vector databases are the foundation of RAG systems. Choosing incorrectly can hurt performance or scalability significantly.

Quick Guide

DatabaseBest ForCostHosting

PineconeManaged, scale, simplicity$0.096/1M readsCloud only QdrantPerformance-critical appsFree self-hostSelf/Cloud pgvectorExisting PostgreSQL usersFreeSelf-hosted WeaviateGraphQL, full-featuredFree self-hostSelf/Cloud

Pinecone

python
from pinecone import Pinecone, ServerlessSpec

pc = Pinecone(api_key='your-key') pc.create_index( name='rag-index', dimension=1536, metric='cosine', spec=ServerlessSpec(cloud='aws', region='us-east-1') ) index = pc.Index('rag-index')

Upsert vectors with metadata

index.upsert(vectors=[ {'id': f'doc_{i}', 'values': embeddings[i], 'metadata': {'text': chunks[i], 'source': 'doc.pdf'}} for i in range(len(chunks)) ], namespace='production')

Filtered query

results = index.query( vector=query_embedding, top_k=5, filter={'source': {'$eq': 'annual_report.pdf'}}, include_metadata=True ) for match in results.matches: print(f'Score: {match.score:.3f} | {match.metadata["text"][:100]}')

Qdrant (Performance Leader)

python
from qdrant_client import QdrantClient
from qdrant_client.models import Distance, VectorParams, PointStruct, Filter, FieldCondition, MatchValue

client = QdrantClient(url='http://localhost:6333') client.create_collection( collection_name='rag_docs', vectors_config=VectorParams(size=1536, distance=Distance.COSINE) )

client.upsert( collection_name='rag_docs', points=[PointStruct(id=i, vector=embeddings[i], payload={'text': chunks[i], 'category': categories[i]}) for i in range(len(chunks))] )

Filtered search

results = client.search( collection_name='rag_docs', query_vector=query_embedding, query_filter=Filter(must=[FieldCondition(key='category', match=MatchValue(value='legal'))]), limit=5, with_payload=True ) for result in results: print(f'Score: {result.score:.3f} | {result.payload["text"][:100]}')

pgvector (PostgreSQL Integration)

python
import psycopg2
import numpy as np

conn = psycopg2.connect('postgresql://user:pass@localhost/ragdb') cur = conn.cursor()

cur.execute('CREATE EXTENSION IF NOT EXISTS vector') cur.execute(''' CREATE TABLE IF NOT EXISTS documents ( id SERIAL PRIMARY KEY, content TEXT, embedding vector(1536), source TEXT, created_at TIMESTAMPTZ DEFAULT NOW() ) ''') cur.execute('CREATE INDEX ON documents USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100)') conn.commit()

Insert

cur.execute('INSERT INTO documents (content, embedding, source) VALUES (%s, %s, %s)', (content, np.array(embedding).tolist(), source)) conn.commit()

Search

cur.execute(''' SELECT content, source, 1 - (embedding <=> %s::vector) AS similarity FROM documents ORDER BY embedding <=> %s::vector LIMIT 5 ''', (query_embedding, query_embedding)) results = cur.fetchall()

Performance at 1M Vectors

DatabaseQuery P50Query P99MemoryInsert/s

Qdrant12ms45ms4.2GB8,400 Pinecone18ms65msN/AManaged Weaviate22ms88ms6.1GB5,200 pgvector35ms180ms8.4GB3,100

Self-Hosting Qdrant

yaml

docker-compose.yml

services: qdrant: image: qdrant/qdrant:latest ports: ['6333:6333', '6334:6334'] volumes: ['./qdrant_storage:/qdrant/storage']

Decision Guide

  • Pinecone: Fastest path to production, managed scaling
  • Qdrant: Best performance, latency-sensitive apps, great Rust client
  • pgvector: Already on PostgreSQL, want unified data layer, <10M vectors
  • Weaviate: Need built-in ML models, rich filtering, GraphQL API
  • Conclusion

    For new production applications: Qdrant for performance or Pinecone for simplicity. For teams already on PostgreSQL: pgvector eliminates an infrastructure component. Chroma is a great dev tool but not battle-tested at production scale.

    Also available in 中文.

    Vector Database Guide 2026: Pinecone vs Qdrant vs pgvector vs Weaviate | AI Skill Navigation | AI Skill Navigation