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 the issue that the optimizer cannot convert OUTER JOIN to INNER JOIN with nested AND/OR in some cases #49625

Merged
merged 3 commits into from
Dec 20, 2023

Conversation

qw4990
Copy link
Contributor

@qw4990 qw4990 commented Dec 20, 2023

What problem does this PR solve?

Issue Number: close #49616

Problem Summary: planner: fix the issue that the optimizer cannot convert OUTER JOIN to INNER JOIN with nested AND/OR in some cases

What changed and how does it work?

planner: fix the issue that the optimizer cannot convert OUTER JOIN to INNER JOIN with nested AND/OR in some cases

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

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 20, 2023
Copy link

codecov bot commented Dec 20, 2023

Codecov Report

Merging #49625 (9fa9fa8) into master (da460f1) will increase coverage by 0.4438%.
Report is 6 commits behind head on master.
The diff coverage is 80.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #49625        +/-   ##
================================================
+ Coverage   70.9801%   71.4239%   +0.4438%     
================================================
  Files          1368       1423        +55     
  Lines        398761     417055     +18294     
================================================
+ Hits         283041     297877     +14836     
- Misses        95945     100360      +4415     
+ Partials      19775      18818       -957     
Flag Coverage Δ
integration 43.7185% <80.0000%> (?)
unit 70.9801% <ø> (ø)

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

Components Coverage Δ
dumpling 53.9663% <ø> (ø)
parser ∅ <ø> (∅)
br 47.3574% <ø> (-5.5252%) ⬇️

Comment on lines 1632 to 1637
tk.MustExec(`use test`)
tk.MustExec(`create table t1 (k int, a int)`)
tk.MustExec(`create table t2 (k int, b int, key(k))`)
tk.MustHavePlan(`select /*+ tidb_inlj(t2, t1) */ *
from t2 left join t1 on t1.k=t2.k
where a>0 or (a=0 and b>0)`, `IndexJoin`)
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to move this test into pkg/planner/core/issuetest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

qw4990 and others added 2 commits December 20, 2023 19:45
Co-authored-by: Zhou Kunqin <25057648+time-and-fate@users.noreply.github.com>
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 20, 2023
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 20, 2023
Copy link

ti-chi-bot bot commented Dec 20, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-12-20 12:08:36.479091609 +0000 UTC m=+1049207.516318538: ☑️ agreed by time-and-fate.
  • 2023-12-20 14:18:00.529267882 +0000 UTC m=+1056971.566494808: ☑️ agreed by winoros.

Copy link

ti-chi-bot bot commented Dec 20, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, time-and-fate, 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:
  • OWNERS [AilinKid,time-and-fate,winoros]

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 00e52ad into pingcap:master Dec 20, 2023
@qw4990
Copy link
Contributor Author

qw4990 commented Dec 21, 2023

/cherry-pick release-6.5
/cherry-pick release-7.1
/cherry-pick release-7.5

@ti-chi-bot
Copy link
Member

@qw4990: new pull request created to branch release-6.5: #49638.

In response to this:

/cherry-pick release-6.5
/cherry-pick release-7.1
/cherry-pick release-7.5

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 ti-community-infra/tichi repository.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Dec 21, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

@qw4990: new pull request created to branch release-7.1: #49639.

In response to this:

/cherry-pick release-6.5
/cherry-pick release-7.1
/cherry-pick release-7.5

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 ti-community-infra/tichi repository.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Dec 21, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

@qw4990: new pull request created to branch release-7.5: #49640.

In response to this:

/cherry-pick release-6.5
/cherry-pick release-7.1
/cherry-pick release-7.5

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 ti-community-infra/tichi repository.

Copy link
Contributor

@ghazalfamilyusa ghazalfamilyusa left a comment

Choose a reason for hiding this comment

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

@qw4990 : The general solution to null filtering condition NFC is simple and wondering why we need to limit to this special case.
NFC (A and B) = NFC(A) OR NFC(B)
NFC (A OR B) = NFC(A) AND NFC(B)
We do have NFC logic for primitive conditions and should be easy to do this general fix.

ti-chi-bot bot pushed a commit that referenced this pull request Feb 18, 2024
…o INNER JOIN with nested AND/OR in some cases (#49625) (#49640)

close #49616
ti-chi-bot bot pushed a commit that referenced this pull request Feb 27, 2024
…o INNER JOIN with nested AND/OR in some cases (#49625) (#49639)

close #49616
@qw4990 qw4990 added the type/bugfix This PR fixes a bug. label Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. 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.

planner: the optimizer cannot convert OUTER JOIN to INNER JOIN with nested AND/OR predicates in some cases
7 participants