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 #50971

Closed
wants to merge 7 commits into from

Conversation

ghazalfamilyusa
Copy link
Contributor

@ghazalfamilyusa ghazalfamilyusa commented Feb 4, 2024

What problem does this PR solve?

Issue Number: Ref #51664

Problem Summary:

Index range extraction in the optimizer can handle disjunctions like
((a = 1 and b = 2 and c > 3) or (a = 4 and b = 5 and c > 6)) and builds the proper index range like "(1 2 3,1 2 +inf], (4 5 6,4 5 +inf]" for this example. The problem is that when we add another conjunct like d > 3 then the optimizer takes another path which find only the point ranges "[1,1], [4,4]" in this example. Finding point ranges is OK for complex CNF where we only pick ranges from only one conjunct, But, in this case, the best conjunct is also better than point ranges.

What changed and how does it work?

We added code that picks the best conjunct ranges if it is more selective than the point ranges. For example, "(1 2 3,1 2 +inf], (4 5 6,4 5 +inf]" is more selective than "[1,1], [4,4]" . We implemented that by checking if the best CNF ranges is a subset of the point ranges.

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 do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 4, 2024
Copy link

tiprow bot commented Feb 4, 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 marked this pull request as draft February 9, 2024 18:45
@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 9, 2024
@ghazalfamilyusa
Copy link
Contributor Author

ghazalfamilyusa commented Feb 12, 2024

/retest

@ti-chi-bot ti-chi-bot bot added the sig/planner SIG: Planner label Apr 16, 2024
@ghazalfamilyusa ghazalfamilyusa changed the title initial code for out2in rule Optimizer: Refactor and simplify outer to inner join conversion rule Apr 16, 2024
@ghazalfamilyusa ghazalfamilyusa marked this pull request as ready for review April 16, 2024 22:16
@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 16, 2024
@ghazalfamilyusa ghazalfamilyusa marked this pull request as draft April 16, 2024 22:16
@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 16, 2024
@ghazalfamilyusa ghazalfamilyusa marked this pull request as ready for review April 16, 2024 23:20
@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 16, 2024
Copy link

codecov bot commented Apr 16, 2024

Codecov Report

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

Project coverage is 73.9923%. Comparing base (9fffc2f) to head (eb2e18f).

❗ Current head eb2e18f differs from pull request most recent head 5be3e91. Consider uploading reports for the commit 5be3e91 to get more accurate results

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #50971        +/-   ##
================================================
+ Coverage   72.3417%   73.9923%   +1.6506%     
================================================
  Files          1481       1481                
  Lines        428393     428405        +12     
================================================
+ Hits         309907     316987      +7080     
+ Misses        99189      91593      -7596     
- Partials      19297      19825       +528     
Flag Coverage Δ
integration 28.0244% <85.7142%> (?)

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

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

@winoros
Copy link
Member

winoros commented Apr 18, 2024

The changes LGTM, and you can run make fmt to solve the static check issues

Copy link

ti-chi-bot bot commented Apr 21, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign qw4990, windtalker for approval, ensuring that each of them provides their approval before proceeding. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 23, 2024
@ti-chi-bot ti-chi-bot bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 24, 2024
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 25, 2024
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 26, 2024
Copy link

ti-chi-bot bot commented Apr 26, 2024

@ghazalfamilyusa: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-br-integration-test bcea3f0 link true /test pull-br-integration-test
pull-lightning-integration-test bcea3f0 link true /test pull-lightning-integration-test
idc-jenkins-ci-tidb/check_dev_2 5be3e91 link true /test check-dev2
pull-mysql-client-test 5be3e91 link true /test pull-mysql-client-test
pull-integration-ddl-test 5be3e91 link true /test pull-integration-ddl-test
idc-jenkins-ci-tidb/unit-test 5be3e91 link true /test unit-test
idc-jenkins-ci-tidb/build 5be3e91 link true /test build
idc-jenkins-ci-tidb/mysql-test 5be3e91 link true /test mysql-test
idc-jenkins-ci-tidb/check_dev 5be3e91 link true /test check-dev

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@ghazalfamilyusa
Copy link
Contributor Author

Started a new branch

@ghazalfamilyusa ghazalfamilyusa deleted the out2in branch April 30, 2024 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

3 participants