If your vectors belong to rows you already keep in Postgres, and you have fewer than a few tens of millions of them, use pgvector with an HNSW index. You get transactional consistency, row-level security, joins and one backup story, and with iterative index scans (pgvector 0.8+) filtered search is no longer the trap it was. Move to a dedicated vector database such as Pinecone when the index no longer fits comfortably in RAM on one machine, when vector traffic starts to hurt your OLTP workload, or when you need millions of isolated tenants or billions of vectors without running the infrastructure yourself.
The rest of this post is the detail behind that answer: how the two pgvector index types behave, why filtered vector search quietly returns too few rows, how to do hybrid BM25 + vector search with reciprocal rank fusion in one SQL statement, a worked cost model, and a runbook for measuring recall on your own data before you decide anything.
Versions referenced: pgvector 0.8.7 (released 1 October 2026), PostgreSQL 18, and Pinecone's serverless platform on API version 2026-07 (release notes).
01pgvector vs Pinecone at a glance
| pgvector (in your Postgres) | Pinecone (serverless) | |
|---|---|---|
| What it is | Extension adding vector, halfvec, bit, sparsevec types and HNSW/IVFFlat indexes |
Managed vector database; dense, sparse and (since September 2026) full-text indexes |
| Consistency | Transactional. A committed row is searchable immediately | Eventually consistent; read-after-write needs LSN checks |
| Filtering | Any SQL predicate, joins, RLS. Approximate indexes filter after the scan (see below) | Metadata filters on flat JSON; no joins |
| Hybrid search | Built-in full-text (not BM25) or BM25 via extensions; fuse in SQL | Documents API with BM25 + dense in one schema; RRF client-side |
| Multi-tenancy | tenant_id + RLS, partitions, or separate databases |
Namespaces: 100,000 per index on Standard, 1,000,000 on Enterprise (limits) |
| Scaling model | Vertical, plus read replicas; sharding via Citus or similar | Storage and compute separated; scales without you sizing nodes |
| Pricing model | The instance you already pay for, plus RAM headroom | Storage per GB-month + read/write units, or Dedicated Read Nodes at an hourly rate |
| Operations | You tune memory, builds, vacuum, upgrades | Vendor does; you manage sync from your source of truth |
The row that decides most cases is the first one under "Consistency". If the embeddings describe data whose source of truth is Postgres, every external vector store adds a sync pipeline, a second deletion path and a window where the two disagree. That cost does not show up in a benchmark.
02HNSW vs IVFFlat in pgvector: which index to use
pgvector ships two approximate nearest neighbour (ANN) indexes. Without one, a query is an exact scan: correct, and fine up to perhaps a hundred thousand rows per query, but linear in table size.
HNSW builds a layered proximity graph (Malkov and Yashunin). Queries walk the graph from a coarse top layer down to a dense bottom layer. IVFFlat clusters vectors into lists with k-means, then searches the probes nearest clusters.
| HNSW | IVFFlat | |
|---|---|---|
| Speed/recall trade-off | Better | Worse |
| Build time and memory | Slower, more memory | Faster, less memory |
| Can build on an empty table | Yes | No. Centroids come from the data present at build time |
| Behaviour as data drifts | Stable; new rows join the graph | Recall degrades as the distribution moves away from the original centroids; rebuild periodically |
| Key knobs | m (default 16), ef_ (default 64), hnsw. (default 40) |
lists (rows/1000 up to 1M rows, sqrt(rows) above), ivfflat. (default 1; start at sqrt(lists)) |
| Deletes and updates | Vacuum must repair the graph; expensive on large indexes | Cheaper |
Defaults and sizing rules are from the pgvector README.
Use HNSW. It is the right default for nearly every production workload because it works on a growing table without rebuilds and gives better recall for the latency. Choose IVFFlat only when build time or memory is the binding constraint, the data is mostly static, and you are prepared to rebuild on a schedule.
Building an HNSW index that does not take all night
-- Session settings for the build only.
SET maintenance_work_mem = '8GB'; -- the graph should fit; see below
SET max_parallel_maintenance_workers = 7; -- plus the leader process
CREATE INDEX CONCURRENTLY chunks_embedding_hnsw
ON chunks USING hnsw (embedding vector_cosine_ops)
WITH (m = 16, ef_construction = 64);Watch the build output. If you see
NOTICE: hnsw graph no longer fits into maintenance_work_mem after 100000 tuplesthe build has spilled and will slow down sharply. The README is explicit that builds are "significantly faster when the graph fits into maintenance_". Do not set maintenance_ so high that the server runs out of memory, and remember that each parallel worker is a separate process on the same box.
CREATE INDEX CONCURRENTLY matters on a live table; our post on zero-downtime Postgres migrations covers the failure modes (invalid indexes after a cancelled build, lock queues) that apply here unchanged.
Dimensions, halfvec and the 2,000-dimension ceiling
The vector type stores up to 16,000 dimensions but HNSW and IVFFlat only index vector up to 2,000 dimensions. halfvec indexes up to 4,000, bit up to 64,000 (README). If your embedding model emits 3,072 dimensions, you have three options: ask the model for fewer dimensions if it supports truncation, index a half-precision expression, or index a binary quantisation and re-rank.
Half precision halves index size. Whether it costs you recall depends on the model and the data, so measure it with the runbook below before you commit.
CREATE INDEX CONCURRENTLY chunks_embedding_hnsw_half
ON chunks USING hnsw ((embedding::halfvec(3072)) halfvec_cosine_ops);
-- The query must use the same expression or the index is ignored.
SELECT id
FROM chunks
ORDER BY embedding::halfvec(3072) <=> $1::halfvec(3072)
LIMIT 10;Binary quantisation is the aggressive version: index one bit per dimension, over-fetch, then re-rank on the full-precision vector.
CREATE INDEX CONCURRENTLY chunks_embedding_bq
ON chunks USING hnsw ((binary_quantize(embedding)::bit(3072)) bit_hamming_ops);
SELECT id FROM (
SELECT id, embedding
FROM chunks
ORDER BY binary_quantize(embedding)::bit(3072) <~> binary_quantize($1::vector)
LIMIT 100 -- over-fetch
) candidates
ORDER BY embedding <=> $1::vector -- exact re-rank
LIMIT 10;The re-rank reads full vectors from the heap, so this trades index RAM for random I/O. It works well when the heap is on fast storage and the over-fetch factor is modest.
03Filtered vector search in pgvector: the post-filter trap
This is the section most comparison posts skip, and it is where most pgvector deployments first go wrong.
Approximate indexes apply WHERE clauses after the index scan. The README puts it plainly: "If a condition matches 10% of rows, with HNSW and the default hnsw. of 40, only 4 rows will match on average." Ask for LIMIT 10 with a filter that matches 10% of rows and you get roughly four results, with no error and no warning. Users see a search that "sometimes finds nothing".
-- Looks right. Returns ~4 rows when tenant 42 owns 10% of the table.
SELECT id FROM chunks
WHERE tenant_id = 42
ORDER BY embedding <=> $1
LIMIT 10;There are five fixes. Pick by how selective the filter is.
1. Iterative index scans (pgvector 0.8+)
Since 0.8.0 the index can keep scanning until it has enough rows that pass the filter.
BEGIN;
SET LOCAL hnsw.iterative_scan = strict_order; -- or relaxed_order
SET LOCAL hnsw.ef_search = 100;
SELECT id FROM chunks
WHERE tenant_id = 42
ORDER BY embedding <=> $1
LIMIT 10;
COMMIT;strict_ keeps results in exact distance order. relaxed_ is faster but can return slightly out-of-order results; re-sort with a materialised CTE:
WITH relaxed AS MATERIALIZED (
SELECT id, embedding <=> $1 AS distance
FROM chunks
WHERE tenant_id = 42
ORDER BY distance
LIMIT 10
)
SELECT * FROM relaxed ORDER BY distance;Iterative scans stop at hnsw. (default 20,000) and are bounded in memory by hnsw. (a multiple of work_mem, default 1). For IVFFlat the equivalent cap is ivfflat.. When the filter is very selective, the scan hits the cap and you are back to short result sets, just less often. Use SET LOCAL, not SET, if you are behind a transaction-mode pooler.
2. Exact search over a small filtered set
If a filter matches a few thousand rows, an exact scan of those rows beats any ANN index and has perfect recall. pgvector 0.8.0 improved cost estimation so the planner chooses this more often, but you can force it with an optimisation fence:
WITH scoped AS MATERIALIZED (
SELECT id, embedding FROM chunks WHERE tenant_id = 42 -- uses a B-tree on tenant_id
)
SELECT id FROM scoped
ORDER BY embedding <=> $1
LIMIT 10;This is the right pattern for most multi-tenant SaaS, where the median tenant is small and only a handful are large.
3. Partial indexes for a few fixed filter values
CREATE INDEX ON chunks USING hnsw (embedding vector_cosine_ops)
WHERE (doc_type = 'contract');Good for a small, stable set of values. Useless for tenant_id with thousands of values.
4. List partitioning for large tenants
Partition by the filter column so each partition has its own graph and the filter becomes partition pruning:
CREATE TABLE chunks (
id bigint GENERATED ALWAYS AS IDENTITY,
tenant_id bigint NOT NULL,
embedding vector(1536) NOT NULL,
PRIMARY KEY (tenant_id, id)
) PARTITION BY LIST (tenant_id);
CREATE TABLE chunks_t42 PARTITION OF chunks FOR VALUES IN (42);
CREATE TABLE chunks_default PARTITION OF chunks DEFAULT;Give your top tenants their own partitions and leave the long tail in the default partition with pattern 2. Thousands of partitions bring their own planning overhead; this is for tens to low hundreds.
5. Push the filter into the vector
Rarely, a filter is really part of the semantics (language, product line). Separate indexes per value or a separate table can be simpler than filtering at all.
Choosing a filtering strategy
| Rows matching the filter | Approach |
|---|---|
| Under ~10,000 | Exact scan over the filtered set (pattern 2) |
| 10,000 to a few million, filter matches >~5% of table | HNSW + iterative scan, raise ef_search |
| A few fixed, high-traffic values | Partial index per value |
| A few very large tenants | List partition per large tenant, default partition for the rest |
| Selective filter on a huge table | Combine: B-tree to scope, then exact or partitioned ANN |
The thresholds are starting points, not rules. Measure recall and latency with the runbook further down.
For the isolation side of tenant_id (RLS policies, SET LOCAL with poolers, FORCE ROW LEVEL SECURITY) see our post on multi-tenant SaaS on Postgres with row-level security. RLS policies are just more predicates, so everything in this section applies to them too.
How Pinecone handles filters
Pinecone applies metadata filters inside its search, so you do not see the short-result-set problem in the same form. The constraints are different: metadata is flat JSON (no nested objects, no nulls, per its known limitations), $in/$nin accept at most 10,000 values (operation limits), and there are no joins. Anything that depends on permissions computed from relational data must be denormalised into metadata and kept in sync, which is the core problem of permission-aware RAG. For per-tenant isolation, use one namespace per tenant rather than a tenant_id filter: it is cheaper (see the cost model) and a forgotten filter cannot leak data across tenants.
04Hybrid search in Postgres: BM25 + vector with reciprocal rank fusion
Vector search is poor at exact tokens: error codes, SKUs, surnames, function names. Keyword search is poor at paraphrase. Hybrid search runs both and fuses the rankings. You probably want it for any retrieval-augmented generation system that indexes technical or business documents.
Postgres full-text search is not BM25
Postgres's built-in ts_rank and ts_rank_cd rank by term frequency and proximity within a document. They do not use corpus-wide inverse document frequency, which is the heart of BM25 (Postgres docs on ranking). They also cannot return results in rank order from the GIN index: Postgres finds every matching row, scores each one, then sorts. For a common term on a large table that is slow.
That leaves three options:
| Option | What it is | Notes |
|---|---|---|
Built-in tsvector + GIN |
Ships with Postgres | Fine for small corpora or as a candidate generator where fusion matters more than score quality |
| pg_textsearch | Tiger Data's BM25 index (USING bm25, <@> operator); open source since v1.0 in 2026 |
Postgres 17 and 18; needs shared_. Corpus statistics span all indexed rows, so IDF can leak term frequencies across RLS boundaries; per-partition statistics differ |
| ParadeDB pg_search | Tantivy-backed BM25 inside Postgres | On managed Postgres (RDS, Cloud SQL) it typically runs as a logical replica, not on your primary |
Check what your provider allows before you design around an extension. Most managed services offer pgvector; few offer shared_ access for third-party search extensions.
Reciprocal rank fusion in one SQL query
Reciprocal rank fusion (Cormack, Clarke and Büttcher, SIGIR 2009) scores each document as the sum of 1 / (k + rank) across result lists, with k = 60 in the original paper. It ignores raw scores, which is exactly what you want when one list is cosine distance and the other is a text rank on a different scale.
Schema:
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE chunks (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
tenant_id bigint NOT NULL,
doc_id bigint NOT NULL,
body text NOT NULL,
tsv tsvector GENERATED ALWAYS AS (to_tsvector('english', body)) STORED,
embedding vector(1536) NOT NULL,
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX chunks_tsv_gin ON chunks USING gin (tsv);
CREATE INDEX chunks_tenant ON chunks (tenant_id);
CREATE INDEX chunks_embedding_hnsw ON chunks USING hnsw (embedding vector_cosine_ops);Hybrid query. $1 is the query embedding, $2 the raw query text, $3 the tenant:
WITH semantic AS (
SELECT id, row_number() OVER (ORDER BY distance) AS rank
FROM (
SELECT id, embedding <=> $1::vector AS distance
FROM chunks
WHERE tenant_id = $3
ORDER BY distance
LIMIT 50
) s
),
keyword AS (
SELECT id, row_number() OVER (ORDER BY score DESC) AS rank
FROM (
SELECT c.id, ts_rank_cd(c.tsv, q) AS score
FROM chunks c, websearch_to_tsquery('english', $2) AS q
WHERE c.tenant_id = $3
AND c.tsv @@ q
ORDER BY score DESC
LIMIT 50
) k
)
SELECT id,
COALESCE(1.0 / (60 + semantic.rank), 0)
+ COALESCE(1.0 / (60 + keyword.rank), 0) AS rrf_score
FROM semantic
FULL OUTER JOIN keyword USING (id)
ORDER BY rrf_score DESC
LIMIT 10;Details that matter:
- Rank inside a bounded subquery. Each inner query orders and limits first, then
row_ranks 50 rows. Putting the window function directly over the table can stop the planner from using the HNSW index.number() FULL OUTER JOIN, notUNION, so a document found by both lists gets both contributions.- Run it with iterative scans on (
SET LOCAL hnsw.) because of the tenant filter, or use the materialised-CTE exact scan for small tenants.iterative_ scan = strict_ order - Weights. To favour one side, multiply its term, e.g.
0.. Tune on labelled queries, not intuition; the span-labelled set from evaluating RAG in production works for this.7 * 1. 0/ (60 + semantic. rank) - With pg_textsearch, swap the keyword CTE for
ORDER BY body <@> to_(scores are negative; lower is better). Use the explicit index name form,bm25query($2, 'chunks_ body_ bm25') LIMIT 50 to_, inside functions, per its README.bm25query(text, index_ name)
On a typical tenant-scoped table this runs as two index scans and a hash join over 100 rows. If the keyword CTE is the slow half, it is because of the scoring problem above, and that is your signal to move to a real BM25 index.
Hybrid search in Pinecone
Pinecone now recommends its Documents API, generally available since 2 September 2026: one schema with a dense_ field and full-text string fields, BM25 scoring, Lucene query syntax and metadata filters. Fusion across the two rankings is still client-side RRF. On the older Vectors API you either store dense and sparse vectors in one index and weight them with an alpha on the query vectors, or run separate dense and sparse indexes and merge yourself. Either way you write the same fusion logic as the SQL above, just in your application.
05A worked cost model: pgvector vs Pinecone
Numbers below are a worked example with stated assumptions, not a benchmark. Plug in your own.
Assumptions: 10 million chunks, 1,536-dimension float32 embeddings, about 500 bytes of metadata each. 5 million queries per month. Pinecone Standard plan list prices on the low end of the published range: storage $0.33/GB-month, reads $16 per million read units (pricing; list prices at the time of writing, so check the vendor page, they change often).
Raw vector size: 1,536 × 4 bytes = 6,144 bytes. With metadata, about 6.6 KB per record, so 10M records ≈ 66 GB.
Pinecone, one big namespace. A query costs 1 RU per GB of the namespace it searches, minimum 0.25 RU (understanding cost). top_k and included metadata do not change it.
- Per query: 66 RU
- Monthly reads: 5M × 66 = 330M RU × $16/M = $5,280
- Storage: 66 × $0.33 = $21.78
- Writes on top, depending on churn
Pinecone, namespace per tenant. Same data split across 2,000 tenants, median namespace well under 0.25 GB:
- Per query: 0.25 RU (the minimum)
- Monthly reads: 5M × 0.25 = 1.25M RU × $16/M = $20
- Plus the $50/month Standard minimum
The difference between those two lines is the most useful thing to know about Pinecone serverless pricing: cost tracks the size of what you search, so the data layout is the pricing decision. Global search over one large corpus at high QPS is the expensive case; that is what Dedicated Read Nodes (fixed hourly price, GA since April 2026) exist for.
pgvector. The heap holds ~66 GB of vectors and metadata. An HNSW index on vector(1536) stores each vector again plus graph links. In pgvector's on-disk layout a 1,536-dimension element and its neighbour list (at m = 16) take about 6.4 KB, so only one fits on an 8 KB page: budget roughly 80 GB, a little more than the heap. That is our arithmetic, not a measurement, so check it with pg_ on a sample build before you size hardware. On halfvec two elements fit per page, so the index is roughly half that. For good latency the index should stay in memory, so you are looking at a memory-optimised instance with ~128 GB of RAM (~64 GB on halfvec), or a replica of that size dedicated to search. If you already run Postgres that large, the marginal cost is close to zero. If you would be buying it just for vectors, compare that instance's monthly price, plus a replica and the engineering time to operate it, with the Pinecone lines above.
The pattern: for multi-tenant workloads with small per-tenant corpora, both are cheap and pgvector wins on simplicity. For one large shared corpus at high QPS, the numbers converge and operational preference decides.
06Where Postgres stops being enough
pgvector does not hit a cliff at a particular row count. It degrades along a few axes, and you should know which one you will hit first.
1. The index outgrows RAM. HNSW search is random access over the graph. Once the working set no longer fits in memory, every hop risks a disk read and p99 latency climbs. Mitigations, in order: halfvec, binary quantisation with re-ranking, a bigger replica, then a disk-oriented index such as pgvectorscale's StreamingDiskANN. When you are on the third of those, price the dedicated alternatives.
2. Build and rebuild time. Index builds on tens of millions of high-dimensional vectors take hours even with parallel workers and enough maintenance_. That matters when you change embedding models, because a model change means re-embedding everything and building a new index alongside the old one. Plan for double storage during the switch.
3. Write and delete churn. Heavy updates and deletes leave the HNSW graph needing repair at vacuum time, which is expensive on large indexes. pgvector 0.8.3 and 0.8.4 fixed possible index corruption and repair errors in HNSW vacuuming; if you run HNSW on a table with real churn, be on 0.8.4 or later. Managed providers lag upstream. At the time of writing, RDS, Aurora and Azure Database for PostgreSQL list pgvector 0.8.2 at most, which predates both fixes, while Cloud SQL lists 0.8.5. Check what your provider actually ships today.
4. Contention with OLTP. Vector queries are CPU-heavy and touch a lot of memory. On the primary they compete with your transactional workload for buffer cache. Move search to a read replica early; it costs little and buys a lot of headroom. Replica lag then becomes your freshness window, which is still usually shorter than an external sync pipeline.
5. Tenant count and isolation. Thousands of large tenants who each need fast filtered ANN push you towards many partitions or many databases, and both get unwieldy. Pinecone's namespaces (up to 1,000,000 per index on Enterprise) solve this directly.
6. Billions of vectors. At that scale you are sharding Postgres (Citus or application-level) and running a distributed system either way. A database built for the job is usually the better trade.
When a dedicated vector database wins
Choose Pinecone, or a peer such as Qdrant, Milvus, Weaviate or turbopuffer, when at least two of these are true:
- Vectors do not have a natural home in your Postgres (for example, a crawled corpus with no relational data).
- The ANN index would need well over a single large instance's RAM, even with
halfvec. - You need many isolated tenants, each with its own fast index.
- Search QPS is high enough to justify its own fleet, and nobody on the team wants to tune and patch it.
- You can tolerate eventual consistency between your source of truth and search.
And you probably do not need one when the corpus is under ~10M vectors, lives next to relational data, needs permission-aware filtering, or when the team running Postgres is the same team that would run the vector store.
07Runbook: measure recall and readiness before you choose
This is the asset to keep. Most teams compare vector stores on vendor benchmarks run on someone else's data. Run these against yours, on a replica.
Step 1: exact and approximate search functions
The SET clauses on the exact function disable index scans only inside it, so it always does a brute-force scan.
CREATE OR REPLACE FUNCTION knn_exact(q vector, k int)
RETURNS TABLE (id bigint)
LANGUAGE sql STABLE
SET enable_indexscan = off
SET enable_bitmapscan = off
AS $$
SELECT c.id FROM chunks c ORDER BY c.embedding <=> q LIMIT k
$$;
CREATE OR REPLACE FUNCTION knn_ann(q vector, k int)
RETURNS TABLE (id bigint)
LANGUAGE sql STABLE
AS $$
SELECT c.id FROM chunks c ORDER BY c.embedding <=> q LIMIT k
$$;Step 2: recall@10 on real queries
Use real query embeddings from production logs in a probe_ table. Sampling from the corpus itself is biased, because each probe finds itself.
SET hnsw.ef_search = 40; -- repeat for 40, 80, 120, 200
SELECT round(avg(hits) / 10.0, 3) AS recall_at_10
FROM (
SELECT (
SELECT count(*)
FROM knn_ann(p.embedding, 10) a
JOIN knn_exact(p.embedding, 10) e USING (id)
) AS hits
FROM (SELECT embedding FROM probe_queries LIMIT 200) p
) per_query;Repeat with your real filters (tenant, document type) added to both functions. Filtered recall is usually much lower than unfiltered recall, and it is the number that matches what users see.
Step 3: latency at the chosen setting
EXPLAIN (ANALYZE, BUFFERS)
SELECT id FROM chunks
WHERE tenant_id = 42
ORDER BY embedding <=> (SELECT embedding FROM probe_queries LIMIT 1)
LIMIT 10;Check that the plan uses the index you expect, and look at shared read versus shared hit in the buffers line. Reads mean the index is not in memory.
Step 4: memory fit
SELECT
pg_size_pretty(pg_relation_size('chunks_embedding_hnsw')) AS hnsw_index,
pg_size_pretty(pg_table_size('chunks')) AS table_with_toast,
current_setting('shared_buffers') AS shared_buffers;If the index is larger than the memory realistically available to it (shared buffers plus OS page cache, minus your OLTP working set), expect latency to degrade under load. pg_ helps after restarts but does not create memory you do not have.
Readiness checklist
| Check | Pass condition |
|---|---|
| pgvector version | 0.8.4 or later if HNSW sees deletes/updates |
| Index type | HNSW, unless a documented reason for IVFFlat |
| Dimensions | ≤2,000 on vector, ≤4,000 on halfvec, or a quantised index |
| Unfiltered recall@10 | Meets your target (we start at ≥0.95) at the chosen ef_search |
| Filtered recall@10 | Measured per filter pattern; iterative scan or exact path where it falls short |
| Result count | No query with a filter silently returns fewer than LIMIT rows when more exist |
| Memory | HNSW index fits in available cache on the serving node |
| Workload isolation | Vector queries on a replica, or measured headroom on the primary |
| Build plan | Rebuild time known; capacity for two indexes during a model change |
| Hybrid | Keyword path exists for exact-token queries; fusion tuned on labelled queries |
| Deletion | Erasure requests remove rows and their embeddings in the same transaction |
If you fail the memory, build-plan or isolation rows and cannot fix them cheaply, that is your case for a dedicated store, made with your own numbers.
08Where this crosses into other layers
The choice looks like a database decision, but most of its cost lands elsewhere. A separate vector store is a second system to secure, a second place personal data lives (so a second path for erasure requests and residency), a second backup and restore story, and a sync pipeline (outbox or CDC, the same choice as dual writes vs CDC in a strangler fig migration) that someone has to monitor. Changing embedding models is an AI-layer decision that becomes a data-layer migration and a cloud capacity question. Teams that pick a vector store by benchmark tend to discover these one at a time.
09FAQ
Is pgvector fast enough for production? Yes, for most workloads up to tens of millions of vectors, provided the HNSW index fits in memory and vector queries do not compete with OLTP on the primary. Measure recall and p99 with the runbook above rather than relying on published benchmarks.
Should I use HNSW or IVFFlat? HNSW in almost every case. It builds on an empty table, handles inserts without rebuilds and gives better recall for the latency. Use IVFFlat only for large, mostly static datasets where build time or memory is the constraint.
Why does my pgvector query with a WHERE clause return fewer results than the LIMIT?
Approximate indexes filter after the scan. With the default hnsw. of 40, a filter matching 10% of rows yields about four results. Turn on hnsw., raise ef_search, or run an exact scan over the filtered rows when they are few.
Can I do BM25 hybrid search in Postgres? Yes. Built-in full-text search works as a keyword retriever but is not BM25. For real BM25 use pg_textsearch or ParadeDB's pg_search, then fuse with the vector results using reciprocal rank fusion in SQL, as shown above.
How much does Pinecone cost compared with pgvector? Pinecone serverless charges per GB searched, so a query over a 66 GB namespace costs 66 read units while a query over a small per-tenant namespace costs 0.25. pgvector costs the RAM to keep the index in memory on an instance you may already run. Per-tenant workloads are cheap on both; high-QPS search over one large corpus is where the comparison gets close.
When should I migrate from pgvector to a dedicated vector database? When the index no longer fits in memory on your largest sensible replica, rebuilds no longer fit your change windows, or you need many isolated high-traffic tenants. Not before. A migration is easier from a working pgvector system than from an early bet on a second database.