Vector Databases Explained: Pinecone vs Weaviate vs pgvector

Back to All Articles

Introduction

Vector databases have become a critical piece of modern AI infrastructure. As large language models (LLMs) and embedding models have matured, the need to store, index, and query high-dimensional vector data efficiently has driven the rise of purpose-built vector databases. Whether you are building a retrieval-augmented generation (RAG) pipeline, a semantic search engine, or a recommendation system, choosing the right vector database can have a profound impact on performance, cost, and developer experience.

In this guide, we compare three of the most popular vector database solutions in 2025–2026: Pinecone, a fully managed cloud-native vector database; Weaviate, an open-source, AI-native vector search engine; and pgvector, a PostgreSQL extension that brings vector capabilities to the world’s most popular relational database. We will explore their architectures, walk through real code examples, examine benchmark performance, and help you decide which one fits your project.

What Are Vector Databases?

Traditional databases store and query structured data — rows, columns, keys, and values. Vector databases, by contrast, are optimized for storing vector embeddings: dense numerical arrays (typically 256 to 3072 dimensions) that represent the semantic meaning of text, images, audio, or other unstructured data.

When you pass a sentence through an embedding model like OpenAI’s text-embedding-3-small or Cohere’s embed-v3, the model outputs a vector that captures the meaning of that sentence in a high-dimensional space. Semantically similar sentences produce vectors that are close together, measured by metrics like cosine similarity, Euclidean distance, or dot product.

A vector database provides:

Why Not Just Use NumPy or FAISS?

Libraries like FAISS and Annoy are excellent for in-memory vector search in research and prototyping. However, they lack persistence, metadata filtering, access control, horizontal scaling, and the operational features required for production systems. Vector databases fill this gap by providing a complete data management layer around ANN search.

Pinecone

Pinecone is a fully managed, cloud-native vector database designed for simplicity and scale. It abstracts away all infrastructure concerns — you never manage servers, indexes, or replicas. Pinecone is available on AWS, GCP, and Azure, and offers a generous free tier that supports up to 2 GB of storage across serverless indexes.

Key Features

Setup and Usage

from pinecone import Pinecone, ServerlessSpec

# Initialize client
pc = Pinecone(api_key="YOUR_API_KEY")

# Create a serverless index
pc.create_index(
    name="articles",
    dimension=1536,
    metric="cosine",
    spec=ServerlessSpec(
        cloud="aws",
        region="us-east-1"
    )
)

# Connect to the index
index = pc.Index("articles")

# Upsert vectors with metadata
index.upsert(
    vectors=[
        {
            "id": "article-1",
            "values": [0.012, -0.034, 0.056],  # 1536-dim vector
            "metadata": {
                "title": "Introduction to RAG",
                "category": "AI",
                "published_year": 2025
            }
        },
        {
            "id": "article-2",
            "values": [0.078, 0.023, -0.011],
            "metadata": {
                "title": "Fine-tuning LLMs",
                "category": "AI",
                "published_year": 2024
            }
        }
    ],
    namespace="blog-posts"
)

# Query with metadata filter
results = index.query(
    vector=[0.015, -0.030, 0.048],
    top_k=5,
    namespace="blog-posts",
    filter={"published_year": {"$gte": 2025}},
    include_metadata=True
)

for match in results["matches"]:
    print(f"{match['id']}: {match['score']:.4f} - {match['metadata']['title']}")

Pricing

Pinecone offers two pricing models. The Serverless model charges based on usage: read units, write units, and storage. For many workloads, costs start at just a few dollars per month. The free tier provides a single index with up to 2 GB of storage. For enterprise needs, Pinecone Enterprise offers dedicated infrastructure, uptime SLAs, SSO, HIPAA compliance, and premium support.

Weaviate

Weaviate is an open-source, AI-native vector database written in Go. It stands out for its modular architecture, built-in vectorization modules, and the ability to run fully self-hosted or as a managed cloud service.

Key Features

Setup and Usage

import weaviate
import weaviate.classes as wvc
from weaviate.classes.config import Property, DataType

# Connect to Weaviate Cloud
client = weaviate.connect_to_weaviate_cloud(
    cluster_url="https://your-cluster.weaviate.network",
    auth_credentials=weaviate.auth.AuthApiKey("YOUR_API_KEY"),
    headers={"X-OpenAI-Api-Key": "YOUR_OPENAI_KEY"}
)

# Create a collection with a vectorizer module
articles = client.collections.create(
    name="Article",
    vectorizer_config=wvc.config.Configure.Vectorizer.text2vec_openai(
        model="text-embedding-3-small"
    ),
    properties=[
        Property(name="title", data_type=DataType.TEXT),
        Property(name="content", data_type=DataType.TEXT),
        Property(name="category", data_type=DataType.TEXT),
        Property(name="published_year", data_type=DataType.INT),
    ]
)

