From: ianwoodfill (@ianwoodfill) <noreply+ianwoodfill@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #259: Understanding HNSW + filtering
Date: Tue, 05 Mar 2024 16:18:35 +0000
Message-ID: <gh-pgvector-pgvector-259-c1979144982@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-259@github.com>
References: <gh-pgvector-pgvector-259@github.com>
I'll chime in with a potentially relevant use case.
We store vector representations of text files in a hierarchical file system represented in postgres. We have a `folder` table that can be infinitely nested, and a `file` table with the documents themselves and their vector representations.
We run a vector search on parts of these tables in unpredictable patterns, defined by end-users. For example, a user might do a vector search within a certain folder and its subdirectories/contents, or even multiple folders. We use a recursive CTE to determine the file search space, and do a vector similarity search on that.
This query pattern has made it very difficult to efficiently use indices/partinioning, since the best we can do is at the file-system level (each end-user gets their own file system).
We found that queries often incorrectly choose to use or not use the index, resulting in query timeouts or low recall. We've discussed manually implementing solutions like @lambda-science suggested, imagining that would work better for our use case.
We've currently resolved to relying on KNN, and instead using hardware with high disk throughput to avoid losing recall and improve query speeds. Obviously this is not super scalable.