pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: hlinnaka (@hlinnaka) <noreply+hlinnaka@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] PR #282: Hnsw iterator
Date: Mon, 30 Oct 2023 10:06:10 +0000
Message-ID: <gh-pgvector-pgvector-282-c1784860844@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-282@github.com>
References: <gh-pgvector-pgvector-282@github.com>

> Hi @knizhnik, thanks for the PR. It's an interesting approach, but want to explore potentially more efficient methods like [HQANN](https://arxiv.org/abs/2207.07940) for filtered search.

HQANN is interesting. [Filtered-DiskANN](https://harsha-simhadri.org/pubs/Filtered-DiskANN23.pdf) is a similar paper but with more thorough experiments IMHO. It's based on Vamana but I think the results would be similar with HNSW.

A problem with that approach is that it's only applicable to equality quals (e.g. `col = 'foo'`). Those are common, but there's a long tail of other queries where it doesn't help. So if we can improve the post-filtering, that would still be useful even if we had HQANN.

> For returning results out-of-order: It's definitely not ideal, but will likely happen with scalar/product quantization as well (and will likely cause confusion since it's not intuitive). Ideally Postgres would have an option to re-rank results from the heap (that access methods / index scans could set), but as far as I know, there's not a way to currently do this.

Ok. Re-ranking could indeed reduce the confusion to applications. It wouldn't help within the executor though; even if you sort the final result set, the intermediate results would still be in wrong order, which can confuse e.g. merge joins or group by. You usually couldn't force re-sorting the intermediate results because you don't know beforehand how many tuples you need from the intermediate node. I think we need to either:

a) Accept weird results if the planner chooses a plan that depends on the ordering, like a merge join,
b) Omit the out-of-order results from the result set altogether, or
c) Introduce the concept of "approximate order" to the planner. If a result set is in approximate order, it's good enough to satisfy an ORDER BY requested by the user, but not for merge joins and such. (And optionally, we could re-sort the final result, if it's in approximate order)

I don't think this is a huge problem in practice. When someone is using a pgvector index, they've already accepted that the results are approximate. Nevertheless it would be nice to have a coherent story on what kind of errors can happen.


view thread (33+ messages)  latest in thread

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