Skip to content

Commit

Permalink
test: add more queries instead of changing queries to use hash joins
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
  • Loading branch information
systay committed Nov 17, 2021
1 parent 45ea9b2 commit c64fb98
Show file tree
Hide file tree
Showing 4 changed files with 616 additions and 66 deletions.
208 changes: 186 additions & 22 deletions go/vt/vtgate/planbuilder/testdata/filter_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,10 @@ Gen4 plan same as above
}

# Multi-route unique vindex constraint
"select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5"
"select user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5"
{
"QueryType": "SELECT",
"Original": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5",
"Original": "select user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5",
"Instructions": {
"OperatorType": "Join",
"Variant": "Join",
Expand All @@ -712,7 +712,7 @@ Gen4 plan same as above
"Sharded": true
},
"FieldQuery": "select `user`.col from `user` where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ `user`.col from `user` where `user`.id = 5",
"Query": "select `user`.col from `user` where `user`.id = 5",
"Table": "`user`",
"Values": [
5
Expand All @@ -727,20 +727,22 @@ Gen4 plan same as above
"Sharded": true
},
"FieldQuery": "select user_extra.id from user_extra where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user_extra where user_extra.col = :user_col",
"Query": "select user_extra.id from user_extra where user_extra.col = :user_col",
"Table": "user_extra"
}
]
}
}
{
"QueryType": "SELECT",
"Original": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5",
"Original": "select user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5",
"Instructions": {
"OperatorType": "Join",
"Variant": "HashJoin",
"ComparisonType": "INT16",
"JoinColumnIndexes": "2",
"Variant": "Join",
"JoinColumnIndexes": "1",
"JoinVars": {
"user_col": 0
},
"Predicate": "`user`.col = user_extra.col",
"TableName": "`user`_user_extra",
"Inputs": [
Expand All @@ -752,7 +754,7 @@ Gen4 plan same as above
"Sharded": true
},
"FieldQuery": "select `user`.col from `user` where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ `user`.col from `user` where `user`.id = 5",
"Query": "select `user`.col from `user` where `user`.id = 5",
"Table": "`user`",
"Values": [
5
Expand All @@ -766,8 +768,8 @@ Gen4 plan same as above
"Name": "user",
"Sharded": true
},
"FieldQuery": "select user_extra.col, user_extra.id from user_extra where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.col, user_extra.id from user_extra",
"FieldQuery": "select user_extra.id from user_extra where 1 != 1",
"Query": "select user_extra.id from user_extra where user_extra.col = :user_col",
"Table": "user_extra"
}
]
Expand Down Expand Up @@ -928,10 +930,10 @@ Gen4 plan same as above
}

# Multi-route with non-route constraint, should use first route.
"select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user join user_extra on user.col = user_extra.col where 1 = 1"
"select user_extra.id from user join user_extra on user.col = user_extra.col where 1 = 1"
{
"QueryType": "SELECT",
"Original": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user join user_extra on user.col = user_extra.col where 1 = 1",
"Original": "select user_extra.id from user join user_extra on user.col = user_extra.col where 1 = 1",
"Instructions": {
"OperatorType": "Join",
"Variant": "Join",
Expand All @@ -949,7 +951,7 @@ Gen4 plan same as above
"Sharded": true
},
"FieldQuery": "select `user`.col from `user` where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ `user`.col from `user` where 1 = 1",
"Query": "select `user`.col from `user` where 1 = 1",
"Table": "`user`"
},
{
Expand All @@ -960,20 +962,22 @@ Gen4 plan same as above
"Sharded": true
},
"FieldQuery": "select user_extra.id from user_extra where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user_extra where user_extra.col = :user_col",
"Query": "select user_extra.id from user_extra where user_extra.col = :user_col",
"Table": "user_extra"
}
]
}
}
{
"QueryType": "SELECT",
"Original": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user join user_extra on user.col = user_extra.col where 1 = 1",
"Original": "select user_extra.id from user join user_extra on user.col = user_extra.col where 1 = 1",
"Instructions": {
"OperatorType": "Join",
"Variant": "HashJoin",
"ComparisonType": "INT16",
"JoinColumnIndexes": "2",
"Variant": "Join",
"JoinColumnIndexes": "1",
"JoinVars": {
"user_col": 0
},
"Predicate": "`user`.col = user_extra.col",
"TableName": "`user`_user_extra",
"Inputs": [
Expand All @@ -985,7 +989,7 @@ Gen4 plan same as above
"Sharded": true
},
"FieldQuery": "select `user`.col from `user` where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ `user`.col from `user` where 1 = 1",
"Query": "select `user`.col from `user` where 1 = 1",
"Table": "`user`"
},
{
Expand All @@ -995,8 +999,8 @@ Gen4 plan same as above
"Name": "user",
"Sharded": true
},
"FieldQuery": "select user_extra.col, user_extra.id from user_extra where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.col, user_extra.id from user_extra where 1 = 1",
"FieldQuery": "select user_extra.id from user_extra where 1 != 1",
"Query": "select user_extra.id from user_extra where 1 = 1 and user_extra.col = :user_col",
"Table": "user_extra"
}
]
Expand Down Expand Up @@ -3497,3 +3501,163 @@ Gen4 plan same as above
}
}
Gen4 plan same as above

