Start with pgvector for production RAG if your data already lives in Postgres and retrieval needs joins or transactional updates. Start with Pinecone serverless if you want a managed retrieval service that you can scale separately from Postgres. Compare filtered recall and p99 at peak load, then price the configurations that meet both targets.
Decision rule
- pgvector suits a team that can allocate Postgres capacity to retrieval and manage index builds, backups, and query tuning. Measure how retrieval affects the application queries sharing that instance. Start with vector index memory sizing.
- Pinecone serverless suits a team that wants Pinecone to operate the search infrastructure. If Postgres remains the source of truth, budget for copying embeddings and metadata, propagating updates and deletes, and fetching chunk text if it stays in Postgres. Pinecone pricing
A Pinecone vs pgvector evaluation can also turn up pg_pinecone, Pinecone’s separate Postgres extension. Its native engine searches inside Postgres, and its remote engine searches a hosted Pinecone serverless index while Postgres retains the table rows. The examples below compare pgvector with the hosted service directly. pg_pinecone README
Filtering is where they diverge
When PostgreSQL uses pgvector’s HNSW index, it applies the WHERE predicate after the index produces candidates. The pgvector README illustrates a filter that matches 10% of rows. With the default hnsw.ef_search of 40, about four candidates match on average, so a request for ten can come back short. pgvector filtering
Iterative scans, available since pgvector 0.8.0, keep looking for eligible rows within scan and memory limits. strict_order preserves distance order among the results. For very selective filters, also test exact search with an index on the filter column. Pinecone accepts a metadata predicate in the search request. Measure its result count and recall against the same exact results. pgvector iterative scans · Pinecone metadata filters
Compare filtered recall and latency
Exact search and iterative HNSW in Postgres
Use a scratch database with pgvector available and a fresh Pinecone test index. Run the first SQL statement once per database. This fixture uses three synthetic vectors. Rows 1 and 2 are eligible for doc = 'report'. Row 3 is closer to the query vector and is excluded by that filter. pgvector setup and cosine indexing
CREATE EXTENSION vector;
CREATE TABLE chunks (
id bigint PRIMARY KEY,
doc text NOT NULL,
embedding vector(3) NOT NULL
);
INSERT INTO chunks (id, doc, embedding) VALUES
(1, 'report', '[1,0.5,0]'),
(2, 'report', '[0.7,1,0]'),
(3, 'memo', '[1,0,0]');
CREATE INDEX chunks_embedding_hnsw
ON chunks USING hnsw (embedding vector_cosine_ops);
Compute the reference IDs with the vector index scan disabled. Then run the same predicate and cosine order with iterative HNSW. pgvector recall monitoring and scan options
-- Filtered exact reference
BEGIN;
SET LOCAL enable_indexscan = off;
SELECT id FROM chunks
WHERE doc = 'report'
ORDER BY embedding <=> '[1,0,0]'
LIMIT 2;
COMMIT;
-- Iterative HNSW on the small fixture
BEGIN;
SET LOCAL enable_seqscan = off;
SET LOCAL hnsw.iterative_scan = strict_order;
SET LOCAL hnsw.ef_search = 100;
SELECT id FROM chunks
WHERE doc = 'report'
ORDER BY embedding <=> '[1,0,0]'
LIMIT 2;
COMMIT;
Prefix each SELECT with EXPLAIN in a separate diagnostic run inside its transaction. Check for an Index Scan on chunks_embedding_hnsw in the HNSW run and a scan plus sort in the fixture’s exact run. The fixture discourages a sequential scan to demonstrate HNSW on a tiny table. Time production runs with the planner settings you intend to deploy and record the chosen plan. PostgreSQL EXPLAIN · pgvector query planning
The same query on Pinecone serverless
With PINECONE_API_KEY set in your environment, create a test document index with a cosine dense_vector field. Serverless and on-demand reads are defaults for this request. Create an index
curl https://api.pinecone.io/indexes \
-H "Api-Key: $PINECONE_API_KEY" \
-H 'Content-Type: application/json' \
-H 'X-Pinecone-Api-Version: 2026-07' \
-d '{"name":"rag-compare","schema":{"fields":{
"embedding":{"type":"dense_vector","dimension":3,"metric":"cosine"}
}}}'
Repeat the describe request until status.ready is true. Set INDEX_HOST to the host in that response. Describe an index
curl https://api.pinecone.io/indexes/rag-compare \
-H "Api-Key: $PINECONE_API_KEY" \
-H 'X-Pinecone-Api-Version: 2026-07'
Upsert the full fixture into rag-test, including the ineligible row. Upsert dense vectors
curl "https://$INDEX_HOST/namespaces/rag-test/documents/upsert" \
-H "Api-Key: $PINECONE_API_KEY" \
-H 'Content-Type: application/json' \
-H 'X-Pinecone-Api-Version: 2026-07' \
-d '{"documents":[
{"_id":"1","doc":"report","embedding":[1,0.5,0]},
{"_id":"2","doc":"report","embedding":[0.7,1,0]},
{"_id":"3","doc":"memo","embedding":[1,0,0]}
]}'
Indexing is asynchronous. Before timing the fixture, check the _id values in matches for IDs 1 and 2. Search for memo to check ID 3. The doc metadata predicate selects the same eligible IDs as the SQL query. Bring your own vectors · Search documents API · Filter by metadata
curl "https://$INDEX_HOST/namespaces/rag-test/documents/search" \
-H "Api-Key: $PINECONE_API_KEY" \
-H 'Content-Type: application/json' \
-H 'X-Pinecone-Api-Version: 2026-07' \
-d '{"top_k":2,
"score_by":[{"type":"dense_vector","fields":["embedding"],"values":[1,0,0]}],
"filter":{"doc":{"$eq":"report"}}}'
Score the same workload
- Replace the fixture with the same frozen snapshot in both stores. Set both dimensions to your embedding size and use your application’s
k. Match record IDs, nonzero embeddings, cosine metric, filter predicates, and held-out query vectors. Use identical tenant subsets when a namespace represents a tenant. Group queries by eligible records divided by the total searched in that corpus or namespace, including rare, common, and unfiltered cases. - Save the filtered exact top
kIDs for each query. Divide the number of exact IDs returned by the system under test by the size of the exact result set. For example, exact IDs{1, 2}and an illustrative response{1}give1 / 2 = 0.50recall@2 and a result count of one. If fewer thankrecords qualify, the exact set is smaller. Record empty exact sets separately. For cutoff ties, recompute exact distances for eligible returned IDs and count those at or inside the cutoff. Recall@k benchmarking guide - Replay the same request mix and arrival rate from the application’s region. Use the same warm-up, run duration, and response payload needs. Time each request at the client and log engine, query ID, selectivity, returned count, recall@k, elapsed milliseconds, and status. Report mean recall, short-result rate, errors, and p99 latency per selectivity group. Count a response as short when it returns fewer IDs than the exact set. Use the same percentile calculation for both stores. Pinecone load-testing guide
Keep configurations that meet your recall, p99, and error targets at peak traffic. Compare their monthly costs using the same expected query volume and write load.
The metric that matters: cost per query at target recall
For Pinecone on-demand reads, each query uses one read unit (RU) per GB in the namespace it searches, with a 0.25 RU minimum. Calculate monthly queries × max(0.25, namespace GB) separately for each namespace, then sum the RUs. For dense vectors, estimate namespace bytes from record count times the average bytes for the ID, metadata, and embedding. Each dimension contributes four bytes. Pinecone billing guide
Worked Standard on-demand estimate. Assume a single 10 GB namespace and index, one million queries per month, and one million write units (WUs). The example uses Pinecone’s published starting rates. Substitute your cloud and region rates. Pinecone starting rates · Plan pricing
| Monthly item | Calculation | Amount |
|---|---|---|
| Query reads | 10 RUs/query × 1,000,000 queries = 10,000,000 RUs at $16 per million | $160.00 |
| Storage | 10 GB × $0.33 per GB-month | $3.30 |
| Writes | 1,000,000 WUs at $4 per million | $4.00 |
| Standard minimum | max($50, $167.30) with no other charges in this example |
$167.30 |
For your bill, total the WUs for inserts, updates, and deletes. New upserts use one WU per KB of the request with a five WU minimum per request. Replacements also meter the existing record. Add any applicable egress overage, imports, backups, and other usage before applying the usage minimum. Price Dedicated Read Nodes separately using their hourly model. Pinecone billing meters · Pinecone plan pricing
For pgvector on an existing Postgres deployment, subtract the monthly compute cost of the deployment without retrieval from the cost of the measured configuration that meets the targets. Add incremental storage, backups, and operator hours times their hourly cost. For a dedicated retrieval deployment, include its full compute cost. Include the app-side cost of syncing and fetching chunks for Pinecone when it applies.
Divide each monthly total by the same number of retrieval queries. The example’s Pinecone service cost is $167.30 / 1,000,000 = $0.0001673 per query. Use your measured capacity and operating costs to make the same calculation for Postgres.
What the pod benchmarks tell you about serverless
Supabase’s October 2023 vendor benchmark reported higher throughput for its pgvector HNSW setup than for Pinecone s1 pods at matched accuracy@10. Tiger Data’s June 2024 vendor benchmark compared Pinecone pods with PostgreSQL running pgvectorscale’s StreamingDiskANN index. Supabase benchmark · Tiger Data benchmark
Use the studies to see how index choice, matched recall, and deployment configuration shape a comparison. Their latency, throughput, and pricing apply to the tested pod configurations. Estimate today’s serverless bill from namespace usage and measure performance with your own filters and load.
Evidence and limits. The examples are based on the pgvector 0.8.7 README, PostgreSQL 18 documentation, and Pinecone API 2026-07 documentation. The commands and workload comparison were not run for this article.
Related across the network
- Qdrant vs Milvus vs Pinecone: Vector DB Comparison — ragstackguide.com
- RAG Poisoning: How Retrieval-Augmented Systems Get Compromised — ai-alert.org
- Secure RAG Architecture Best Practices for Production LLM Systems — aidefense.dev
- How to Secure Vector Database Access in RAG Systems — aisecreviews.com