Skip to content
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

planner: fix join reorder will append remained other condition to an outer join #44409

Merged

Conversation

AilinKid
Copy link
Contributor

@AilinKid AilinKid commented Jun 5, 2023

What problem does this PR solve?

Issue Number: close #44314

Problem Summary:

What is changed and how it works?

As mentioned in the last comment on the issue

Reason: outer join's other condition influence is quite different from inner join's other condition, the latter one functions as a simple filter, just integrated with inner join. The former functions as a simple filter but also decides whether the outer join is matched or not, consequently deciding whether appending an additional null (which means this row itself is not pruned in the final result)

So when enumerating join order when encountering inner join combined with outer join, those original other conditions bonded with an outer join, just let it be; those additional remained other conditions shouldn't be put down into it, adding additional selection above is a resolution.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

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.

planner: fix join reorder will append remained condition to an outer join

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jun 5, 2023
@ti-chi-bot ti-chi-bot bot requested review from SeaRise and tangwz June 5, 2023 08:53
@ti-chi-bot ti-chi-bot bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 5, 2023
@AilinKid AilinKid changed the title planner: fix join reorder will append remained condition to an outer join planner: fix join reorder will append remained other condition to an outer join Jun 5, 2023
@ti-chi-bot ti-chi-bot bot added needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. and removed do-not-merge/needs-triage-completed labels Jun 5, 2023
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jun 5, 2023
AilinKid added 6 commits June 5, 2023 17:43
Signed-off-by: AilinKid <[email protected]>
Signed-off-by: AilinKid <[email protected]>
Signed-off-by: AilinKid <[email protected]>
Signed-off-by: AilinKid <[email protected]>
Signed-off-by: AilinKid <[email protected]>
@@ -507,6 +507,13 @@ func (s *baseSingleGroupJoinOrderSolver) makeJoin(leftPlan, rightPlan LogicalPla
remainOtherConds, otherConds = expression.FilterOutInPlace(remainOtherConds, func(expr expression.Expression) bool {
return expression.ExprFromSchema(expr, mergedSchema)
})
if (joinType.JoinType == LeftOuterJoin || joinType.JoinType == RightOuterJoin || joinType.JoinType == LeftOuterSemiJoin || joinType.JoinType == AntiLeftOuterSemiJoin) && len(otherConds) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about fullOuter?

Copy link
Contributor Author

@AilinKid AilinKid Jun 5, 2023

Choose a reason for hiding this comment

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

no full outer join type internally

Signed-off-by: AilinKid <[email protected]>
@AilinKid AilinKid force-pushed the fix-outer-join-append-other-cond branch from be5a9c5 to 2b80079 Compare June 5, 2023 10:01
Copy link
Contributor

@elsa0520 elsa0520 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 5, 2023

@elsa0520: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

LGTM

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/test-infra repository.

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 5, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 5, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-06-05 09:11:57.782914431 +0000 UTC m=+253104.055887213: ☑️ agreed by winoros.
  • 2023-06-05 11:12:37.20244188 +0000 UTC m=+260343.475414663: ☑️ agreed by chrysan.

@elsa0520
Copy link
Contributor

elsa0520 commented Jun 5, 2023

/lgtm

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 5, 2023

@elsa0520: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

/lgtm

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/test-infra repository.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 5, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrysan, elsa0520, winoros

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot merged commit 0cd5372 into pingcap:master Jun 5, 2023
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #44423.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #44424.

ti-chi-bot bot pushed a commit that referenced this pull request Jun 6, 2023
ti-chi-bot bot pushed a commit that referenced this pull request Jul 12, 2023
winoros added a commit to winoros/tidb that referenced this pull request Jul 25, 2023
@winoros winoros added the type/bugfix This PR fixes a bug. label Jul 25, 2023
ti-chi-bot bot pushed a commit that referenced this pull request Jul 26, 2023
ti-chi-bot bot pushed a commit that referenced this pull request Aug 16, 2023
ti-chi-bot bot pushed a commit that referenced this pull request Oct 12, 2023
ti-chi-bot bot pushed a commit that referenced this pull request May 7, 2024
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-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Temporary incorrect query results occur after create table.
5 participants