# Multi-route unique vindex constraint (with hash join)
"select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5"
{
"QueryType": "SELECT",
"Original": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5",
"Instructions": {
"OperatorType": "Join",
"Variant": "Join",
"JoinColumnIndexes": "1",
"JoinVars": {
"user_col": 0
},
"TableName": "`user`_user_extra",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "SelectEqualUnique",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select `user`.col from `user` where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ `user`.col from `user` where `user`.id = 5",
"Table": "`user`",
"Values": [
5
],
"Vindex": "user_index"
},
{
"OperatorType": "Route",
"Variant": "SelectScatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select user_extra.id from user_extra where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user_extra where user_extra.col = :user_col",
"Table": "user_extra"
}
]
}
}
{
"QueryType": "SELECT",
"Original": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5",
"Instructions": {
"OperatorType": "Join",
"Variant": "HashJoin",
"ComparisonType": "INT16",
"JoinColumnIndexes": "2",
"Predicate": "`user`.col = user_extra.col",
"TableName": "`user`_user_extra",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "SelectEqualUnique",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select `user`.col from `user` where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ `user`.col from `user` where `user`.id = 5",
"Table": "`user`",
"Values": [
5
],
"Vindex": "user_index"
},
{
"OperatorType": "Route",
"Variant": "SelectScatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select user_extra.col, user_extra.id from user_extra where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.col, user_extra.id from user_extra",
"Table": "user_extra"
}
]
}
}

# Multi-route with non-route constraint, should use first route.
"select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user join user_extra on user.col = user_extra.col where 1 = 1"
{
"QueryType": "SELECT",
"Original": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user join user_extra on user.col = user_extra.col where 1 = 1",
"Instructions": {
"OperatorType": "Join",
"Variant": "Join",
"JoinColumnIndexes": "1",
"JoinVars": {
"user_col": 0
},
"TableName": "`user`_user_extra",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "SelectScatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select `user`.col from `user` where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ `user`.col from `user` where 1 = 1",
"Table": "`user`"
},
{
"OperatorType": "Route",
"Variant": "SelectScatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select user_extra.id from user_extra where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user_extra where user_extra.col = :user_col",
"Table": "user_extra"
}
]
}
}
{
"QueryType": "SELECT",
"Original": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.id from user join user_extra on user.col = user_extra.col where 1 = 1",
"Instructions": {
"OperatorType": "Join",
"Variant": "HashJoin",
"ComparisonType": "INT16",
"JoinColumnIndexes": "2",
"Predicate": "`user`.col = user_extra.col",
"TableName": "`user`_user_extra",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "SelectScatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select `user`.col from `user` where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ `user`.col from `user` where 1 = 1",
"Table": "`user`"
},
{
"OperatorType": "Route",
"Variant": "SelectScatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select user_extra.col, user_extra.id from user_extra where 1 != 1",
"Query": "select /*vt+ ALLOW_HASH_JOIN */ user_extra.col, user_extra.id from user_extra where 1 = 1",
"Table": "user_extra"
}
]
}
}
Loading

0 comments on commit c64fb98

Please sign in to comment.