🐘
Vector Database

pgvector Review 2026

Already running PostgreSQL? Congrats, you're one extension away from a vector database. pgvector adds AI-powered search without adding another service to your stack.

What is pgvector?

pgvector is an open-source extension for PostgreSQL that adds vector similarity search. Install it, create a column with the vector type, add an index, and query using distance operators. Your embedding vectors live in the same database as your application data, queryable with standard SQL.

It's not a separate database. It's not a new service. It's PostgreSQL with vector superpowers. For the millions of applications already running on Postgres, that's the simplest possible path to vector search.

How It Works

You store vectors in a column of type vector(1536) (where 1536 is your embedding dimension). Then you query with distance operators: <-> for L2 distance, <=> for cosine distance, <#> for inner product. It's SQL. If you know SQL, you know how to use pgvector.

CREATE TABLE documents (id serial, content text, embedding vector(1536));
CREATE INDEX ON documents USING hnsw (embedding vector_cosine_ops);
SELECT id, content FROM documents ORDER BY embedding <=> '[0.1, 0.2, ...]' LIMIT 10;

Three lines. You now have a vector database.

Index Types

HNSW (Hierarchical Navigable Small World)

HNSW is the recommended index type for most use cases. It builds a multi-layer graph structure that enables fast approximate nearest neighbor search. Query performance is excellent, typically single-digit milliseconds for moderate-sized datasets. The tradeoff is build time and memory usage. HNSW indexes take longer to create and use more memory than IVFFlat.

Key parameters: m (connections per layer, default 16) and ef_construction (build quality, default 64). Higher values improve recall at the cost of build time and memory. For most applications, the defaults work well.

IVFFlat (Inverted File Index)

IVFFlat divides your vectors into clusters (lists) and searches only the closest clusters at query time. It builds faster than HNSW and uses less memory, but query performance isn't as good. The key parameter is lists, which controls how many clusters to create. A common rule of thumb: use sqrt(n) lists for n vectors.

IVFFlat requires data to be present before building the index (it needs to learn cluster centers). HNSW can be built on an empty table. For datasets that are loaded once and queried often, IVFFlat is a reasonable choice. For data that changes frequently, HNSW adapts better.

Iterative Scans (v0.8+)

Version 0.8 added iterative index scans, which address a long-standing pain point: filtered vector search. Previously, if you combined a vector similarity search with a WHERE clause, the index might not return enough matching results. Iterative scans keep searching the index until enough filtered results are found, preventing the "overfiltering" problem.

The SQL Advantage

pgvector's biggest strength isn't performance. It's integration. Your vectors live next to your application data. Need the 10 most similar products that are in stock and under $50? That's one SQL query with pgvector. With a separate vector database, you'd query for similar vectors, get IDs back, then query your application database for the matching products. Two roundtrips, two services, more code, more failure modes.

This advantage compounds in applications where vector search is one feature among many. E-commerce search, content recommendations, user matching: these all involve combining vector similarity with business logic filters on relational data.

Cloud Availability

You don't have to install pgvector yourself. AWS RDS for PostgreSQL, Google Cloud SQL, Azure Database for PostgreSQL, Supabase, and Neon all support pgvector. If you're using any of these platforms, enabling pgvector is a one-line command: CREATE EXTENSION vector;. Supabase and Neon have made pgvector a core part of their AI story, with documentation and tutorials specifically for RAG and semantic search use cases.

pgvector vs Pinecone

Pinecone is faster at scale and requires zero infrastructure management. pgvector is free and lives in your existing database. If vector search is your primary workload, Pinecone is the better choice. If vector search is one feature in a larger application that already uses PostgreSQL, pgvector avoids the complexity of a second database.

pgvector vs Weaviate

Weaviate offers hybrid search, built-in vectorization, and multi-tenancy features that pgvector doesn't have. But Weaviate is a separate service to deploy and manage. pgvector adds vector search to what you already run. The choice usually comes down to whether you need Weaviate's advanced features or prefer the simplicity of staying within PostgreSQL.

✓ Pros

  • No new infrastructure: adds vector search to your existing PostgreSQL database
  • Full SQL support means you can join vector results with relational data in one query
  • HNSW indexes provide fast approximate nearest neighbor search
  • Available on major cloud platforms (AWS RDS, Supabase, Neon, GCP Cloud SQL)
  • Free and open source with a permissive license

✗ Cons

  • Performance doesn't match dedicated vector databases at very large scale
  • Tuning HNSW and IVFFlat indexes requires understanding the tradeoffs
  • No built-in vectorization, you need to generate embeddings yourself
  • Filtering with vector search can be slow without careful index planning

Who Should Use pgvector?

Ideal For:

  • Teams already running PostgreSQL who want vector search without adding a new database to their stack
  • Projects that need to join vector and relational data where a single SQL query beats cross-service calls
  • Small to medium AI features within existing applications where a dedicated vector database is overkill
  • Developers on platforms like Supabase or Neon where pgvector is pre-installed and ready to use

Maybe Not For:

  • Large-scale vector search (100M+ vectors) where dedicated databases like Pinecone or Weaviate handle the load more efficiently
  • Teams without PostgreSQL expertise since tuning indexes and queries requires database knowledge
  • Projects needing hybrid or semantic search features that dedicated vector databases provide out of the box

Our Verdict

pgvector is the most practical choice for teams that already run PostgreSQL. And a lot of teams run PostgreSQL. Instead of adding Pinecone or Weaviate to your stack (with new SDKs, new billing, new monitoring, new failure modes), you install an extension and write SQL. Your embeddings live next to your application data. You can join vector search results with user tables, product tables, or anything else in a single query. That's powerful.

The limits are real, though. pgvector isn't as fast as dedicated vector databases for large-scale workloads. Index tuning requires understanding HNSW parameters like ef_construction and m, or IVFFlat's lists parameter. Filtered vector search can be slow without the iterative scan features in v0.8+. For under 10 million vectors with moderate query volume, pgvector is often the right call. Beyond that, or if vector search is your primary workload rather than a feature within a larger app, a dedicated solution makes more sense.

Disclosure: This review contains affiliate links. If you sign up through our links, we may earn a commission at no extra cost to you. We only recommend tools we actually use and believe in. Our reviews are based on hands-on testing, not sponsored content.

Frequently Asked Questions

Is pgvector free?

Yes. pgvector is free and open source under the PostgreSQL license. You pay only for your PostgreSQL hosting, whether that's self-managed servers or a cloud platform like AWS RDS, Supabase, or Neon.

Do I need a separate vector database if I use pgvector?

For many use cases, no. pgvector adds vector search directly to PostgreSQL. If your dataset is under 10 million vectors and your query volume is moderate, pgvector handles the workload without needing a dedicated vector database.

HNSW or IVFFlat: which index should I use?

Use HNSW for most cases. It has better query performance, works on empty tables, and handles updates well. Use IVFFlat when build speed and memory usage matter more than query performance, or for batch-loaded datasets that don't change often.

How does pgvector handle filtered search?

Version 0.8 added iterative index scans that solve the overfiltering problem. When combining vector similarity search with WHERE clauses, pgvector keeps scanning the index until enough filtered results are found. Enable with hnsw.iterative_scan or ivfflat.iterative_scan settings.

Can I use pgvector with LangChain or LlamaIndex?

Yes. Both LangChain and LlamaIndex have pgvector integrations. You can use pgvector as your vector store in RAG pipelines built with either framework. The integrations handle vector operations through standard SQL underneath.

Get Tool Reviews in Your Inbox

Weekly AI tool updates, new releases, and honest comparisons.