pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: jkatz (@jkatz) <noreply+jkatz@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #719: SELECT WHERE ORDER BY LIMIT no results
Date: Fri, 20 Dec 2024 14:41:15 +0000
Message-ID: <gh-pgvector-pgvector-719-c2557141475@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-719@github.com>
References: <gh-pgvector-pgvector-719@github.com>

> > @Tibiritabara did you modify these variables?
> > ```sql
> > hnsw.ef_search = 200;
> > hnsw.iterative_scan = 'strict_order';
> > hnsw.max_scan_tuples = 20000;
> > hnsw.scan_mem_multiplier = 2;
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > I **_had_** to set these and do some very basic tuning to get results
> 
> I faced the same issue and this workaround has worked for me.

This isn't a workaround - [it's a feature](https://github.com/pgvector/pgvector?tab=readme-ov-file#filtering). Setting `hnsw.iterative_scan` lets PostgreSQL know to continue scanning the index until enough results are returned. We explicitly don't set `hnsw.iterative_scan` by default in v0.8.0, in part because it may not be the best method for all queries involving filters, which I'll discuss more below.

I still need to finish a blog post on this topic, but I [recently spoke on strategies around handling `WHERE` clauses](https://www.youtube.com/watch?v=L8fQqVwTT3Y&ab_channel=AWSEvents) and how the selectivity of your query (how many results you expect to return - high selectivity means you return only a few results) impacts your indexing strategy. Based on your query pattern, it may make more sense to use a B-tree or other index type than a vector index. This can give you both faster queries and better quality results, but it depends on the overall composition of your data.

view thread (31+ messages)  latest in thread

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