Skip to content

planner: enable cd-c algorithm by default for join reorder | tidb-test=pr/2676#66349

Merged
ti-chi-bot[bot] merged 55 commits intopingcap:masterfrom
guo-shaoge:post_cdc_impl
Mar 13, 2026
Merged

planner: enable cd-c algorithm by default for join reorder | tidb-test=pr/2676#66349
ti-chi-bot[bot] merged 55 commits intopingcap:masterfrom
guo-shaoge:post_cdc_impl

Conversation

@guo-shaoge
Copy link
Copy Markdown
Collaborator

@guo-shaoge guo-shaoge commented Feb 24, 2026

What problem does this PR solve?

Issue Number: close #63887

Problem Summary:

  1. enable new join reorder impl by default
  2. clean all the cases

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Summary by CodeRabbit

  • Bug Fixes

    • Improved query execution plan optimization for complex joins, particularly with outer join reordering and index range predicate handling.
    • Fixed join predicate ordering in query plans to ensure correct optimization and execution.
  • Tests

    • Enhanced test coverage for query optimization scenarios and join reordering strategies.
    • Updated test assertions for improved reliability of plan validation tests.

Signed-off-by: guo-shaoge <shaoge1994@163.com>
@pantheon-ai
Copy link
Copy Markdown

pantheon-ai Bot commented Feb 24, 2026

I've accepted your request and will start reviewing the pull request. I'll conduct a thorough review covering code quality, potential issues, and implementation details.

⏳ This process typically takes 10-30 minutes depending on the complexity of the changes.

Open in Web
Learn more about Pantheon AI

@ti-chi-bot ti-chi-bot Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. sig/planner SIG: Planner labels Feb 24, 2026
@guo-shaoge guo-shaoge changed the title planner: enable cd-c algorithm by default for join reorder [WIP] planner: enable cd-c algorithm by default for join reorder Feb 24, 2026
@ti-chi-bot ti-chi-bot Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 24, 2026
@guo-shaoge
Copy link
Copy Markdown
Collaborator Author

remainder: add inTest check if has remaining edge

Copy link
Copy Markdown

@pantheon-ai pantheon-ai Bot left a comment

Choose a reason for hiding this comment

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

P2: join reorder fallback behavior

Comment thread pkg/planner/core/rule_join_reorder.go
Copy link
Copy Markdown

@pantheon-ai pantheon-ai Bot left a comment

Choose a reason for hiding this comment

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

