pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: mauriciocirelli (@mauriciocirelli) <noreply+mauriciocirelli@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #259: Understanding HNSW + filtering
Date: Wed, 08 May 2024 17:00:21 +0000
Message-ID: <gh-pgvector-pgvector-259-c2101019002@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-259@github.com>
References: <gh-pgvector-pgvector-259@github.com>

@williamhakim10 

The question is very straightforward.
I have many documents in several different categories. On PG15, a query returns 3 results, when I LIMIT to 10. On PG16, the same query returns 10 results.
If I do not use the LIMIT clause, either PG version return all related documents.

As I see on the plan, on PG15, it is using the HNSW index. On PG16, it is using the owner id index. 

It seems to me that on PG15, it is using the HNSW index and limiting its search to the 10 NN (from the LIMIT clause), while it should not do it. The LIMIT clause should be applied only on the final step, after all other filterings.

Why HNSW index is limiting its search on the inner query on PG15? This is what I am trying to understand and, if possible, workaround, to provide the correct results to the end application. The same query on the same data, should return the same results. In this case, 10 documents, because there are 10 documents that satisfy all the conditions.

view thread (90+ messages)  latest in thread

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