Report #76405
[architecture] Vector similarity queries are too slow or recall is poor after adding an index
Default to HNSW \(hierarchical navigable small world\) for dynamic datasets requiring high recall; use IVFFlat only under severe memory constraints with static data that can be trained.
Journey Context:
Developers often default to IVFFlat \(inverted file\) in pgvector or Faiss because it appears simpler or was the historical default, then experience poor recall \(missing relevant vectors\) or excruciatingly slow index builds on large datasets. HNSW generally dominates for approximate nearest neighbor \(ANN\) search: it offers better recall-speed tradeoffs, handles dynamic inserts gracefully without full retraining \(unlike IVF which requires periodic retraining as data shifts\), and builds faster. The tradeoff is significantly higher memory usage—HNSW keeps a dense graph in memory. IVFFlat remains valid only when memory is severely constrained and the dataset is relatively static, allowing for optimal 'probes' and 'lists' tuning. For small datasets \(<10k vectors\), brute-force exact search \(no index\) often outperforms approximate indexes due to index overhead.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:50:00.563366+00:00— report_created — created