Skip to content
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

Gen4: Even more fixes #8904

Merged
merged 8 commits into from
Sep 30, 2021
Merged

Gen4: Even more fixes #8904

merged 8 commits into from
Sep 30, 2021

Conversation

systay
Copy link
Collaborator

@systay systay commented Sep 29, 2021

Description

More gen4 small fixes

  • Grouping on top of PulloutSubqueries
  • UNION between SELECT * queries
  • Compact joins - after creating the operator tree, there might have opened up new opportunities to merge QueryGraphs
  • Merge UNIONs more aggressively - when it's a UNION DISTINCT, we can reorder the SELECTs to see if there are more chances to merge routes together

Related Issue(s)

#7280

Checklist

  • Tests were added or are not required
  • Documentation was added or is not required

@systay systay changed the title Allows planning grouping on top of PulloutSubqueries Gen4Even more fixes Sep 29, 2021
@systay systay changed the title Gen4Even more fixes Gen4: Even more fixes Sep 29, 2021
@systay systay added Component: Query Serving Type: Enhancement Logical improvement (somewhere between a bug and feature) labels Sep 29, 2021
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>
…tble join planning

Signed-off-by: Andres Taylor <andres@planetscale.com>
Now that all the queries are either planned correctly or failing with
the expected error (Gen4NotSupported), we could simplify plan_test a lot

Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
@systay systay marked this pull request as ready for review September 30, 2021 13:51
Copy link
Member

@frouioui frouioui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me 🚀

Comment on lines +137 to +144
func orderedStringIntMap(in map[string]int) orderedMap {
result := make(orderedMap, 0, len(in))
for k, v := range in {
result = append(result, keyVal{key: k, val: v})
}
sort.Sort(result)
return result
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is great

Comment on lines +119 to +121
}
func (qg *QueryGraph) addJoinPredicates(ts semantics.TableSet, expr sqlparser.Expr) {
for _, join := range qg.innerJoins {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add an extra new line between 119 and 120

var checkAllTests = false
func testFile(t *testing.T, filename, tempDir string, vschema *vschemaWrapper) {
t.Run(filename, func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is really great

Comment on lines +1656 to +1691
{
"QueryType": "SELECT",
"Original": "select col from unsharded union select id from user union select col2 from unsharded union select col from user_extra",
"Instructions": {
"OperatorType": "Distinct",
"Inputs": [
{
"OperatorType": "Concatenate",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "SelectUnsharded",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"FieldQuery": "select col from unsharded where 1 != 1 union select col2 from unsharded where 1 != 1",
"Query": "select col from unsharded union select col2 from unsharded",
"Table": "unsharded"
},
{
"OperatorType": "Route",
"Variant": "SelectScatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select id from `user` where 1 != 1 union select col from user_extra where 1 != 1",
"Query": "select id from `user` union select col from user_extra",
"Table": "`user`"
}
]
}
]
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for better plans!

@systay systay merged commit 59031fd into vitessio:main Sep 30, 2021
@systay systay deleted the gen4-more-fixes branch September 30, 2021 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Query Serving Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants