HNSW is both more accurate and faster at 2M rows, it costs a much longer, heavier build, and it needs no retraining as the catalog grows.
Embedding benchmarks, September
We compared two pgvector index types on the full product catalog: 2.1 million rows, 1,536 dimensions, cosine distance. Every query ran against a warm cache on the production replica size.
Method
Each index answered the same 5,000 search queries sampled from last month's traffic. We measured recall against an exact scan and recorded latency at the 95th percentile. Builds ran on an otherwise idle machine.
Results
HNSW held 0.97 recall at 9 ms p95 with ef_search set to 80. Raising it to 200 moved recall to 0.99 and latency to 17 ms, which is past the retrieval budget.
IVFFlat with 1,000 lists reached 0.91 recall at 14 ms. Probing more lists closed some of the gap, but latency climbed faster than recall did.
Build cost
The HNSW build took 41 minutes and peaked at 11 GB of memory. IVFFlat built in 6 minutes and never passed 2 GB.
The longer build is a one-time cost. Rows added later join the HNSW graph as they are written, so there is no retraining step. IVFFlat lists are fixed at build time and drift as the catalog changes.
Recommendation
Use HNSW for product search. Keep IVFFlat in mind for the nightly analytics tables, where builds run often and a few points of recall matter less.