fix(vchordrq): estimate filtered candidate selectivity#461
Open
spenc-r wants to merge 1 commit into
Open
Conversation
Use the planner's filtered row estimate as filter selectivity for deciding how many IVFFlat candidates are needed to satisfy LIMIT after heap-side quals. Report indexSelectivity from the expected retrieved candidate count instead of the final survivor fraction, so cost_index() prices heap fetch and qpqual evaluation against candidate rows rather than every table row or only the rows that pass filters. Clamp the candidate-processing term by node_count, and tighten the cost estimator sqllogictest coverage around btree alternatives, candidate-cost floors, and extreme selectivity.
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
gaocegege
added a commit
to tensorchord/CLA
that referenced
this pull request
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Fixes vchordrq cost estimation for filtered
ORDER BY distance LIMIT ...queries.The estimator now separates:
baserel->rowsor parameterizedppi_rows)This avoids reporting
indexSelectivity = 1.0for heap-side filters that are not index quals, while also avoiding the opposite under-estimate of reporting only the final survivor fraction.The candidate-processing term is also clamped by the IVF candidate budget (
node_count).Why
For vchordrq indexes, filters on non-vector columns live in
baserestrictinfo, notindexclauses. The previous estimator therefore often reported selectivity as 1.0, causing PostgreSQL to price expensive filter evaluation against the whole table and reject the vector index path even when it was the better plan.Tests
tests/vchordrq/cost_estimator.sltgit diff --check origin/main...HEAD