pgvector, the Postgres extension for vector similarity search, defaults to sequential scans that guarantee 100% recall but become costly beyond ~50k rows. Switching to IVFFlat indexing enables approximate nearest neighbor (ANN) search, reducing query time from ~39ms to ~6ms on tested datasets. The two key tuning parameters are lists (number of k-means clusters) and probes (clusters explored per query). Recommended starting points: lists = rows/1000 for up to 1M rows, probes = lists/10 for up to 1M rows. Increasing probes improves recall but yields diminishing returns on execution time, so experimentation is advised for each specific dataset.

4m read timeFrom neon.com
Post cover image
Table of contents
Sequential scans with pgvectorIndexing with IVFFlatConclusion
2 Impressions