Skip to content

Conversation

@mgartner
Copy link
Collaborator

@mgartner mgartner commented Nov 3, 2025

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.

@mgartner mgartner requested review from a team and michae2 November 3, 2025 18:08
@mgartner mgartner requested a review from a team as a code owner November 3, 2025 18:08
@blathers-crl
Copy link

blathers-crl bot commented Nov 3, 2025

Thanks for opening a backport.

Before merging, please confirm that it falls into one of the following categories (select one):

  • Non-production code changes. Includes test-only changes, build system changes, etc.
  • Fixes for serious issues. Defined in the policy as correctness, stability, or security issues, data corruption/loss, significant performance regressions, breaking working and widely used functionality, or an inability to detect and debug production issues.
  • Other approved changes. These changes must be gated behind a disabled-by-default feature flag unless there is a strong justification not to.

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.

@blathers-crl blathers-crl bot added backport Label PR's that are backports to older release branches T-sql-queries SQL Queries Team labels Nov 3, 2025
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@blathers-crl
Copy link

blathers-crl bot commented Nov 3, 2025

❌ PR #156797 does not comply with backport policy

Confidence: medium
Explanation: The PR intends to make modifications in two areas: enhancing selectivity estimations for query plans and introducing a new session setting named 'optimizer_use_max_frequency_selectivity'. None of these changes appear to address critical bugs as defined by stability, data corruption, or significant performance regressions. The new session setting could be viewed as a feature flag, but the PR lacks explicit evidence that this setting is disabled by default. Additionally, the 'Release justification' line in the PR body mentions a 'low-risk planning improvement' which does not suggest an immediate and critical fix or any sort of gating behind a feature flag necessary for less critical changes, as per the Backport Policy.
Recommendation: Request clarification or addition of details regarding the default state of the new session setting to confirm it as a feature flag. Alternatively, reconsider the backport due to the lack of critical bug fix criteria met.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@mgartner mgartner changed the title release-25.2: release-25.3: opt: estimate worst-case selectivity of placeholder equalities release-25.2: opt: estimate worst-case selectivity of placeholder equalities Nov 3, 2025
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
@mgartner mgartner force-pushed the backport25.2-156791 branch from b7faaaf to 013bb75 Compare November 4, 2025 21:24
Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@michae2 reviewed 17 of 17 files at r1, 10 of 10 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner)

@mgartner mgartner merged commit 073b195 into cockroachdb:release-25.2 Nov 5, 2025
14 of 16 checks passed
@mgartner mgartner deleted the backport25.2-156791 branch November 5, 2025 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Label PR's that are backports to older release branches T-sql-queries SQL Queries Team target-release-25.2.10

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants