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: convert cartesian semi join with other nulleq condition to cross semi join with equal condition #58075

Merged
merged 2 commits into from
Dec 16, 2024

Conversation

hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented Dec 9, 2024

What problem does this PR solve?

Issue Number: close #57583
Problem Summary:

What changed and how does it work?

when to convert the equal condition, We only consider the equality condition. but nulleq is considered,too.

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.

convert cartesian semi join with other nulleq condition to cross semi join with equal condition

将具有 nulleq 条件的cartesian semi join  转换为具有相等条件的 semi join 

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-tests-checked 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. sig/planner SIG: Planner and removed do-not-merge/needs-tests-checked labels Dec 9, 2024
@hawkingrei hawkingrei force-pushed the 57583 branch 3 times, most recently from 6a05f0c to 51eac5b Compare December 13, 2024 07:48
@hawkingrei
Copy link
Member Author

/test all

@hawkingrei
Copy link
Member Author

/retest

2 similar comments
@hawkingrei
Copy link
Member Author

/retest

@hawkingrei
Copy link
Member Author

/retest

Copy link

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.0601%. Comparing base (cea46f1) to head (8d112ff).
Report is 281 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #58075        +/-   ##
================================================
+ Coverage   73.2259%   75.0601%   +1.8341%     
================================================
  Files          1675       1724        +49     
  Lines        462254     470664      +8410     
================================================
+ Hits         338490     353281     +14791     
+ Misses       102989      95249      -7740     
- Partials      20775      22134      +1359     
Flag Coverage Δ
integration 49.0847% <100.0000%> (?)
unit 72.4491% <100.0000%> (+0.0784%) ⬆️

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

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 61.6605% <ø> (+15.6224%) ⬆️

@hawkingrei
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Dec 16, 2024
@hawkingrei hawkingrei changed the title planner: convert hash semi join with nulleq condition to cross semi join with other condition planner: convert cartesian semi join with other nulleq condition to cross semi join with equal condition Dec 16, 2024
@hawkingrei
Copy link
Member Author

/check-issue-triage-complete

@hawkingrei hawkingrei force-pushed the 57583 branch 2 times, most recently from db4789a to 28233bb Compare December 16, 2024 03:36
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 16, 2024
@AilinKid
Copy link
Contributor

AilinKid commented Dec 16, 2024

can you explain why the original positive case normally work even without this fix

mysql> explain select id from t1 intersect select id from t1;
+------------------------------+----------+-----------+---------------+-------------------------------------------------------------+
| id                           | estRows  | task      | access object | operator info                                               |
+------------------------------+----------+-----------+---------------+-------------------------------------------------------------+
| HashJoin_7                   | 6400.00  | root      |               | semi join, equal:[nulleq(test.t1.id, test.t1.id)]           |
| ├─TableReader_18(Build)      | 10000.00 | root      |               | data:TableFullScan_17                                       |
| │ └─TableFullScan_17         | 10000.00 | cop[tikv] | table:t1      | keep order:false, stats:pseudo                              |
| └─HashAgg_12(Probe)          | 8000.00  | root      |               | group by:test.t1.id, funcs:firstrow(test.t1.id)->test.t1.id |
|   └─TableReader_13           | 8000.00  | root      |               | data:HashAgg_8                                              |
|     └─HashAgg_8              | 8000.00  | cop[tikv] |               | group by:test.t1.id,                                        |
|       └─TableFullScan_11     | 10000.00 | cop[tikv] | table:t1      | keep order:false, stats:pseudo                              |
+------------------------------+----------+-----------+---------------+-------------------------------------------------------------+

Signed-off-by: Weizhen Wang <[email protected]>
@hawkingrei
Copy link
Member Author

/retest

@hawkingrei
Copy link
Member Author

explain select id from t1 intersect select id from t1;

it is in this code. In fact, it cannot deduce the elements that can be PredicatePushDown, so the modification point is not triggered.

image

@hawkingrei
Copy link
Member Author

hawkingrei commented Dec 16, 2024

can you explain why the original positive case normally work even without this fix

mysql> explain select id from t1 intersect select id from t1;
+------------------------------+----------+-----------+---------------+-------------------------------------------------------------+
| id                           | estRows  | task      | access object | operator info                                               |
+------------------------------+----------+-----------+---------------+-------------------------------------------------------------+
| HashJoin_7                   | 6400.00  | root      |               | semi join, equal:[nulleq(test.t1.id, test.t1.id)]           |
| ├─TableReader_18(Build)      | 10000.00 | root      |               | data:TableFullScan_17                                       |
| │ └─TableFullScan_17         | 10000.00 | cop[tikv] | table:t1      | keep order:false, stats:pseudo                              |
| └─HashAgg_12(Probe)          | 8000.00  | root      |               | group by:test.t1.id, funcs:firstrow(test.t1.id)->test.t1.id |
|   └─TableReader_13           | 8000.00  | root      |               | data:HashAgg_8                                              |
|     └─HashAgg_8              | 8000.00  | cop[tikv] |               | group by:test.t1.id,                                        |
|       └─TableFullScan_11     | 10000.00 | cop[tikv] | table:t1      | keep order:false, stats:pseudo                              |
+------------------------------+----------+-----------+---------------+-------------------------------------------------------------+

In fact, it skipes the PredicatePushDown rules when to build logical plan.

Copy link

ti-chi-bot bot commented Dec 16, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, 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 added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 16, 2024
Copy link

ti-chi-bot bot commented Dec 16, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-12-16 04:21:40.990116531 +0000 UTC m=+844291.078919059: ☑️ agreed by AilinKid.
  • 2024-12-16 09:46:24.534096184 +0000 UTC m=+863774.622898726: ☑️ agreed by winoros.

@ti-chi-bot ti-chi-bot bot merged commit f744959 into pingcap:master Dec 16, 2024
24 checks passed
@hawkingrei
Copy link
Member Author

/cherrypick release-8.5

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Dec 25, 2024
@ti-chi-bot
Copy link
Member

@hawkingrei: new pull request created to branch release-8.5: #58521.

In response to this:

/cherrypick release-8.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.

hawkingrei added a commit to ti-chi-bot/tidb that referenced this pull request Dec 31, 2024
ti-chi-bot bot pushed a commit that referenced this pull request Jan 1, 2025
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. label Jan 24, 2025
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jan 24, 2025
@ti-chi-bot ti-chi-bot bot removed the needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimizer convert hash semi join with nulleq condition to cross semi join with other condition
4 participants