Data platforms · AI

pgvector or a dedicated vector database? How I decide for RAG and search

Teams starting retrieval-augmented generation often reach for a new database before checking the one they already run. For many workloads, Postgres with pgvector is enough. For some it isn't. Here is how I tell the difference.

ComparisonSumanta Mukhopadhyay7 min read4 sources
#data#rag#ai#platform
COMPARISON · DATA PLATFORMS · AI22 Oct 2026 · 16:15 GST

A familiar pattern: a team decides to add RAG to its product, evaluates three vector databases, picks one, and six months later is running a second database with its own backups, security reviews, access controls and sync pipeline, all to store a few million embeddings next to data that already lives in Postgres.

Sometimes that's the right call. Often it isn't.

What pgvector gives you

pgvector is an open-source Postgres extension for vector similarity search, supporting exact search as well as approximate indexes such as HNSW and IVFFlat1. The strongest argument for it isn't performance. It's that vectors live beside your relational data, under the same transactions, backups, access controls and operational tooling.

That matters most for filtering. Real RAG queries are rarely "the nearest chunks"; they are "the nearest chunks this user may see, from this tenant, in this product line, updated this year". In Postgres those filters are ordinary SQL against data you already govern.

The filtering problem, and the 0.8 fix

Approximate indexes return a limited candidate set, and filters apply afterwards. With a selective filter, that can leave very few results: the Nile write-up of the release cites an example where a condition matching 10% of rows yields only about four results with default HNSW settings4.

pgvector 0.8.0, released in late 2024, added iterative index scans: if the first pass returns too few matches, the scan continues until it finds enough or hits a configured limit, with options for strict or relaxed ordering23. It also improved cost estimation so the planner makes better index choices when filtering2. The release notes add a useful reminder: where an ordinary index such as a B-tree can meet performance needs, it gives exact results2.

Filtered retrieval is where many RAG systems quietly fail: the right document exists but the user is told nothing relevant was found. Test with your real filters, not unfiltered benchmarks.

How I decide

Favours pgvectorFavours a dedicated vector database
Vectors relate closely to existing relational dataVector search is the main workload, not a feature
Rich filters, permissions and multi-tenancy in SQLVery large collections or very high query rates
Moderate scale that fits your Postgres capacitySearch load would compete with transactional work
Team already runs Postgres wellNeed for features Postgres lacks in your setup
Strong consistency between data and embeddingsIndependent scaling of search from the database

A middle path is common: start on pgvector, measure, and move only the search workload if it outgrows Postgres. If your operational database is MongoDB, the equivalent question applies there, as in hybrid search for RAG on MongoDB.

Practical rules for pgvector

  1. Benchmark with your filters and your data, measuring recall as well as latency.
  2. Enforce permissions in the query, ideally with row-level security, so retrieval can't return documents a user shouldn't see. The same principle applies to tenants, as in multi-tenant SaaS patterns.
  3. Separate search load with read replicas if it begins to affect transactional performance.
  4. Combine with keyword search; Postgres full-text search plus vectors is a reasonable hybrid for many products.
  5. Evaluate retrieval quality with a labelled set, as in the RAG to production checklist, before tuning indexes.

How I can help

I design retrieval architectures and data platforms for AI products, choosing the simplest stack that will scale. See my AI architecture work, or analyse your challenge and bring the result to a call.

References
  1. 1
    pgvectorpgvector, GitHub
  2. 2
    pgvector 0.8.0 releasedPostgreSQL · Nov 2024
  3. 3
  4. 4
FAQ

Common questions

What is pgvector?

An open-source PostgreSQL extension for storing vectors and running similarity search, with exact search and approximate indexes such as HNSW and IVFFlat.

What changed in pgvector 0.8.0?

It added iterative index scans, so that filtered queries on approximate indexes keep scanning until enough matching rows are found, and improved cost estimation so the planner chooses indexes more sensibly when filtering.

When should I choose a dedicated vector database?

When vector search is the core workload at large scale, needs features Postgres lacks, or would compete for resources with transactional work. For moderate scale with relational filters and existing Postgres expertise, pgvector is often the simpler choice.

Keep reading

Related

Open to advisory, fractional CTO & select builds

Let's talk about what you're building.

The fastest route is a free 30-minute call. Prefer to write? Send a message and I'll reply personally within two business days.

Start a conversation

How would you like to reach me?

Book a 30-min callFastest. Pick any open slot on my calendar.→ Write in GmailOpens a pre-filled draft in your browser.→ Use my email appOutlook, Apple Mail or your default client.→

I reply personally within two business days. US & UAE time zones.