-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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/core: simple greedy join reorder based on CBO #8394
Conversation
TPCH Need some investigation on Q17 and Q18. |
What's the results of star benchmark? |
@ngaut TiDB haven't tested SSB yet. It will takes some time to do it. |
Update for TPCH Q17: New order is You cannot say that the new order(don't care about the actual operator node below) is worse than before. This can be optimized i think. But will leave it for future pr to do. |
The problem here is we haven't consider the physical cost of the join order, only the number of rows of the intermediate result are considered in this greedy algorithm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
) | ||
|
||
func extractInnerJoinGroup(p *LogicalJoin) ([]LogicalPlan, []*expression.ScalarFunction, []expression.Expression) { | ||
if p.reordered || p.preferJoinType > uint(0) || p.JoinType != InnerJoin || p.StraightJoin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why stop extracting inner join groups when p.preferJoinType > uint(0)
? IMHO, It's only a hint about join algorithm, not the join order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emm, we can do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Could you please update code to remove this check in this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, when do join reorder, we create new join node. And when creating it. We missed the join hint information. We need to change the way we hold it before we remove this check.
/run-all-tests tidb-test=pr/548 |
/run-all-tests |
) | ||
|
||
func extractInnerJoinGroup(p *LogicalJoin) ([]LogicalPlan, []*expression.ScalarFunction, []expression.Expression) { | ||
if p.reordered || p.preferJoinType > uint(0) || p.JoinType != InnerJoin || p.StraightJoin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Could you please update code to remove this check in this function?
…tidb into join-reorder-cbo-greedy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
/run-integration-common-test |
What problem does this PR solve?
Let the default join reorder by greedy use CBO.
What is changed and how it works?
Removed old one, add the new greedy algo.
Check List
Tests
Side effects
No
Related changes
This change is