AI

pgvector vs Pinecone: which vector store, and when

Choosing between Postgres vector search and a managed vector database

The default answer is pgvector, and it stays the right answer far longer than most comparisons imply. If you already run PostgreSQL, pgvector adds vector search to a database you are already backing up, monitoring and paying for.

That is not a claim that Pinecone is worse. It is a claim about sequencing: adopting a second datastore on day one buys operational overhead before you know whether you need the capability it brings.

The comparison

pgvectorPinecone
What it isA Postgres extensionA managed vector database
Operational costNone extra if you run PostgresA new service, vendor and bill
Filtered searchA WHERE clause, fully transactionalMetadata filters, eventually consistent
Joins to your own dataNative — it is the same databaseApplication-side stitching
Scaling ceilingHigh, with tuningHigher, largely handled for you
Best atMost productsVery large or very high-throughput indexes

The third and fourth rows are the ones people underrate. In a RAG system you almost always need to filter by identity before retrieving — this user may see these documents. With pgvector that is a WHERE clause in the same transaction as the rest of your query. With a separate vector store it is a metadata filter in one system joined to permissions in another, and keeping those two in agreement is a real source of bugs, some of which leak data.

Making pgvector fast

Most "pgvector does not scale" stories are missing an index. A sequential scan over a few hundred thousand embeddings is slow, and that is a configuration problem rather than a property of the extension.

  • Build an HNSW index. It is slower to build and larger than IVFFlat, and it gives better recall at speed for most workloads.
  • Match the operator class to your distance metric. An index built for L2 does not serve cosine queries, and the planner will quietly fall back to a scan.
  • Reduce dimensions if your model supports it. Storage and search time scale with dimensionality, and shorter embeddings are often no worse for retrieval.
  • Check the plan with EXPLAIN. Postgres index documentation applies here like anywhere else — if you see a sequential scan, that is your answer.
  • Keep vectors in their own table, referenced by id, so a wide content row does not get dragged through every search.

What should actually make you move

Not volume alone. These are the specific conditions where a managed vector database starts to earn its cost:

  1. You are past roughly ten million vectors and index rebuilds have become an operational event you have to plan around.
  2. Query volume is high enough that vector search competes with transactional load on the same instance, and separating them is cheaper than scaling Postgres.
  3. You need index updates visible in milliseconds at high write rates — a live feed rather than a document corpus.
  4. You have no one to own Postgres tuning, and a managed service is genuinely cheaper than the hire.

That last one is a real reason and gets dismissed too readily. Choosing a managed service because you do not want to operate the alternative is a legitimate engineering decision, not a failure of nerve.

The migration is not the scary part

The reason to start with pgvector is that moving later is cheap if you build for it. Keep retrieval behind one interface — a function that takes a query and filters and returns passages with ids — and the store becomes an implementation detail.

Re-embedding is the part people fear, and it is usually a few dollars and an afternoon. Embedding models are far cheaper than generation models, which is why RAG costs are dominated by inference rather than by storage.

What we do

We start every RAG build on pgvector unless there is a concrete reason from the list above, and in practice most products never hit one. When a client arrives already running a managed vector database we usually leave it — migrating a working system to save a modest bill is rarely the highest-value work available.

The decision that actually affects answer quality is not where the vectors live. It is what you retrieve and how you evaluate it, which is where the engineering time should go.

Frequently asked questions

Is pgvector good enough instead of Pinecone?

For most products, yes. If you already run PostgreSQL, pgvector adds vector search to a database you are already backing up and monitoring, and it keeps permission filtering in the same transaction as retrieval. A managed vector database earns its cost past roughly ten million vectors, at very high write rates, or when nobody is available to own Postgres tuning.

Why is my pgvector query slow?

Usually a missing or unused index. Run EXPLAIN: if you see a sequential scan, either no index exists, the operator class does not match your distance metric — an L2 index does not serve cosine queries — or the planner has a reason to ignore it. Build an HNSW index, match the operator class, and keep vectors in their own narrow table.

When should I move from pgvector to a vector database?

When index rebuilds past roughly ten million vectors become an operational event, when vector search competes with transactional load on the same instance, when you need index updates visible in milliseconds at high write rates, or when you have nobody to own Postgres tuning and a managed service costs less than the hire. Volume alone is not a reason.

How hard is it to migrate from pgvector to Pinecone later?

Not very, if you keep retrieval behind one interface that takes a query plus filters and returns passages with ids. Then the store is an implementation detail. Re-embedding the corpus is usually a few dollars and an afternoon, because embedding models are far cheaper than generation models.

References

  1. pgvectorGitHub
  2. PineconePinecone
  3. IndexesPostgreSQL Documentation
  4. Efficient and robust approximate nearest neighbor search using HNSW graphsarXiv
  5. Embeddings guideOpenAI

Keep reading

The cost components of a retrieval-augmented chatbot
AI

How Much Does a RAG Chatbot Cost?

A demo costs a weekend. A version you can put in front of customers costs considerably more, and almost none of the difference is the model.

An AI layer added alongside an existing product's services
AI

Adding AI to an Existing SaaS Product

The hard part is not the model. It is choosing which job to give it, and building the parts around it that decide whether anyone trusts the output.

Let's put it into production.

Book a 30-minute call — you'll walk away with a scope, a timeline and a fixed price.

Book a call