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 15:15:38 +0000
Message-ID: <gh-pgvector-pgvector-259-c2100820604@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-259@github.com>
References: <gh-pgvector-pgvector-259@github.com>
Hi @williamhakim10
Yes, I understand that. In the second query planner it has chosen to use the category/owner index instead of the HNSW index. So it was "brute-forcing" the distance, but only on a subset of the data.
But I have cases which a super-user could search for any document, so the owner index would not be used. In such cases, the HSNW index would be very helpful. Dropping it may cause a performance impact for super-users searches.
So, basically, it is up to postgres to decide which is the best index to use. I am fine with that and PG16 is doing it properly.
The issue is that on PG15, it is not returning the correct data. When I have "pre-filters", it is chosing a query planner that returns less results than I would expect (3 instead of 10) because it is applying the "pre-filters" after finding the 10 nearest neighbors.