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: eliminate useless scalar subqueries in some scenarios of aggregate queries #47550

Merged
merged 20 commits into from
Nov 7, 2023

Conversation

King-Dylan
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #45822
Problem Summary:
For some scenarios of aggregate queries, scalar subqueries and the other functions can be eliminated

What is changed and how it works?

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/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Oct 11, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 11, 2023

Hi @King-Dylan. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@tiprow
Copy link

tiprow bot commented Oct 11, 2023

Hi @King-Dylan. 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.

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

Have you run the explain_test?

planner/core/optimizer.go Outdated Show resolved Hide resolved
planner/core/logical_plans_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@fixdb fixdb left a comment

Choose a reason for hiding this comment

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

On a second thought, can we do it in columnPruner, LogicalProjection.PruneColumns instead of creating a new rule?

planner/core/logical_plans_test.go Outdated Show resolved Hide resolved
planner/core/rule_apply_eliminate.go Outdated Show resolved Hide resolved
planner/core/rule_apply_eliminate.go Outdated Show resolved Hide resolved
planner/core/rule_apply_eliminate.go Outdated Show resolved Hide resolved
planner/core/rule_apply_eliminate.go Outdated Show resolved Hide resolved
Copy link
Contributor

@AilinKid AilinKid 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 needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Oct 25, 2023
@AilinKid
Copy link
Contributor

pls resolve the conflicts

@ti-chi-bot ti-chi-bot bot removed the needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. label Nov 6, 2023
@elsa0520
Copy link
Contributor

elsa0520 commented Nov 6, 2023

/remove-label needs-ok-to-test

Copy link

ti-chi-bot bot commented Nov 6, 2023

@elsa0520: These labels are not set on the issue: needs-ok-to-test.

In response to this:

/remove-label needs-ok-to-test

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

@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

Copy link

ti-chi-bot bot commented Nov 6, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, elsa0520

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 Nov 6, 2023
Copy link

ti-chi-bot bot commented Nov 6, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-10-25 09:24:14.596465932 +0000 UTC m=+2426652.183576077: ☑️ agreed by AilinKid.
  • 2023-11-06 09:55:09.340523703 +0000 UTC m=+3465306.927633848: ☑️ agreed by elsa0520.

Copy link

codecov bot commented Nov 6, 2023

Codecov Report

Merging #47550 (3b2927d) into master (c1e28f3) will increase coverage by 1.3121%.
Report is 27 commits behind head on master.
The diff coverage is 80.3571%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #47550        +/-   ##
================================================
+ Coverage   71.4989%   72.8110%   +1.3121%     
================================================
  Files          1402       1425        +23     
  Lines        406167     413124      +6957     
================================================
+ Hits         290405     300800     +10395     
+ Misses        95941      93398      -2543     
+ Partials      19821      18926       -895     
Flag Coverage Δ
integration 42.9567% <73.2142%> (?)
unit 71.4443% <80.3571%> (-0.0547%) ⬇️

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

Components Coverage Δ
dumpling 53.9874% <ø> (ø)
parser ∅ <ø> (∅)
br 48.6646% <ø> (-4.2610%) ⬇️

@King-Dylan
Copy link
Contributor Author

/retest

@King-Dylan
Copy link
Contributor Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 286e852 into pingcap:master Nov 7, 2023
12 of 16 checks passed
@qw4990
Copy link
Contributor

qw4990 commented May 28, 2024

/cherry-pick release-7.5

@ti-chi-bot
Copy link
Member

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

In response to this:

/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 May 28, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@qw4990 qw4990 added the needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. label Jun 6, 2024
@qw4990
Copy link
Contributor

qw4990 commented Jun 6, 2024

/cherry-pick release-6.5

@ti-chi-bot
Copy link
Member

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

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

@qw4990: new pull request could not be created: failed to create pull request against pingcap/tidb#release-6.5 from head ti-chi-bot:cherry-pick-47550-to-release-6.5: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for ti-chi-bot:cherry-pick-47550-to-release-6.5."}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#create-a-pull-request"}

In response to this:

/cherry-pick release-6.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 Jun 6, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
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. ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

For some scenarios of aggregate queries, scalar subqueries can be eliminated
7 participants