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/cascades: implement ImplementationRule for Selection #12257

Merged
merged 28 commits into from
Oct 21, 2019

Conversation

francis0407
Copy link
Member

@francis0407 francis0407 commented Sep 18, 2019

What problem does this PR solve?

  1. Introduce EngineType in cascades planner.
  2. Implement ImplementationRule for LogicalSelection in cascades planner.
  3. Move some tests of cascades integration tests to json file.

Check List

Tests

  • Integration test

@codecov
Copy link

codecov bot commented Sep 18, 2019

Codecov Report

Merging #12257 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #12257   +/-   ##
===========================================
  Coverage   80.0296%   80.0296%           
===========================================
  Files           465        465           
  Lines        106613     106613           
===========================================
  Hits          85322      85322           
  Misses        14909      14909           
  Partials       6382       6382

@francis0407
Copy link
Member Author

/rebuild

@francis0407
Copy link
Member Author

/rebuild

@sre-bot
Copy link
Contributor

sre-bot commented Sep 25, 2019

@zz-jason, @eurekaka, @winoros, PTAL.

@sre-bot
Copy link
Contributor

sre-bot commented Sep 27, 2019

@zz-jason, @eurekaka, @winoros, PTAL.

@sre-bot
Copy link
Contributor

sre-bot commented Oct 7, 2019

@zz-jason, @eurekaka, @winoros, @lzmhhh123, PTAL.

Copy link
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

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

lgtm

@francis0407 francis0407 added the status/LGT1 Indicates that a PR has LGTM 1. label Oct 15, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Oct 17, 2019

@zz-jason, @winoros, @lamxTyler, @eurekaka, @lzmhhh123, PTAL.

@francis0407
Copy link
Member Author

/run-unit-test

1 similar comment
@francis0407
Copy link
Member Author

/run-unit-test

logicalSel := expr.ExprNode.(*plannercore.LogicalSelection)
physicalSel := plannercore.PhysicalSelection{
Conditions: logicalSel.Conditions,
}.Init(logicalSel.SCtx(), expr.Group.Prop.Stats.ScaleByExpectCnt(reqProp.ExpectedCnt), logicalSel.SelectBlockOffset(), reqProp)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we make a copy of the reqProp to pass it as children properties? see #8635 for explanations.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. I just find another problem.
The Stats for init should be expr.Group.Prop.Stats instead of expr.Group.Prop.Stats.ScaleByExpectCnt(reqProp.ExpectedCnt)?

Copy link
Member Author

Choose a reason for hiding this comment

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

And reqProp.ExpectedCnt also should be scaled by the selectivity?


// CalcCost implements Implementation CalcCost interface.
func (sel *TiDBSelectionImpl) CalcCost(outCount float64, childCosts []float64, children ...*memo.Group) float64 {
sel.cost = outCount*sel.plan.SCtx().GetSessionVars().CPUFactor + childCosts[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use row count of child group here instead of outCount?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, it seems we didn't update the stats of the child group. If we scale the stats of child group by ExpectedCnt, we can use the row count of the child group then.


// CalcCost implements Implementation CalcCost interface.
func (sel *TiKVSelectionImpl) CalcCost(outCount float64, childCosts []float64, children ...*memo.Group) float64 {
sel.cost = outCount*sel.plan.SCtx().GetSessionVars().CopCPUFactor + childCosts[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

planner/memo/expr_iterator.go Outdated Show resolved Hide resolved
planner/memo/pattern.go Outdated Show resolved Hide resolved
@sre-bot
Copy link
Contributor

sre-bot commented Oct 20, 2019

@zz-jason, @winoros, @lamxTyler, @eurekaka, @lzmhhh123, PTAL.

Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

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

LGTM

@eurekaka eurekaka added the status/can-merge Indicates a PR has been approved by a committer. label Oct 21, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Oct 21, 2019

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Oct 21, 2019

/run-all-tests

@sre-bot sre-bot merged commit d0113f4 into pingcap:master Oct 21, 2019
@francis0407 francis0407 deleted the impl_selection branch October 29, 2019 02:43
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1. type/new-feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants