-
Notifications
You must be signed in to change notification settings - Fork 4k
release-25.2: opt: estimate worst-case selectivity of placeholder equalities #156797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
release-25.2: opt: estimate worst-case selectivity of placeholder equalities #156797
Conversation
|
Thanks for opening a backport. Before merging, please confirm that it falls into one of the following categories (select one):
Add a brief release justification to the PR description explaining your selection. Also, confirm that the change does not break backward compatibility and complies with all aspects of the backport policy. All backports must be reviewed by the TL and EM for the owning area. |
|
❌ PR #156797 does not comply with backport policy Confidence: medium 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Previously, we calculated the selectivity of placeholder equality filters, e.g., `x = $1`, using the distinct count of a column and total row count. This represented an average-case selectivity. Now, we instead estimate the worst-case selectivity using the maximum frequency of the histogram of the constrained column. This helps avoid choosing a generic query plan under `plan_cache_mode=auto` that performs poorly for heavy-hitter placeholder values. Fixes cockroachdb#151373 Release note (performance improvement): The cost of generic query plans is now calculated based on worst-case selectivities for placeholder equalities (e.g., x = $1). This reduces the chance of suboptimal generic query plans being chosen when `plan_cache_mode=auto`.
The `optimizer_use_max_frequency_selectivity` session setting has been added. It is enabled by default. Disabling it reverts the selectivity improvements added in cockroachdb#151409. Release note: None
b7faaaf to
013bb75
Compare
michae2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michae2 reviewed 17 of 17 files at r1, 10 of 10 files at r2, all commit messages.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @mgartner)
Backport 2/2 commits from #156791.
/cc @cockroachdb/release
Backport:
Please see individual PRs for details.
/cc @cockroachdb/release
Release justification: Low-risk planning improvement for generic query plans.