Requesting changes due to a P1 cost bug and two operability/behavior changes surfaced by making CD-C join reorder the default. See inline comments for details.

}
})
if p.SCtx().GetSessionVars().EnableOuterJoinReorder {
p, err := joinorder.Optimize(p)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 (see pkg/planner/core/joinorder/join_order.go:507): With default tidb_opt_cartesian_join_order_threshold=0 (CartesianJoinOrderThreshold), CD-C’s 2nd pass forces allowNoEQ=true and then multiplies cumCost by cartesianFactor (0), making cartesian/no-EQ joins cost 0. This can drive severe plan regressions/OOM once this path is default; please ensure the penalty never reduces cost (e.g., clamp factor >=1 / additive penalty) and/or don’t run the 2nd pass when cartesian is disabled.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

updated

Copy link
Copy Markdown

@pantheon-ai pantheon-ai Bot Mar 11, 2026

Choose a reason for hiding this comment

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

Thanks for the update. The next push will be reviewed to confirm the cartesian factor clamping/penalty fix is in place and no longer causes cost collapse to 0.

ℹ️ Learn more details on Pantheon AI.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

PTAL, I've updated the code related to cumCost and cartesianFactor

Copy link
Copy Markdown

@pantheon-ai pantheon-ai Bot Mar 12, 2026

Choose a reason for hiding this comment

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

Confirmed fixed ✅ — the clamp at lines 485–486 of the latest commit correctly sets cartesianFactor = 1 before the second-pass greedyConnectJoinNodes call whenever cartesianFactor <= 0, preventing cumCost * 0 = 0. This resolves the cost-collapse concern. Thanks for addressing it.

ℹ️ Learn more details on Pantheon AI.

})
if p.SCtx().GetSessionVars().EnableOuterJoinReorder {
p, err := joinorder.Optimize(p)
return p, false, err
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 (see pkg/planner/core/joinorder/join_order.go:273): tidb_opt_join_reorder_threshold is effectively ignored (threshold check commented out; useGreedy := true), making DP unreachable. This is a compatibility/operability regression for users relying on DP join reorder with threshold > 0.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

DP will be implemented in future pr

Copy link
Copy Markdown

@pantheon-ai pantheon-ai Bot Mar 11, 2026

Choose a reason for hiding this comment

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

Understood — please consider adding a comment in the code noting that tidb_opt_join_reorder_threshold is temporarily non-functional (DP path pending a follow-up PR), so operators and future contributors are not surprised by the ignored variable. A tracking issue link would also help.

ℹ️ Learn more details on Pantheon AI.

Comment thread pkg/planner/core/rule_join_reorder.go Outdated
failpoint.Return(p2, false, err)
}
})
if p.SCtx().GetSessionVars().EnableOuterJoinReorder {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: EnableOuterJoinReorder now selects which join reorder engine runs (joinorder.Optimize vs optimizeRecursive), impacting pure-inner-join queries too. That changes the var’s operational meaning beyond “whether outer joins participate”; consider a separate session var/flag for engine selection and keep this var scoped to outer-join behavior.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

outdated comment

Copy link
Copy Markdown

@pantheon-ai pantheon-ai Bot Mar 11, 2026

Choose a reason for hiding this comment

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

Acknowledged — if the engine-selection logic has been refactored in the latest commits, this concern no longer applies. Thanks for the update.

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Feb 24, 2026

@pantheon-ai[bot]: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

Requesting changes due to a P1 cost bug and two operability/behavior changes surfaced by making CD-C join reorder the default. See inline comments for details.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Comment thread pkg/planner/core/rule_join_reorder.go Outdated
failpoint.Return(p2, false, err)
}
})
if p.SCtx().GetSessionVars().EnableOuterJoinReorder {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Routing the default join-reorder through joinorder.Optimize (via EnableOuterJoinReorder) bypasses the legacy extractJoinGroup path that checks tidb_opt_join_reorder_through_sel (TiDBOptJoinReorderThroughSel, around L53). This makes that knob ineffective in default configs. Should the new joinorder path honor it (or document/rename it as legacy-only)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

outdated comment. TiDBOptJoinReorderThroughSel has been supported in the new impl

Copy link
Copy Markdown

@pantheon-ai pantheon-ai Bot Mar 11, 2026

Choose a reason for hiding this comment

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

Acknowledged — good to know TiDBOptJoinReorderThroughSel is now handled natively in the new implementation. The related P1 concern about selection predicates potentially being dropped when that knob is ON (filed separately at join_order.go:85/94) still stands and should be verified once addressed.

ℹ️ Learn more details on Pantheon AI.

@guo-shaoge guo-shaoge changed the title [WIP] planner: enable cd-c algorithm by default for join reorder [WIP] planner: enable cd-c algorithm by default for join reorder | pr=tidb-test/2676 Mar 2, 2026
@guo-shaoge guo-shaoge changed the title [WIP] planner: enable cd-c algorithm by default for join reorder | pr=tidb-test/2676 planner: enable cd-c algorithm by default for join reorder | pr=tidb-test/2676 Mar 2, 2026
@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 2, 2026
@guo-shaoge
Copy link
Copy Markdown
Collaborator Author

/retest

Signed-off-by: guo-shaoge <shaoge1994@163.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 2, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR introduces schema-aligned join condition handling and replaces failpoint-based control flow with session variable gating for outer join reordering. Core planner logic is enhanced with condition alignment functions, and test expectations across multiple suites are updated to reflect the resulting query plan changes.

Changes

Cohort / File(s) Summary
Join Reorder Core Logic
pkg/planner/core/rule_join_reorder.go, pkg/planner/core/joinorder/conflict_detector.go
Replaced failpoint-based conditional with session variable gating for outer join reordering; introduced alignment functions (alignScalarFuncsNotNullWithSchema, alignExprsNotNullWithSchema, alignExprNotNullWithSchema) to align EQ and non-EQ conditions with joined schema; modified makeNonInnerJoin to use aligned conditions for predicate distribution.
Build Configuration
pkg/planner/core/joinorder/BUILD.bazel, pkg/planner/core/casetest/enforcempp/BUILD.bazel
Added dependencies: mysql parser package to joinorder library; testify/assert to enforcempp test suite.
Test Infrastructure
pkg/planner/core/casetest/enforcempp/enforce_mpp_test.go
Replaced require.Eventually with assert.Eventually capturing actual plan for each iteration; added conditional failure with diagnostic output including cascades value, SQL statement, expected plan, and actual plan.
Planner Testdata Updates
pkg/planner/core/casetest/binaryplan/testdata/*, pkg/planner/core/casetest/cbotest/testdata/*, pkg/planner/core/casetest/hint/testdata/*, pkg/planner/core/casetest/mpp/testdata/*, pkg/planner/core/casetest/rule/testdata/*, pkg/planner/core/casetest/tpcds/testdata/*, pkg/planner/core/casetest/testdata/*
Updated JSON plan expectations across multiple test suites; changes include node identifier shifts, predicate reordering (e.g., gt/lt precedence changes), removal of redundant warning messages, and structural plan reorganization (projection placement, exchange node reordering, join tree reshaping).
Integration Test Results
tests/integrationtest/r/planner/core/*, tests/integrationtest/r/select.result, tests/integrationtest/r/tpch.result, tests/integrationtest/r/join_reorder2.result, tests/integrationtest/r/plan_cache.result
Updated explain plan outputs reflecting new join ordering strategy: HashJoin topology changes, table scan reordering, join predicate restructuring, predicate pushdown adjustments, and Build/Probe side reassignments across complex multi-join scenarios.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

ok-to-test

Suggested reviewers

  • qw4990
  • terry1purcell

Poem

🐰 The planner hops with joy today,
Conditions align along the way,
Join orders bloom in schema's light,
Outer joins reorder left and right!
With testify's assert, we diagnose,
No more failpoints—the session knows! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description lacks critical required information including a proper issue link, detailed problem statement, and explanation of changes. Add a proper issue link (close #66088), provide a detailed problem summary explaining why the cd-c algorithm is being enabled by default, and explain what changed and how it works in detail.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly identifies the main change: enabling the cd-c algorithm by default for join reorder in the planner. This is the primary objective of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

Migrating from UI to YAML configuration.

Use the @coderabbitai configuration command in a PR comment to get a dump of all your UI settings in YAML format. You can then edit this YAML file and upload it to the root of your repository to configure CodeRabbit programmatically.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
pkg/planner/core/rule_join_reorder.go (2)

295-300: Remove stale failpoint placeholder block.

The commented failpoint block is dead code and now just adds confusion around the active control path.

🧹 Proposed cleanup
-	// failpoint.Inject("enableCDCJoinReorder", func(val failpoint.Value) {
-	// 	if val.(bool) {
-	// 		p2, err := joinorder.Optimize(p)
-	// 		failpoint.Return(p2, false, err)
-	// 	}
-	// })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/planner/core/rule_join_reorder.go` around lines 295 - 300, Remove the
stale commented failpoint block that references
failpoint.Inject("enableCDCJoinReorder") and the inner call to
joinorder.Optimize(p) (variables p and p2); simply delete the entire
commented-out block so the active control flow is not obscured by dead code, and
ensure no other references to enableCDCJoinReorder remain in this scope.

291-303: Please attach targeted planner test evidence for this optimizer-path switch.

Given this changes join reorder dispatch logic, include the exact planner and integration test commands/results in the PR thread before merge.

As per coding guidelines pkg/planner/**: Run targeted planner unit tests (go test -run <TestName> -tags=intest,deadlock) and update rule testdata when needed for changes to planner rules or logical/physical plans.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/planner/core/rule_join_reorder.go` around lines 291 - 303, Add targeted
planner unit and integration tests that exercise both branches of the join
reorder dispatch (when p.SCtx().GetSessionVars().EnableOuterJoinReorder is true
and false) so CI and reviewers can see exact planner outputs; create/modify
tests (e.g., in a new or existing pkg/planner/*_test.go such as
rule_join_reorder_test.go) that invoke the planner on representative queries and
assert or capture the produced logical/physical plans for the Optimize and
optimizeRecursive paths, update any rule testdata expected outputs under
pkg/planner/testdata as needed, and run the commands to produce evidence: go
test -run <TestName> -tags=intest,deadlock (and the relevant unit test runs)
then paste the exact command lines and their outputs (planner and integration
results) into the PR thread for review.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/planner/core/rule_join_reorder.go`:
- Around line 295-300: Remove the stale commented failpoint block that
references failpoint.Inject("enableCDCJoinReorder") and the inner call to
joinorder.Optimize(p) (variables p and p2); simply delete the entire
commented-out block so the active control flow is not obscured by dead code, and
ensure no other references to enableCDCJoinReorder remain in this scope.
- Around line 291-303: Add targeted planner unit and integration tests that
exercise both branches of the join reorder dispatch (when
p.SCtx().GetSessionVars().EnableOuterJoinReorder is true and false) so CI and
reviewers can see exact planner outputs; create/modify tests (e.g., in a new or
existing pkg/planner/*_test.go such as rule_join_reorder_test.go) that invoke
the planner on representative queries and assert or capture the produced
logical/physical plans for the Optimize and optimizeRecursive paths, update any
rule testdata expected outputs under pkg/planner/testdata as needed, and run the
commands to produce evidence: go test -run <TestName> -tags=intest,deadlock (and
the relevant unit test runs) then paste the exact command lines and their
outputs (planner and integration results) into the PR thread for review.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 255b3fb and 631165e.

📒 Files selected for processing (26)
  • pkg/planner/core/casetest/binaryplan/testdata/binary_plan_suite_out.json
  • pkg/planner/core/casetest/binaryplan/testdata/binary_plan_suite_xut.json
  • pkg/planner/core/casetest/cbotest/testdata/analyze_suite_out.json
  • pkg/planner/core/casetest/cbotest/testdata/analyze_suite_xut.json
  • pkg/planner/core/casetest/enforcempp/BUILD.bazel
  • pkg/planner/core/casetest/enforcempp/enforce_mpp_test.go
  • pkg/planner/core/casetest/hint/testdata/integration_suite_out.json
  • pkg/planner/core/casetest/hint/testdata/integration_suite_xut.json
  • pkg/planner/core/casetest/mpp/testdata/integration_suite_out.json
  • pkg/planner/core/casetest/mpp/testdata/integration_suite_xut.json
  • pkg/planner/core/casetest/rule/rule_outer2inner_test.go
  • pkg/planner/core/casetest/rule/testdata/join_reorder_suite_out.json
  • pkg/planner/core/casetest/rule/testdata/outer2inner_out.json
  • pkg/planner/core/casetest/rule/testdata/outer2inner_xut.json
  • pkg/planner/core/casetest/testdata/json_plan_suite_out.json
  • pkg/planner/core/casetest/testdata/json_plan_suite_xut.json
  • pkg/planner/core/casetest/tpcds/testdata/tpcds_suite_out.json
  • pkg/planner/core/casetest/tpcds/testdata/tpcds_suite_xut.json
  • pkg/planner/core/rule_join_reorder.go
  • tests/integrationtest/r/planner/core/casetest/index/index.result
  • tests/integrationtest/r/planner/core/casetest/rule/rule_join_reorder.result
  • tests/integrationtest/r/planner/core/issuetest/planner_issue.result
  • tests/integrationtest/r/planner/core/join_reorder2.result
  • tests/integrationtest/r/planner/core/plan_cache.result
  • tests/integrationtest/r/planner/core/rule_join_reorder.result
  • tests/integrationtest/r/select.result

Signed-off-by: guo-shaoge <shaoge1994@163.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/integrationtest/r/tpch.result`:
- Line 447: The EXPLAIN predicate printer is dropping relation/alias qualifiers,
producing unsatisfiable text like eq(tpch50.nation.n_name, "JAPAN") for joined
instances; update the predicate/expr formatter (e.g., the function that formats
scalar expressions / column references used by the HashJoin explain path) to
include the per-source alias or qualifier (the join input alias such as n1/n2)
when rendering ColumnRef nodes so the predicate shows eq(n1.n_name, "JAPAN") and
eq(n2.n_name, "INDIA"); locate the formatter used by HashJoin explain output and
change it to prefer the relation alias (or join alias) over the fully qualified
catalog.table name when an alias is present.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 631165e and 0364655.

📒 Files selected for processing (1)
  • tests/integrationtest/r/tpch.result

Comment thread tests/integrationtest/r/tpch.result
Signed-off-by: guo-shaoge <shaoge1994@163.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 83.96226% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.1128%. Comparing base (b6af20e) to head (7e6c4a2).
⚠️ Report is 75 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #66349        +/-   ##
================================================
+ Coverage   77.6965%   78.1128%   +0.4162%     
================================================
  Files          2012       1942        -70     
  Lines        550857     538480     -12377     
================================================
- Hits         427997     420622      -7375     
+ Misses       121144     117414      -3730     
+ Partials       1716        444      -1272     
Flag Coverage Δ
integration 43.5942% <77.3584%> (-4.5617%) ⬇️
unit 76.4889% <83.9622%> (+0.2226%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 56.7974% <ø> (ø)
parser ∅ <ø> (∅)
br 48.8781% <ø> (-12.0358%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: guo-shaoge <shaoge1994@163.com>
@pantheon-ai
Copy link
Copy Markdown

pantheon-ai Bot commented Mar 3, 2026

Review Complete

Findings: 0 issues
Posted: 0
Duplicates/Skipped: 0

ℹ️ Learn more details on Pantheon AI.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/planner/core/joinorder/conflict_detector.go`:
- Around line 785-802: The cloned ScalarFunction's cached hash becomes stale
after you mutate its arguments in the block handling *expression.ScalarFunction
(where you call e.Clone(), assign newFunc.GetArgs()[i] = newArgs[i] after
alignExprNotNullWithSchema), so update the code to invalidate/recompute the hash
cache: after the mutation loop call expression.ReHashCode(newFunc) (or rebuild
the function via expression.NewFunctionInternal(...) instead of mutating the
clone) so the canonicalhashcode reflects the new arguments.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0364655 and 0b357bc.

📒 Files selected for processing (5)
  • pkg/planner/core/casetest/rule/testdata/outer_to_semi_join_suite_out.json
  • pkg/planner/core/casetest/rule/testdata/outer_to_semi_join_suite_xut.json
  • pkg/planner/core/casetest/tpch/testdata/tpch_suite_out.json
  • pkg/planner/core/casetest/tpch/testdata/tpch_suite_xut.json
  • pkg/planner/core/joinorder/conflict_detector.go

Comment thread pkg/planner/core/joinorder/conflict_detector.go Outdated
Signed-off-by: guo-shaoge <shaoge1994@163.com>
Signed-off-by: guo-shaoge <shaoge1994@163.com>
Signed-off-by: guo-shaoge <shaoge1994@163.com>
Signed-off-by: guo-shaoge <shaoge1994@163.com>
Signed-off-by: guo-shaoge <shaoge1994@163.com>
@guo-shaoge
Copy link
Copy Markdown
Collaborator Author

/retest

1 similar comment
@guo-shaoge
Copy link
Copy Markdown
Collaborator Author

/retest

@guo-shaoge guo-shaoge removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 13, 2026
@guo-shaoge
Copy link
Copy Markdown
Collaborator Author

/unhold

Signed-off-by: guo-shaoge <shaoge1994@163.com>
@guo-shaoge
Copy link
Copy Markdown
Collaborator Author

/retest

1 similar comment
@guo-shaoge
Copy link
Copy Markdown
Collaborator Author

/retest

@ti-chi-bot ti-chi-bot Bot merged commit 20b231f into pingcap:master Mar 13, 2026
33 checks passed
Comment on lines -447 to -455
└─HashJoin root inner join, equal:[eq(tpch50.orders.o_custkey, tpch50.customer.c_custkey) eq(tpch50.nation.n_nationkey, tpch50.customer.c_nationkey)]
├─TableReader(Build) root data:TableFullScan
│ └─TableFullScan cop[tikv] table:customer keep order:false
└─HashJoin(Probe) root inner join, equal:[eq(tpch50.lineitem.l_orderkey, tpch50.orders.o_orderkey)]
└─HashJoin root inner join, equal:[eq(tpch50.customer.c_nationkey, tpch50.nation.n_nationkey)], other cond:or(and(eq(tpch50.nation.n_name, "JAPAN"), eq(tpch50.nation.n_name, "INDIA")), and(eq(tpch50.nation.n_name, "INDIA"), eq(tpch50.nation.n_name, "JAPAN")))
├─TableReader(Build) root data:Selection
│ └─Selection cop[tikv] or(eq(tpch50.nation.n_name, "INDIA"), eq(tpch50.nation.n_name, "JAPAN"))
│ └─TableFullScan cop[tikv] table:n2 keep order:false
└─HashJoin(Probe) root inner join, equal:[eq(tpch50.orders.o_custkey, tpch50.customer.c_custkey)]
├─TableReader(Build) root data:TableFullScan
│ └─TableFullScan cop[tikv] table:orders keep order:false
└─HashJoin(Probe) root inner join, equal:[eq(tpch50.supplier.s_suppkey, tpch50.lineitem.l_suppkey)]
├─HashJoin(Build) root inner join, equal:[eq(tpch50.nation.n_nationkey, tpch50.supplier.s_nationkey)]
│ ├─HashJoin(Build) root CARTESIAN inner join, other cond:or(and(eq(tpch50.nation.n_name, "JAPAN"), eq(tpch50.nation.n_name, "INDIA")), and(eq(tpch50.nation.n_name, "INDIA"), eq(tpch50.nation.n_name, "JAPAN")))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is an unexpected change.

@ti-chi-bot
Copy link
Copy Markdown
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #67289.
But this PR has conflicts, please resolve them!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

planner: incorrect join reorder for outer-join

6 participants