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 19:09:19 +0000
Message-ID: <gh-pgvector-pgvector-282-rc1341714050@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)

Yep...
Using max_distance was not good idea: it cause extraction of almost all elements in memory which leads to very bad performance and high memory consumption. So I have changed implementation to use distance to n-th element as criteria to stop recursive traversal. Now this time is almost the same as with original implementation.

To do it I have implemented function `pairingheap_nth`. It is very naive implementation: it just recursively call `pairingheap_delete_first` N times and then reconstruct the tree, adding removed elements back.
Maybe it is really better to maintain one more pairing heap, but I am not sure if it is better. At least approach with `pairingheap_nth` is much simpler.


view thread (33+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-282-rc1341714050@github.com>
Permalink:  ../gh-pgvector-pgvector-282-rc1341714050@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