Move horizon planning to operators#11622
Conversation
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
… operators Signed-off-by: Andres Taylor <andres@planetscale.com>
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.
nit: we can also change the comment Clone -> clone
Signed-off-by: Andres Taylor <andres@planetscale.com>
c74cf88 to
079bc33
Compare
| } | ||
| func planSingleShardRoute(statement sqlparser.SelectStatement, rb *Route, horizon *Horizon) (Operator, error) { |
| "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.
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.
Looking at the operator test data, it feels like it encapsulates each node in the tree.
There was a problem hiding this comment.
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.
I'll add info about horizons in the op tree as well
frouioui
left a comment
There was a problem hiding this comment.
LGTM, can't approve as this is my PR.
|
We should update the Pull Request description. |
GuptaManan100
left a comment
There was a problem hiding this comment.
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&WHEREclauses.A horizon is what we call in the planner the stuff that is outside the
FROM ... WHEREclause. 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