-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Move horizon planning to operators #11622
Conversation
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Andres Taylor <[email protected]>
… operators Signed-off-by: Andres Taylor <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
If a new flag is being introduced:
If a workflow is added or modified:
Bug fixes
Non-trivial changes
New/Existing features
Backward compatibility
|
// Clone implements the Operator interface | ||
func (a *ApplyJoin) Clone(inputs []Operator) Operator { | ||
func (a *ApplyJoin) clone(inputs []Operator) Operator { |
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.
nit: we can also change the comment Clone
-> clone
Signed-off-by: Andres Taylor <[email protected]>
c74cf88
to
079bc33
Compare
} | ||
func planSingleShardRoute(statement sqlparser.SelectStatement, rb *Route, horizon *Horizon) (Operator, error) { |
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.
nit: new line :)
"vitess.io/vitess/go/vt/vtgate/planbuilder/plancontext" | ||
) | ||
|
||
// Horizon is an operator we use until we decide how to handle the source to the horizon. |
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.
I am not sure I fully understand this. We add the Horizon
operator into the tree until we have decided how the rest of the tree will do horizon planning?
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.
Looking at the operator test data, it feels like it encapsulates each node in the tree.
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.
Yes. We need to do the physical route planning before we do the horizon planning
// Package operators contains the operators used to plan queries. | ||
/* | ||
The operators go through a few phases while planning: | ||
1. Logical |
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.
That's a nice write up
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.
I'll add info about horizons in the op tree as well
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, can't approve as this is my PR.
We should update the Pull Request description. |
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.
I like the changes!
Description
A refactoring that introduces a Horizon as a logical operator.
During query planning, we start by figuring out where we are going to send the queries. This is done by inspecting the
FROM
&WHERE
clauses.A horizon is what we call in the planner the stuff that is outside the
FROM ... WHERE
clause. If we are able to send the whole query to a single shard, we don't do much more planning - we simply add the rest of the clauses (projections, ordering, limit, aggregation and more) to the query and we are done.If we can't delegate everything to MySQL, we do more planning, and this is what we call horizon planning.
This change moves the horizon into the operator tree, instead of having special handling of derived tables, unions and subqueries.
Related Issue(s)
#11626
Checklist
Deployment Notes