Skip to content

release-26.1: opt: apply min_row_count to anti-joins#164798

Merged
DrewKimball merged 1 commit intocockroachdb:release-26.1from
DrewKimball:backport26.1-163244
Mar 4, 2026
Merged

release-26.1: opt: apply min_row_count to anti-joins#164798
DrewKimball merged 1 commit intocockroachdb:release-26.1from
DrewKimball:backport26.1-163244

Conversation

@DrewKimball
Copy link
Copy Markdown
Collaborator

@DrewKimball DrewKimball commented Mar 4, 2026

Backport 1/4 commits from #163244.

/cc @cockroachdb/release


opt: apply min_row_count to anti-joins

Previously, the optimizer_min_row_count setting did not apply to the
final selectivity calculated for AntiJoin expressions. This meant that
the setting was applied asymmetrically, which could cause the optimizer
to choose bad plans. This commit fixes the issue, gated behind a session
setting optimizer_use_min_row_count_anti_join_fix.

Fixes #162258

Release note (bug fix): Fixed a bug that prevented the optimizer_min_row_count
setting from applying to anti-join expressions, which could lead to bad query
plans. The fix is gated behind optimizer_use_min_row_count_anti_join_fix, and
will be on by default on 26.2+, and off by default in prior versions.


Release justification: critical fix for optimizer regression in 25.4

@DrewKimball DrewKimball requested a review from michae2 March 4, 2026 05:34
@DrewKimball DrewKimball requested a review from a team as a code owner March 4, 2026 05:34
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Mar 4, 2026

Thanks for opening a backport.

Before merging, please confirm that the change does not break backwards compatibility and otherwise complies with the backport policy. Include a brief release justification in the PR description explaining why the backport is appropriate. All backports must be reviewed by the TL for the owning area. While the stricter LTS policy does not yet apply, please exercise judgment and consider gating non-critical changes behind a disabled-by-default feature flag when appropriate.

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

This change is Reviewable

@DrewKimball DrewKimball requested review from mw5h and removed request for michae2 March 4, 2026 05:34
Previously, the `optimizer_min_row_count` setting did not apply to the
final selectivity calculated for AntiJoin expressions. This meant that
the setting was applied asymmetrically, which could cause the optimizer
to choose bad plans. This commit fixes the issue, gated behind a session
setting `optimizer_use_min_row_count_anti_join_fix`.

Fixes cockroachdb#162258

Release note (bug fix): Fixed a bug that prevented the optimizer_min_row_count
setting from applying to anti-join expressions, which could lead to bad query
plans. The fix is gated behind `optimizer_use_min_row_count_anti_join_fix`, and
will be on by default on 26.2+, and off by default in prior versions.
@DrewKimball DrewKimball force-pushed the backport26.1-163244 branch from a2737f4 to 5cd845c Compare March 4, 2026 05:40
Copy link
Copy Markdown
Contributor

@mw5h mw5h left a comment

Choose a reason for hiding this comment

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

:lgtm:

@mw5h made 1 comment.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained.

@DrewKimball DrewKimball merged commit fac79fd into cockroachdb:release-26.1 Mar 4, 2026
18 checks passed
@DrewKimball DrewKimball deleted the backport26.1-163244 branch March 4, 2026 22:57
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-26.1.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants