New Tool Radar

AI Concepts

How to Choose pgvector for RAG When Postgres Is Already There

Decide whether the pgvector extension on your existing Postgres is enough for RAG, instead of adding a second database.

Schematic illustration with three step boxes: count your vectors, test filtered search, and decide on one system.

pgvector adds vector search to PostgreSQL you already run, and it is a genuinely good answer when your scale is moderate and your operational appetite is low. The rule from practitioners is simple: do not add a second database for 200,000 vectors. But it is a bolt-on, not a dedicated engine, so check your scale and filters before you commit.

Before you start

An existing Postgres database with pgvector available, and a test corpus with the metadata filters you need.

Count your vectors and your filters

Count the vectors you will store and the filters each query needs, such as tenant, date or document type. pgvector handles moderate scale well and does SQL filters and joins natively, which is its main advantage.

If the count is under roughly 10 to 20 million vectors and the filters are relational, pgvector is a serious candidate. Above that, a dedicated engine deserves a test.

Test filtered search on real data

Load a sample of your corpus, create an HNSW index, and run your 20 test questions with their real filters. Record recall at 5 and latency, and check that the filter actually narrows the results.

Compare with the same test on a plain similarity search without filters: if filters do not change the results, either the filters are wrong or the data does not need them.

Decide on one system, not two

If pgvector passes, stay on one system: one backup, one set of transactions, one database to monitor. Adding a dedicated vector store for a small corpus buys complexity, not quality.

If it fails on latency or recall, test Qdrant or Pinecone on the same corpus before you decide.

Practice check: fictional Maple Corner corpus, 180,000 vectors, tenant filter

The table below is fictional practice material, worked out by hand from the stated test figures. It is the expected result for the practice workload, not a run of any database.

Check Result Verdict
Vector count 180,000 Under the 10M guide range
Recall at 5, filtered 17 of 20 Pass
Filtered latency 68 ms Pass
Backup and transactions Same Postgres Pass – one system

All four checks pass at 180,000 vectors with a tenant filter, so pgvector is enough here and no second database is needed.

Expected result. UNTESTED: the figures in the practice table are worked out by hand, not measured by running pgvector. Load your own sample, run your test questions with real filters, and decide on the measured latency and recall.

Limits

  • pgvector is a Postgres extension: its ceiling is your Postgres server, not a distributed cluster.
  • HNSW index build time grows with the corpus; test the build on your full vector count, not only on a sample.

Sources

See all