pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: hlinnaka (@hlinnaka) <noreply+hlinnaka@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] PR #424: Update cost estimation to not use index when expected tuples is too low
Date: Mon, 22 Jan 2024 00:22:37 +0000
Message-ID: <gh-pgvector-pgvector-424-c1902822740@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-424@github.com>
References: <gh-pgvector-pgvector-424@github.com>

This approach seems pretty inflexible to me. Off the top of my head, some scenarios where this can go wrong:

1. There might be a LIMIT at the top of the query, but the index scan is part of a larger plan. Consider a partitioned table, for example. The hnsw.ef_search parameter would apply to each scan separately, so the combined end result can have many more results, which might be fine. Or UNION. Or a join that produces many output rows for each row from the index scan.

2. There might be joins which filter rows, not just plain quals on the table itself.

3. LIMIT can be a parameter, e.g. `LIMIT $1`, not known at planning time.

4. There is no LIMIT, but the the client only fetches X first rows from the cursor.

5. Selectivity estimates can be very poor. If the planner estimates that a clause is very selective, but in reality it's not, this would heavily favor a seqscan even though an index scan would be appropriate. This is of course always a problem with planning any query, but this PR introduces a very strong bias on what is considered.


view thread (15+ messages)  latest in thread

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