From: xzilla (@xzilla) <noreply+xzilla@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] PR #422: Add FAQ HNSW vs IVFFlat?
Date: Sat, 20 Jan 2024 17:19:33 +0000
Message-ID: <gh-pgvector-pgvector-422@github.com> (raw)
Summarize the trade-offs at play when choosing between HNSW or IVFFlat indexes.
Inspired by recent PR #404 by @danthedaniel.
inline patch 1: README.md (+12/-0 lines) download inline-1.patchdiff --git a/README.md b/README.mdindex c84436236..1fd1ac4e7 100644--- a/README.md+++ b/README.md@@ -499,6 +499,18 @@ No, but like other index types, you’ll likely see better performance if they d
SELECT pg_size_pretty(pg_relation_size('index_name'));
```
+#### Should I use HNSW or IVFFlat indexes?++The ideal index type depends on specific trade-offs needed for any given workload. While a comprehensive analysis of all possible trade-offs is outside the scope of this discussion, the following provides a summary of typical (but not definitive) expectations. Of course we recommend benchmarking your specific workload for optimal performance.++Feature | HNSW | IVFFlat+--- | --- | ---+Query speed | Faster | Slower+Recall | Higher | Lower+Index building | Slower | Faster+Memory usage | Higher | Lower+Incremental data changes | Handles well | Less optimal, may need re-building+
## Troubleshooting
#### Why isn’t a query using an index?