-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: refactor the implementation of cost calculation #33945
Labels
Comments
This was referenced Apr 14, 2022
12 tasks
espresso98
pushed a commit
to espresso98/tidb
that referenced
this issue
Apr 25, 2022
… IndexLookup, Proj and Sel (pingcap#34091) ref pingcap#33945
ti-chi-bot
pushed a commit
that referenced
this issue
Apr 26, 2022
12 tasks
This was referenced Apr 27, 2022
ti-chi-bot
pushed a commit
that referenced
this issue
Apr 28, 2022
ti-chi-bot
pushed a commit
that referenced
this issue
Apr 29, 2022
12 tasks
espresso98
pushed a commit
to espresso98/tidb
that referenced
this issue
Apr 29, 2022
12 tasks
ti-chi-bot
pushed a commit
that referenced
this issue
May 5, 2022
12 tasks
ti-chi-bot
pushed a commit
that referenced
this issue
May 6, 2022
12 tasks
ti-chi-bot
pushed a commit
that referenced
this issue
May 6, 2022
12 tasks
ti-chi-bot
pushed a commit
that referenced
this issue
May 7, 2022
This was referenced May 9, 2022
ti-chi-bot
pushed a commit
that referenced
this issue
May 10, 2022
ti-chi-bot
pushed a commit
that referenced
this issue
May 10, 2022
This was referenced May 11, 2022
ti-chi-bot
pushed a commit
that referenced
this issue
May 12, 2022
12 tasks
ti-chi-bot
pushed a commit
that referenced
this issue
May 16, 2022
ti-chi-bot
pushed a commit
that referenced
this issue
May 16, 2022
12 tasks
ti-chi-bot
pushed a commit
that referenced
this issue
Jun 6, 2022
12 tasks
Merged
12 tasks
qw4990
added a commit
to qw4990/tidb
that referenced
this issue
Jul 12, 2022
… cost model factors (pingcap#35226) ref pingcap#33945
qw4990
added a commit
to qw4990/tidb
that referenced
this issue
Jul 12, 2022
qw4990
added a commit
to qw4990/tidb
that referenced
this issue
Jul 12, 2022
… in `DataSource.findBestTask` (pingcap#35221) ref pingcap#33945
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Enhancement
The current implementation of cost calculation is tightly coupled with physical optimization.
In physical optimization, the optimizer changes the plan structure frequently and updates the current cost correspondingly.
Here is an example:
addPushedDownSelection
is used to pushselection
down, and commentsCOST
andPHY-OPT
are used to represent the corresponding line is forcost calculation
orplan change in physical optimization
, and then you can see they are coupled tightly.The current implementation is hard to maintain and has already caused lots of issues: #32675 #32672 #32698 #27189 #30103 #32362.
To solve this problem thoroughly, we decided to refactor the implementation of cost calculation.
A new interface
Plan.CalCost() float64
will be introduced and all code related to cost calculation will be removed from physical optimization, and then you can see the example above become like this:And all code related to cost calculation will be moved into the new and standard interface
Plan.CalCost() float64
.Below is an example of
IndexReader
:After this refactoring, the cost model will become easier to maintain and calibrate.
And the cost of a plan becomes re-computable, which means you can invoke
Plan.CalCost()
multiple times in varied places, and I think some other modules like (PlanCache
,SPM
,PlanRewriter
,JoinReorder
, ...) can also get some benefits from it.Here is a detailed design doc(Chinese) about this.
Here is the demo.
The text was updated successfully, but these errors were encountered: