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
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.
向量数据库的核心操作是近似最近邻搜索(ANN),通过HNSW、IVF等索引算法将相似度计算加速到毫秒级响应
HNSW and IVF are two mainstream approximate nearest neighbor indexing algorithms; HNSW offers fast query speeds and high recall but requires relatively large memory.
Timeline (last 90 days)
Common indexes for pgvector include IVFFlat and HNSW; the former builds quickly but its recall is affected by parameters, while the latter has better query performance but higher memory usage.
pgvector supports two types of vector indexes, HNSW and IVFFlat, and index construction and queries are constrained by PostgreSQL's page management, concurrency control and memory model.
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.
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.
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 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.
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).
6 more timeline events
All Facts (16)
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.
90%Verified向量数据库的核心操作是近似最近邻搜索(ANN),通过HNSW、IVF等索引算法将相似度计算加速到毫秒级响应
80%VerifiedHNSW and IVF are two mainstream approximate nearest neighbor indexing algorithms; HNSW offers fast query speeds and high recall but requires relatively large memory.
65%UnverifiedCommon indexes for pgvector include IVFFlat and HNSW; the former builds quickly but its recall is affected by parameters, while the latter has better query performance but higher memory usage.
50%Unverifiedpgvector supports two types of vector indexes, HNSW and IVFFlat, and index construction and queries are constrained by PostgreSQL's page management, concurrency control and memory model.
50%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%