pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: fanfuxiaoran (@fanfuxiaoran) <noreply+fanfuxiaoran@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #259: Understanding HNSW + filtering
Date: Mon, 18 Sep 2023 08:53:58 +0000
Message-ID: <gh-pgvector-pgvector-259-c1723000331@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-259@github.com>
References: <gh-pgvector-pgvector-259@github.com>

@jkatz  Your approach of creating multiple columns index to support attribute filtering looks good to me. 
>Finally, in the case we have a category_id present, I wonder if we can store the values in the lists themselves in a B-tree structure, so that way we can go directly to those values.

I think storing the values in the lists themselves in a B-tree structure would have a bad performance as the size of the vector struct is big and we need to read the pages randomly to compute the distances for a specific list as the `category_id` that in the same list may be distributed in different pages.

>HNSW -- effectively keeping two pairs of links in a "multi-column" style index

It could work when the predicate is '=',  but how about '>' or '<'?
 I have another idea about HNSW index, which is similar to ivfflat index.  We need to maintain such info in HNSW index: given a TID we can directly get its entry point in different layers. When fetching the index, first get the 'TID's ( the base heap table TID)   that matches the attribute filter. Then fetch the entry points for those 'TID's. Finally, choose the entry point in each layer based on the vector distance to the query vector and those 'TIDs to do search.

view thread (90+ messages)  latest in thread

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