Vector Store Comparison
Vector stores are specialized databases that index and query high-dimensional vectors (embeddings). They are the backbone of RAG applications, enabling semantic search over documents, images, and structured data.
Choosing the right vector store depends on scale, latency requirements, budget, deployment model (cloud vs self-hosted), and feature needs (hybrid search, filtering, multi-tenancy). This guide compares the most popular options with real code examples.
| Feature | Pinecone | Weaviate | Qdrant | Chroma | pgvector |
|---|---|---|---|---|---|
| Deployment | Managed only | Managed + Self-hosted | Managed + Self-hosted | Self-hosted / Embedded | Self-hosted (Postgres) |
| Max Dimensions | 20,000 | 65,535 | 65,535 | Unlimited | 16,000 |
| Distance Metrics | cosine, euclidean, dotproduct | cosine, l2, dot, hamming | cosine, euclid, dot, manhattan | cosine, l2, ip | cosine, l2, inner product |
| Hybrid Search | Sparse-dense | BM25 + Vector | Full-text + Vector | No (manual) | tsvector + Vector |
| Filtering | Metadata filters | GraphQL filters | Payload filters | Where clauses | SQL WHERE + operators |
| Multi-tenancy | Namespaces | Native (class-level) | Collection-based | Collection-based | Schema-based |
| Free Tier | 100K vectors | Unlimited (self-hosted) | Unlimited (self-hosted) | Unlimited (embedded) | Unlimited (self-hosted) |
| Best For | Managed simplicity | AI-native apps | High performance | Prototyping | Existing Postgres |
Pinecone is a fully managed vector database. Zero infrastructure to manage — just create an index and start querying. Best for teams that want vector search without operational overhead.
| 1 | import pinecone |
| 2 | from langchain_pinecone import PineconeVectorStore |
| 3 | from langchain_openai import OpenAIEmbeddings |
| 4 | |
| 5 | # Initialize Pinecone |
| 6 | pc = pinecone.Pinecone(api_key="YOUR_API_KEY") |
| 7 | |
| 8 | # Create index (one-time setup) |
| 9 | pc.create_index( |
| 10 | name="my-docs", |
| 11 | dimension=1536, |
| 12 | metric="cosine", |
| 13 | spec=pinecone.ServerlessSpec(cloud="aws", region="us-east-1"), |
| 14 | ) |
| 15 | |
| 16 | # Use with LangChain |
| 17 | index = pc.Index("my-docs") |
| 18 | vectorstore = PineconeVectorStore( |
| 19 | index=index, |
| 20 | embedding=OpenAIEmbeddings(), |
| 21 | namespace="production", |
| 22 | ) |
| 23 | |
| 24 | # Add documents |
| 25 | vectorstore.add_documents(documents, ids=[doc.metadata["id"] for doc in documents]) |
| 26 | |
| 27 | # Query with filters |
| 28 | results = vectorstore.similarity_search( |
| 29 | "How to deploy Docker containers", |
| 30 | k=5, |
| 31 | filter={"category": "deployment", "year": {"$gte": 2025}}, |
| 32 | ) |
| 33 | |
| 34 | # Hybrid search (sparse-dense) |
| 35 | results = vectorstore.similarity_search( |
| 36 | "Docker compose networking", |
| 37 | k=5, |
| 38 | alpha=0.5, # 0=pure keyword, 1=pure semantic |
| 39 | ) |
info
Weaviate is an AI-native vector database with built-in generative search, hybrid search, and multi-modal support. Its GraphQL API and schema-based approach make it ideal for complex applications.
| 1 | import weaviate |
| 2 | from langchain_weaviate import WeaviateVectorStore |
| 3 | from langchain_openai import OpenAIEmbeddings |
| 4 | |
| 5 | # Connect to Weaviate (local or cloud) |
| 6 | client = weaviate.connect_to_local() # or connect_to_weaviate_cloud() |
| 7 | |
| 8 | # Create collection with schema |
| 9 | collection = client.collections.create( |
| 10 | name="Documents", |
| 11 | vectorizer_config=weaviate.classes.config.Vectorizer.text2vec_openai, |
| 12 | generative_config=weaviate.classes.config.GenerativeConfig.openai(), |
| 13 | ) |
| 14 | |
| 15 | # Add data (auto-vectorized) |
| 16 | with collection.batch.dynamic() as batch: |
| 17 | for doc in documents: |
| 18 | batch.add_object( |
| 19 | properties={ |
| 20 | "title": doc.metadata["title"], |
| 21 | "content": doc.page_content, |
| 22 | "category": doc.metadata["category"], |
| 23 | }, |
| 24 | ) |
| 25 | |
| 26 | # Vector search |
| 27 | results = collection.query.near_text( |
| 28 | query="How to use Docker", |
| 29 | limit=5, |
| 30 | return_metadata=weaviate.classes.query.MetadataQuery(distance=True), |
| 31 | filters=weaviate.classes.query.Filter.by_property("category").equal("devops"), |
| 32 | ) |
| 33 | |
| 34 | # Generative search (RAG built-in) |
| 35 | results = collection.generate.near_text( |
| 36 | query="Explain Docker networking", |
| 37 | grouped_task="Summarize the key points from these documents", |
| 38 | limit=5, |
| 39 | ) |
| 40 | print(results.generated) |
best practice
Qdrant is a high-performance vector database written in Rust. It excels at speed, offers advanced filtering, and supports quantization for memory efficiency. Ideal for performance-critical applications.
| 1 | from qdrant_client import QdrantClient |
| 2 | from qdrant_client.models import ( |
| 3 | VectorParams, Distance, PointStruct, Filter, |
| 4 | FieldCondition, MatchValue, Range, |
| 5 | ) |
| 6 | from langchain_qdrant import QdrantVectorStore |
| 7 | |
| 8 | # Connect to Qdrant |
| 9 | client = QdrantClient(url="http://localhost:6333") |
| 10 | |
| 11 | # Create collection |
| 12 | client.create_collection( |
| 13 | collection_name="docs", |
| 14 | vectors_config=VectorParams(size=1536, distance=Distance.COSINE), |
| 15 | quantization_config=None, # Enable scalar quantization for 4x compression |
| 16 | ) |
| 17 | |
| 18 | vectorstore = QdrantVectorStore( |
| 19 | client=client, |
| 20 | collection_name="docs", |
| 21 | embedding=OpenAIEmbeddings(), |
| 22 | ) |
| 23 | |
| 24 | # Advanced filtering |
| 25 | from qdrant_client.models import Filter, FieldCondition, MatchAny, Range |
| 26 | |
| 27 | results = vectorstore.similarity_search( |
| 28 | query="Kubernetes deployment strategies", |
| 29 | k=10, |
| 30 | filter=Filter( |
| 31 | must=[ |
| 32 | FieldCondition(key="category", match=MatchValue(value="devops")), |
| 33 | FieldCondition( |
| 34 | key="complexity", |
| 35 | match=MatchAny(any=["intermediate", "advanced"]), |
| 36 | ), |
| 37 | ], |
| 38 | must_not=[ |
| 39 | FieldCondition(key="deprecated", match=MatchValue(value=True)), |
| 40 | ], |
| 41 | ), |
| 42 | ) |
| 43 | |
| 44 | # Batch upsert for high throughput |
| 45 | from qdrant_client.models import PointStruct |
| 46 | points = [PointStruct(id=i, vector=emb, payload={"text": text}) for i, emb, text in zip(ids, embeddings, texts)] |
| 47 | client.upsert(collection_name="docs", points=points) |
info
Chroma is a lightweight, developer-friendly vector database designed for local development and small-to-medium workloads. It runs embedded in your application or as a server.
| 1 | from langchain_chroma import Chroma |
| 2 | from langchain_openai import OpenAIEmbeddings |
| 3 | from langchain_text_splitters import RecursiveCharacterTextSplitter |
| 4 | |
| 5 | # In-memory (development) |
| 6 | vectorstore = Chroma.from_documents( |
| 7 | documents=docs, |
| 8 | embedding=OpenAIEmbeddings(), |
| 9 | collection_name="my_collection", |
| 10 | ) |
| 11 | |
| 12 | # Persistent storage |
| 13 | vectorstore = Chroma.from_documents( |
| 14 | documents=docs, |
| 15 | embedding=OpenAIEmbeddings(), |
| 16 | collection_name="my_collection", |
| 17 | persist_directory="./chroma_data", |
| 18 | ) |
| 19 | |
| 20 | # Query |
| 21 | results = vectorstore.similarity_search_with_score( |
| 22 | "How does caching work?", |
| 23 | k=5, |
| 24 | ) |
| 25 | |
| 26 | # Metadata filtering |
| 27 | results = vectorstore.similarity_search( |
| 28 | "cache invalidation strategies", |
| 29 | k=5, |
| 30 | filter={"category": "performance", "difficulty": "advanced"}, |
| 31 | ) |
| 32 | |
| 33 | # ChromaDB server mode |
| 34 | import chromadb |
| 35 | client = chromadb.HttpClient(host="localhost", port=8000) |
| 36 | collection = client.get_or_create_collection("docs") |
warning
pgvector is a Postgres extension that adds vector search to your existing database. If you already use Postgres, it eliminates the need for a separate vector database.
| 1 | -- Enable pgvector extension |
| 2 | CREATE EXTENSION IF NOT EXISTS vector; |
| 3 | |
| 4 | -- Create table with vector column |
| 5 | CREATE TABLE documents ( |
| 6 | id SERIAL PRIMARY KEY, |
| 7 | content TEXT NOT NULL, |
| 8 | embedding VECTOR(1536) NOT NULL, |
| 9 | metadata JSONB DEFAULT '{}', |
| 10 | created_at TIMESTAMPTZ DEFAULT NOW() |
| 11 | ); |
| 12 | |
| 13 | -- Create HNSW index for fast approximate search |
| 14 | CREATE INDEX ON documents |
| 15 | USING hnsw (embedding vector_cosine_ops) |
| 16 | WITH (m = 16, ef_construction = 64); |
| 17 | |
| 18 | -- Similarity search |
| 19 | SELECT content, metadata, |
| 20 | 1 - (embedding <=> $1) AS similarity |
| 21 | FROM documents |
| 22 | WHERE 1 - (embedding <=> $1) > 0.7 |
| 23 | ORDER BY embedding <=> $1 |
| 24 | LIMIT 5; |
| 25 | |
| 26 | -- Hybrid search: vector + full-text |
| 27 | SELECT d.content, |
| 28 | 1 - (d.embedding <=> $1) AS vector_score, |
| 29 | ts_rank_cd(d.search_vector, plainto_tsquery('english', $2)) AS text_score |
| 30 | FROM documents d |
| 31 | WHERE d.search_vector @@ plainto_tsquery('english', $2) |
| 32 | OR 1 - (d.embedding <=> $1) > 0.5 |
| 33 | ORDER BY (vector_score + text_score) DESC |
| 34 | LIMIT 10; |
| 1 | # LangChain integration with pgvector |
| 2 | from langchain_postgres import PGVector |
| 3 | from langchain_openai import OpenAIEmbeddings |
| 4 | |
| 5 | vectorstore = PGVector( |
| 6 | connection="postgresql+psycopg://user:pass@localhost:5432/db", |
| 7 | embeddings=OpenAIEmbeddings(), |
| 8 | collection_name="documents", |
| 9 | use_jsonb=True, # Store metadata as JSONB |
| 10 | ) |
| 11 | |
| 12 | # Add documents |
| 13 | vectorstore.add_documents(documents) |
| 14 | |
| 15 | # Query with hybrid search |
| 16 | results = vectorstore.similarity_search( |
| 17 | "Docker networking", |
| 18 | k=5, |
| 19 | ) |
info
Choose your vector store based on these criteria. Start simple and migrate when you outgrow the current solution.
Prototype / Hackathon
Chroma — Zero setup, in-memory, embedded. Get from idea to demo in minutes.
Existing Postgres + Small Scale
pgvector — No new infrastructure. Add vector search to your existing database.
Production — Zero Operations
Pinecone — Fully managed, scales automatically, no DevOps needed.
Production — Self-hosted, High Performance
Qdrant — Fastest queries, best quantization, full control over infrastructure.
Production — AI-Native Features
Weaviate — Built-in vectorizers, generative search, multi-modal support, GraphQL API.
best practice