From: hlinnaka (@hlinnaka) <noreply+hlinnaka@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #678: Iterative index scans
Date: Tue, 24 Sep 2024 12:19:08 +0000
Message-ID: <gh-pgvector-pgvector-678-c2371112515@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-678@github.com>
References: <gh-pgvector-pgvector-678@github.com>
Nice to see some action on this!
I had a look at the [hnsw-streaming](https://github.com/pgvector/pgvector/compare/hnsw-streaming) branch, thinking how it compares with the previous work I did at https://github.com/hlinnaka/pgvector/tree/hnsw_iterator (discussed in PR #282), and #524. If I understand correctly, hnsw-streaming and my "hnsw_iterator" implementation use the same approach: Instead of discarding items, put them in another heap, and take items back from that heap if more items are needed. The difference is that hnsw-streaming works in batches, while hnsw_iterator runs the algorithm continuously on every tuple.
At quick glance, I think PR #524 is more similar to hsnw-treamng, as it also works in batches.
It would be interesting to benchmark these. I like the continuous approach in hnsw_iterator, it feels more principled than working in batches, but it probably doesn't make much difference in practice.
For easier comparison, I rebased and squashed my hnsw_iterator branch on top of current 'master'. It doesn't handle the vacuum locking correctly, but that should be easy to fix. The code is structured so that it keeps the existing HnswSearchLayer code unmodified for the non-continuous case, and duplicates the logic. This makes it easier to compare, but the code could easily be deduplicated.