pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: VladlenPopolitov (@VladlenPopolitov) <noreply+VladlenPopolitov@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] PR #524: Add search option to better process queries with WHERE clause (relaxed monotonicity)
Date: Sun, 18 Aug 2024 10:03:34 +0000
Message-ID: <gh-pgvector-pgvector-524-c2295203790@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-524@github.com>
References: <gh-pgvector-pgvector-524@github.com>

Hi @ankane ! I did benchmarks for pgvector in standard mode and relaxed mode and found, that search results depends more on filters value distributrion, than search algorithms: there is no universal best search algorithm.
1) When there is no filter, standard pgvector slightly quicker, than relaxed (due to relaxed's overhead to store all visited vectors- I showed it on picture in pull request comment above) 
2) When there is filter condition with ~2-10 values, relaxed algorithm becomes faster than standard (relaxed decreases speed with the remaining recall, standard increases efsearch to keep the same recall resulting higher speed decrease)
![benchmark3_1](https://github.com/user-attachments/assets/9ce3247b-9a59-4ccd-a921-64b254bf72a9)

3) When filter has ~100 values relaxed drops speed keeping recall rate, standard drops recall to 1-10% and becomes unusable, it returns empty datasets instead of some not nearest vectors.
![benchmark3_1](https://github.com/user-attachments/assets/2646465b-31c2-45a7-924d-302c9017a259)

4) When filter has ~1000 values, standard returns almost always empty datasets, relaxed returns the same recall, but slower than table scan without index. In this situation usual btree index works very fast (quick filter and then distance calculation for filtered tuples from table).
![benchmark3_1](https://github.com/user-attachments/assets/d16e8ae5-f02e-4ab3-aede-59cbb55da9a5)

5) When filter has ~1000 values and table is very big, then btree index also does not work. In this situation composite index can help, that naturally process filter conditions.

relaxed mode gives to users more options to search, when they need filters. Also I would point, that pgvectorscale also implemented similar algorithm, when results returned until filter conditions are satisfied and all records returned.
I think, maybe "relaxed" name is not properly explain the method, probably better is "stream".

I could update pull request to the current code base. It is also interesting, what are your findings regarding filtered search.

view thread (15+ messages)  latest in thread

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