-
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
Planner refactoring #7103
Merged
Merged
Planner refactoring #7103
Changes from 39 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
a924e24
Semantic analysis
systay 7f4c826
Added tests for query graph
GuptaManan100 ed8cfe7
Added 2nd planner test capability to plan_test
GuptaManan100 13095ef
Test New Planner
systay 91c8c95
added the first two succesful new planner tests
systay bdf65b2
checked all the tests that work with the 2nd planner
GuptaManan100 8a148e7
support more cases with the new planner
systay 09a6dac
new planner can solve the simplest join plans
systay 9691541
remove randomness from the planbuilding process
systay 713ea58
fix issue with the dp table
systay 44de903
add greedy option for large queries
systay 14f4680
refactor: extract method
systay 9224b3a
refactor: querygraph and test
systay 9aa2331
moved code to where it belongs
systay e500d3a
simplify routePlan
systay 63d4339
added route planning unit tests
systay b1a5df8
added flag to control the planner version
systay 4ecd166
added left to right planner
systay 33f5ca5
add planner benchmark
harshit-gangal 74e6d7e
Supported merging joins in selectScatter queries
GuptaManan100 4613d6c
pushed predicates to the correct place in join queries
GuptaManan100 c7aecd3
added vtgate flag and system variable to control the planner used
systay b4ac6de
added helpful comments
systay cf1ad11
add a shortcut to the greedy planner to prefer joins with predicates
systay 000426e
change planner benchmark to only read the input file once
systay 1c9c5eb
added a new version of greedy optimizer using priority queue
GuptaManan100 9c16d63
fixed join predicate collection issue
GuptaManan100 23d6535
added more supported queries
systay 57e14ca
handle null comparisons in the V4 planner
systay 4b83703
fail plan tests if the v4 planner unexpectedly produces the same plan…
systay b9fa57e
merge SelectEqualUnique plans
systay ecd4936
refactored route planning code
systay 3bafc10
Remove the assumption that A join B has the same cost as B join A
systay 2d4dd72
don't copy table qualifier and only copy some fields if the full plan…
systay ff4adae
keep tables in FROM according to original query
systay 7f3c956
Merge remote-tracking branch 'upstream/master' into horizon-planning
systay 027e154
fix lint on go/vt/srvtopo/resilient_server_test.go
shlomi-noach 01a1ef1
imports
systay 5dc6497
cleaned out code
systay d285bfe
removed planner-version sysvar
systay 26b008b
adress peer review comments
systay 35e41cd
Merge remote-tracking branch 'upstream/master' into horizon-planning
systay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
Copyright 2019 The Vitess Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package planbuilder | ||
|
||
import ( | ||
"vitess.io/vitess/go/vt/sqlparser" | ||
"vitess.io/vitess/go/vt/vtgate/engine" | ||
"vitess.io/vitess/go/vt/vtgate/semantics" | ||
) | ||
|
||
var _ logicalPlan = (*join2)(nil) | ||
|
||
// join is used to build a Join primitive. | ||
// It's used to build a normal join or a left join | ||
// operation. | ||
type join2 struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
// Left and Right are the nodes for the join. | ||
Left, Right logicalPlan | ||
Cols []int | ||
Vars map[string]int | ||
} | ||
|
||
// Order implements the logicalPlan interface | ||
func (j *join2) Order() int { | ||
panic("implement me") | ||
} | ||
|
||
// ResultColumns implements the logicalPlan interface | ||
func (j *join2) ResultColumns() []*resultColumn { | ||
panic("implement me") | ||
} | ||
|
||
// Reorder implements the logicalPlan interface | ||
func (j *join2) Reorder(i int) { | ||
panic("implement me") | ||
} | ||
|
||
// Wireup implements the logicalPlan interface | ||
func (j *join2) Wireup(lp logicalPlan, jt *jointab) error { | ||
panic("implement me") | ||
} | ||
|
||
// Wireup2 implements the logicalPlan interface | ||
func (j *join2) Wireup2(semTable *semantics.SemTable) error { | ||
err := j.Left.Wireup2(semTable) | ||
if err != nil { | ||
return err | ||
} | ||
return j.Right.Wireup2(semTable) | ||
} | ||
|
||
// SupplyVar implements the logicalPlan interface | ||
func (j *join2) SupplyVar(from, to int, col *sqlparser.ColName, varname string) { | ||
panic("implement me") | ||
} | ||
|
||
// SupplyCol implements the logicalPlan interface | ||
func (j *join2) SupplyCol(col *sqlparser.ColName) (rc *resultColumn, colNumber int) { | ||
panic("implement me") | ||
} | ||
|
||
// SupplyWeightString implements the logicalPlan interface | ||
func (j *join2) SupplyWeightString(colNumber int) (weightcolNumber int, err error) { | ||
panic("implement me") | ||
} | ||
|
||
// Primitive implements the logicalPlan interface | ||
func (j *join2) Primitive() engine.Primitive { | ||
return &engine.Join{ | ||
Left: j.Left.Primitive(), | ||
Right: j.Right.Primitive(), | ||
Cols: j.Cols, | ||
Vars: j.Vars, | ||
} | ||
} | ||
|
||
// Inputs implements the logicalPlan interface | ||
func (j *join2) Inputs() []logicalPlan { | ||
panic("implement me") | ||
} | ||
|
||
// Rewrite implements the logicalPlan interface | ||
func (j *join2) Rewrite(inputs ...logicalPlan) error { | ||
panic("implement me") | ||
} | ||
|
||
// Solves implements the logicalPlan interface | ||
func (j *join2) Solves() semantics.TableSet { | ||
return j.Left.Solves().Merge(j.Right.Solves()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we need to allow users to change planner_version at session level? If we do this than the plan cache also would be required to store this information. Allowing at vtgate startup should be good enough.
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.
Fair enough. I'll remove it. I was testing things and wanted to quickly be able to switch, but there are other ways of accomplishing this.