pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: knizhnik (@knizhnik) <noreply+knizhnik@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] PR #282: Hnsw iterator
Date: Fri, 29 Sep 2023 14:05:52 +0000
Message-ID: <gh-pgvector-pgvector-282-rc1341411376@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-282-rc1341132985@github.com>
References: <gh-pgvector-pgvector-282@github.com>
	<gh-pgvector-pgvector-282-rc1341132985@github.com>

(on src/hnswutils.c:624)

> W should use `CompareFurthestCandidates`

Actually it is not completely true. pgvector really uses reverse (distance descending) order for W, because 
1.  It needs to get largest distance already selected in W
2. Be able to replace item with largest distance with better candidate.

We do not need 2 and we need to extract best candidate from W (with smallest distance).
In the original pgvector implementation it is solved by extracting all elements and  appending them to the list (so finally in the list them are in correct distance ascending order).
But in case of iterator I need to select just one best  item.

But you was right - I incorrectly used pairingheap_first to get the largest distance. It is fixed now.

view thread (33+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-282-rc1341411376@github.com>
Permalink:  ../gh-pgvector-pgvector-282-rc1341411376@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox