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, executor: add post-process after physical plan optimization and move buildProjBelowAgg from executor to planner #8828

Merged
merged 5 commits into from Jan 3, 2019

Conversation

qw4990
Copy link
Contributor

@qw4990 qw4990 commented Dec 26, 2018

What problem does this PR solve?

Add a post process function after DoOptimize() in package "planner/core". (#8713)
In this post process, we can:

  1. eliminate physical projection eliminatePhysicalProjection;
  2. build projection operator below aggregation operator;

So after this code change, the plan in explain xx is equals to explain analyze xx, and the plan generation is back to the "planner" package.

Hope this can make the code more readable and maintainable.

What is changed and how it works?

  1. add a postOptimize() after DoOptimize() at planner/core/optimizer.go;
  2. move buildProjBelowAgg() from executor/builder.go to planner/core/optimizer.go;
  3. update some unit tests;

Check List

Tests

  • Unit test
  • Integration test

This change is Reviewable

@CLAassistant
Copy link

CLAassistant commented Dec 26, 2018

CLA assistant check
All committers have signed the CLA.

@qw4990 qw4990 added sig/planner SIG: Planner sig/execution SIG execution labels Dec 26, 2018
planner/core/optimizer.go Outdated Show resolved Hide resolved
@XuHuaiyu XuHuaiyu added type/enhancement sig/execution SIG execution and removed sig/execution SIG execution labels Dec 26, 2018
@XuHuaiyu
Copy link
Contributor

/run-all-tests

@qw4990 qw4990 changed the title planner, executor: add post-process after physical plan optimazation … planner, executor: add post-process after physical plan optimazation and move buildProjBelowAgg from executor to planner Dec 26, 2018
planner/core/optimizer.go Outdated Show resolved Hide resolved
planner/core/optimizer.go Outdated Show resolved Hide resolved
planner/core/optimizer.go Outdated Show resolved Hide resolved
planner/core/optimizer.go Outdated Show resolved Hide resolved
planner/core/optimizer.go Outdated Show resolved Hide resolved
planner/core/optimizer.go Outdated Show resolved Hide resolved
@XuHuaiyu XuHuaiyu changed the title planner, executor: add post-process after physical plan optimazation and move buildProjBelowAgg from executor to planner planner, executor: add post-process after physical plan optimization and move buildProjBelowAgg from executor to planner Dec 28, 2018
qw4990 added a commit to qw4990/tidb that referenced this pull request Dec 28, 2018
…and move buildProjBelowAgg from executor to planner (pingcap#8828)
planner/core/optimizer.go Outdated Show resolved Hide resolved
qw4990 added a commit to qw4990/tidb that referenced this pull request Dec 28, 2018
…and move buildProjBelowAgg from executor to planner (pingcap#8828)
qw4990 added a commit to qw4990/tidb that referenced this pull request Dec 28, 2018
…and move buildProjBelowAgg from executor to planner (pingcap#8828)
…and move buildProjBelowAgg from executor to planner
…and move buildProjBelowAgg from executor to planner (pingcap#8828)
…and move buildProjBelowAgg from executor to planner (pingcap#8828)
…and move buildProjBelowAgg from executor to planner (pingcap#8828)
Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

@XuHuaiyu XuHuaiyu added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 3, 2019
Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@zz-jason zz-jason added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 3, 2019
@zz-jason
Copy link
Member

zz-jason commented Jan 3, 2019

/run-all-tests

@qw4990 qw4990 merged commit 243120c into pingcap:master Jan 3, 2019
@qw4990 qw4990 added this to Done in Planner via automation Jan 3, 2019
planner/core/cbo_test.go Show resolved Hide resolved

// If the mode is FinalMode, we do not need to wrap cast upon the args,
// since the types of the args are already the expected.
if len(aggFuncs) > 0 && aggFuncs[0].Mode != aggregation.FinalMode {
Copy link
Contributor

Choose a reason for hiding this comment

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

if the mode is Partial2Mode, we don't need the cast either? @XuHuaiyu @qw4990

Copy link
Contributor

Choose a reason for hiding this comment

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

@eurekaka Seems you're right.

Copy link
Contributor Author

@qw4990 qw4990 Feb 15, 2019

Choose a reason for hiding this comment

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

Should I push another PR to fix these two problems? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

}

child := aggPlan.Children()[0]
prop := aggPlan.GetChildReqProps(0).Clone()
Copy link
Contributor

Choose a reason for hiding this comment

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

prop would not be used anymore since we have finished physical optimization, so we can just set it nil?

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks so

XuHuaiyu pushed a commit to XuHuaiyu/tidb that referenced this pull request Feb 15, 2019
…and move buildProjBelowAgg from executor to planner (pingcap#8828)
zz-jason pushed a commit that referenced this pull request Feb 15, 2019
…and move buildProjBelowAgg from executor to planner (#8828) (#9314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/planner SIG: Planner status/LGT2 Indicates that a PR has LGTM 2. type/enhancement
Projects
No open projects
Planner
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

6 participants