IVFFlat
An approximate nearest neighbor indexing method based on k-means clustering. It groups vectors into a number of clusters and scans only the nearest clusters at query time. It has low memory overhead and fast build times, but recall is generally lower than that of HNSW.
Core Facts
向量数据库的核心操作是近似最近邻搜索(ANN),通过HNSW、IVF等索引算法将相似度计算加速到毫秒级响应
pgvector is an open-source extension for PostgreSQL that natively adds vector data types and similarity search capabilities to the relational database, supporting both exact nearest-neighbor and approximate nearest-neighbor (HNSW, IVFFlat index) retrieval modes.
Timeline (last 90 days)
IVFFlat clusters the vector space into multiple Voronoi cells; on insertion it only computes the owning cluster and appends, with no global graph restructuring, so write throughput is higher, but recall is usually lower than HNSW.
The lists parameter of IVFFlat is generally recommended to be the square root of the row count, but write-intensive scenarios can use a smaller lists (e.g., 100) to reduce insertion overhead.
Creating both an IVFFlat index (for writes) and an HNSW index (for reads) to separate reads and writes can solve the write-write blocking problem, raising insertion throughput from 50/s to 180/s.
HNSW should be chosen for scenarios with frequent writes, continuously growing data, and sensitivity to recall; IVFFlat should be chosen for scenarios where data is relatively static, memory is tight, and periodic rebuilds are acceptable.
IVFFlat requires that the table already contain representative data when the index is built, otherwise the cluster centers cannot reflect the true distribution, and after new data is written the list distribution gradually becomes imbalanced and recall may drop, requiring periodic index rebuilds.
IVFFlat first uses k-means to cluster vectors into several lists, and at query time only scans the several lists closest to the query vector, with the probes parameter controlling the number of lists scanned.
The official announcement of pg_vectorsearch did not give the dimensionality of the benchmark dataset, the throughput (QPS), or a direct IVFFlat comparison, and multi-client throughput testing is listed as a to-be-completed item.
According to benchmark data provided by the project, Pg_vectorsearch surpasses pgvector's IVFFlat and HNSW in query throughput.
pgvector provides two index types, IVFFlat and HNSW, respectively aimed at different recall and speed trade-off scenarios.
IVFFlat uses two parameters, lists (the number of cluster buckets) and probes (the number of buckets actually scanned during a query); lists is often taken as rows/1000 (when the number of rows does not exceed one million) or sqrt(rows), and probes is usually tuned starting from sqrt(lists).
5 more timeline events
All Facts (14)
向量数据库的核心操作是近似最近邻搜索(ANN),通过HNSW、IVF等索引算法将相似度计算加速到毫秒级响应
80%Verifiedpgvector is an open-source extension for PostgreSQL that natively adds vector data types and similarity search capabilities to the relational database, supporting both exact nearest-neighbor and approximate nearest-neighbor (HNSW, IVFFlat index) retrieval modes.
70%UnverifiedThe lists parameter of IVFFlat is generally recommended to be the square root of the row count, but write-intensive scenarios can use a smaller lists (e.g., 100) to reduce insertion overhead.
50%UnverifiedIVFFlat clusters the vector space into multiple Voronoi cells; on insertion it only computes the owning cluster and appends, with no global graph restructuring, so write throughput is higher, but recall is usually lower than HNSW.
50%UnverifiedCreating both an IVFFlat index (for writes) and an HNSW index (for reads) to separate reads and writes can solve the write-write blocking problem, raising insertion throughput from 50/s to 180/s.
50%UnverifiedIVFFlat requires that the table already contain representative data when the index is built, otherwise the cluster centers cannot reflect the true distribution, and after new data is written the list distribution gradually becomes imbalanced and recall may drop, requiring periodic index rebuilds.
50%UnverifiedHNSW should be chosen for scenarios with frequent writes, continuously growing data, and sensitivity to recall; IVFFlat should be chosen for scenarios where data is relatively static, memory is tight, and periodic rebuilds are acceptable.
50%UnverifiedIVFFlat first uses k-means to cluster vectors into several lists, and at query time only scans the several lists closest to the query vector, with the probes parameter controlling the number of lists scanned.
50%Unverifiedpgvector provides two index types, IVFFlat and HNSW, respectively aimed at different recall and speed trade-off scenarios.
50%UnverifiedIVFFlat uses two parameters, lists (the number of cluster buckets) and probes (the number of buckets actually scanned during a query); lists is often taken as rows/1000 (when the number of rows does not exceed one million) or sqrt(rows), and probes is usually tuned starting from sqrt(lists).
50%UnverifiedWhen the data distribution is skewed or the number of clusters is set improperly, IVFFlat will face the dilemma of recall collapsing because too few buckets are scanned, or speed degrading because too many buckets are scanned.
50%Unverifiedpgvector supports two mainstream types of indexes, HNSW and IVFFlat; HNSW has high recall and low latency but is slow to build and uses a lot of memory; IVFFlat has low memory overhead and builds quickly but usually has lower recall.
50%UnverifiedAt very large scale datasets, pgvector's performance based on IVFFlat or HNSW indexes is often constrained by single-machine memory and CPU resources, making horizontal scaling difficult.
50%UnverifiedHNSW 和 IVF 是两类主流的近似最近邻索引算法,HNSW 查询速度快、召回率高但内存占用较大
50%