# Insert objects - Weaviate vectorizes automatically
articles.data.insert_many([
    wvc.data.DataObject(
        properties={
            "title": "Introduction to RAG",
            "content": "Retrieval-augmented generation combines...",
            "category": "AI",
            "published_year": 2025
        }
    ),
    wvc.data.DataObject(
        properties={
            "title": "Fine-tuning LLMs",
            "content": "Fine-tuning allows you to adapt...",
            "category": "AI",
            "published_year": 2024
        }
    )
])

# Semantic search with filters
response = articles.query.near_text(
    query="how to build RAG applications",
    limit=5,
    filters=wvc.query.Filter.by_property("published_year").greater_or_equal(2025),
    return_metadata=wvc.query.MetadataQuery(distance=True)
)

for obj in response.objects:
    print(f"{obj.properties['title']} (distance: {obj.metadata.distance:.4f})")

client.close()

Pricing

Weaviate’s open-source version is completely free to self-host. Weaviate Cloud offers a free sandbox tier, with production tiers starting at around $25/month.

pgvector

pgvector is an open-source PostgreSQL extension that adds vector storage and similarity search capabilities directly inside Postgres. If you already use PostgreSQL, pgvector lets you add vector search without introducing a new database into your stack.

Key Features

Setup and Usage

-- Enable the pgvector extension
CREATE EXTENSION IF NOT EXISTS vector;

-- Create a table with a vector column
CREATE TABLE articles (
    id SERIAL PRIMARY KEY,
    title TEXT NOT NULL,
    content TEXT,
    category TEXT,
    published_year INTEGER,
    embedding vector(1536)
);

-- Insert data with embeddings
INSERT INTO articles (title, content, category, published_year, embedding)
VALUES
    ('Introduction to RAG',
     'Retrieval-augmented generation combines...',
     'AI', 2025,
     '[0.012, -0.034, 0.056, ...]'::vector);

-- Create an HNSW index for fast approximate search
CREATE INDEX ON articles
USING hnsw (embedding vector_cosine_ops)
WITH (m = 16, ef_construction = 200);

-- Semantic similarity search with metadata filter
SELECT
    id,
    title,
    1 - (embedding <=> '[0.015, -0.030, 0.048, ...]'::vector) AS similarity
FROM articles
WHERE published_year >= 2025
ORDER BY embedding <=> '[0.015, -0.030, 0.048, ...]'::vector
LIMIT 5;

Using pgvector with Python

import psycopg2
from pgvector.psycopg2 import register_vector

conn = psycopg2.connect("postgresql://user:pass@localhost/mydb")
register_vector(conn)

cur = conn.cursor()

query_embedding = [0.015, -0.030, 0.048]  # From your embedding model
cur.execute("""
    SELECT id, title,
           1 - (embedding <=> %s::vector) AS similarity
    FROM articles
    WHERE published_year >= 2025
    ORDER BY embedding <=> %s::vector
    LIMIT 5
""", (query_embedding, query_embedding))

for row in cur.fetchall():
    print(f"{row[1]}: {row[2]:.4f}")

Pricing

pgvector is completely free and open-source. Your costs are the underlying PostgreSQL infrastructure. On managed platforms like Supabase (free tier available), Neon, or AWS RDS, costs are very predictable.

Head-to-Head Comparison

Feature Pinecone Weaviate pgvector
Type Fully managed SaaS Open-source / managed cloud Open-source Postgres extension
Index Algorithm Proprietary (graph-based ANN) HNSW, flat HNSW, IVFFlat
Max Dimensions 20,000 65,535 2,000 (16,000 with halfvec)
Auto Vectorization Yes (Inference API) Yes (modular vectorizers) No (bring your own embeddings)
Hybrid Search Sparse-dense vectors BM25 + vector (built-in) tsvector + vector (manual SQL)
ACID Transactions No No Yes
Self-hosting No Yes (Docker / Kubernetes) Yes (any Postgres deployment)
Scalability Billions of vectors (managed) Billions (with sharding) Millions (single node typical)
Query Latency (p99) < 50ms at scale < 100ms at scale < 20ms (small-medium datasets)
Best For Zero-ops, rapid prototyping, enterprise scale Flexibility, self-hosting, multi-modal AI Postgres-native stacks, hybrid relational + vector

When to Use Each Database

Choose Pinecone When:

Choose Weaviate When:

Choose pgvector When:

Hybrid Approach:

Many production systems use a hybrid architecture — pgvector for small, frequently accessed vector collections that benefit from relational joins, and a dedicated vector database (Pinecone or Weaviate) for large-scale similarity search workloads.

Conclusion

There is no single “best” vector database — the right choice depends on your specific requirements, existing infrastructure, and team capabilities.

Pinecone is the best choice for teams that want a fully managed, zero-ops solution that scales seamlessly. Weaviate is ideal for teams that need flexibility, self-hosting options, and AI-native features like built-in vectorization and generative search. pgvector is the pragmatic choice for teams already invested in PostgreSQL — it eliminates the need for a separate database and provides ACID compliance.

Whichever you choose, the vector database ecosystem is maturing rapidly. All three options have made significant strides in performance, developer experience, and feature completeness throughout 2024–2025. Start with the solution that best fits your current stack and requirements — you can always migrate your embeddings later if your needs evolve.