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

Optimizer: Refactor and simplify outer to inner join conversion rule #52941 | tidb-test=pr/2321 #52941

Merged
merged 3 commits into from
May 16, 2024

Conversation

ghazalfamilyusa
Copy link
Contributor

@ghazalfamilyusa ghazalfamilyusa commented Apr 27, 2024

What problem does this PR solve?

Issue Number: Ref #53278

Problem Summary:
Currently, the outer to inner join rewrite is part of the predicate push down. This is causing confusion and difficulty in extending of both rewrites. Also, the current implementation of outer to inner join rewrite has unnecessary special cases.

What changed and how does it work?

A new logical optimization is added to the list of rules. Also, a simple solution of null filtering (or NF) predicate check is used.
The solution is simply:

  • NF(A AND B) = NF(A) OR NF(B)
  • NF(A OR B) = NF(A) AND NF(B)

The scope covers previous solution plus some more with the generalized solution. mysql tests has two diffs and both are OK to promote. A separate PR will be used for that.

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 do-not-merge/invalid-title release-note-none Denotes a PR that doesn't merit a release note. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. sig/planner SIG: Planner labels Apr 27, 2024
Copy link

tiprow bot commented Apr 27, 2024

Hi @ghazalfamilyusa. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

@ghazalfamilyusa ghazalfamilyusa changed the title refactor outer to inner join optimization rule Optimizer: Refactor and simplify outer to inner join conversion rule #50971 Apr 27, 2024
@ti-chi-bot ti-chi-bot bot removed do-not-merge/invalid-title needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 27, 2024
@ghazalfamilyusa ghazalfamilyusa force-pushed the outer2inner branch 2 times, most recently from a3969db to b43e840 Compare April 27, 2024 20:35
Copy link

codecov bot commented Apr 27, 2024

Codecov Report

Attention: Patch coverage is 43.62416% with 84 lines in your changes are missing coverage. Please review.

Project coverage is 73.5124%. Comparing base (acdb6f5) to head (15a2ba2).
Report is 12 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #52941        +/-   ##
================================================
+ Coverage   72.4943%   73.5124%   +1.0180%     
================================================
  Files          1493       1498         +5     
  Lines        429359     434713      +5354     
================================================
+ Hits         311261     319568      +8307     
+ Misses        98889      95083      -3806     
- Partials      19209      20062       +853     
Flag Coverage Δ
integration 24.4896% <43.6241%> (?)

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 50.1812% <ø> (+8.7242%) ⬆️

@ghazalfamilyusa ghazalfamilyusa force-pushed the outer2inner branch 2 times, most recently from 3d6981a to 6dbbc8c Compare April 27, 2024 23:03
@ghazalfamilyusa
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Apr 27, 2024

@ghazalfamilyusa: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@ghazalfamilyusa
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Apr 28, 2024

@ghazalfamilyusa: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@ghazalfamilyusa ghazalfamilyusa force-pushed the outer2inner branch 2 times, most recently from 6833fad to ecba825 Compare April 28, 2024 20:56
@ghazalfamilyusa
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Apr 28, 2024

@ghazalfamilyusa: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@ghazalfamilyusa ghazalfamilyusa marked this pull request as draft April 28, 2024 22:13
@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 Apr 28, 2024
@ghazalfamilyusa ghazalfamilyusa marked this pull request as ready for review April 29, 2024 03:27
@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 Apr 29, 2024
@ghazalfamilyusa ghazalfamilyusa force-pushed the outer2inner branch 3 times, most recently from 588bde2 to c2978ba Compare May 15, 2024 06:25
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label May 15, 2024
@@ -73,16 +73,16 @@
"Join{DataScan(t1)->DataScan(t2)}(test.t.a,test.t.b)(test.t.d,test.t.d)->Projection",
"Join{DataScan(ta)->DataScan(tb)}(test.t.d,test.t.d)->Projection",
"Join{DataScan(ta)->DataScan(tb)}(test.t.d,test.t.d)->Projection",
"Join{DataScan(ta)->DataScan(tb)}(test.t.d,test.t.d)->Sel([eq(test.t.a, 0)])->Projection",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this output changed a lot ? I saw you didn't change any case of this in.json ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change is probably of more chances to predicate push down after outer to inner join rule.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@elsa0520 : actually some tests are missing flagConvertOuterToInnerJoin whcih cause some joins not converted and different push down. Will fix the tests by adding flagConvertOuterToInnerJoin to the plan tests.

@ghazalfamilyusa ghazalfamilyusa requested a review from elsa0520 May 15, 2024 17:31
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 ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 16, 2024
Copy link

ti-chi-bot bot commented May 16, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-05-15 07:39:47.762672961 +0000 UTC m=+1638941.519808534: ☑️ agreed by qw4990.
  • 2024-05-16 03:12:09.78056395 +0000 UTC m=+1709283.537699522: ☑️ agreed by elsa0520.

@qw4990
Copy link
Contributor

qw4990 commented May 16, 2024

/retest

Copy link

tiprow bot commented May 16, 2024

@qw4990: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

Copy link

ti-chi-bot bot commented May 16, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: elsa0520, qw4990, XuHuaiyu

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 added the approved label May 16, 2024
@ti-chi-bot ti-chi-bot bot merged commit 9da001d into pingcap:master May 16, 2024
23 checks passed
@ghazalfamilyusa ghazalfamilyusa deleted the outer2inner branch May 16, 2024 15:38
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. 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.

4 participants