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

[release-17.0] fix: cost to include subshard opcode (#14023) #14027

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/operators/sharded_routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (tr *ShardedRouting) Cost() int {
switch tr.RouteOpCode {
case engine.EqualUnique:
return 1
case engine.Equal:
case engine.Equal, engine.SubShard:
return 5
case engine.IN:
return 10
Expand Down
85 changes: 85 additions & 0 deletions go/vt/vtgate/planbuilder/testdata/from_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -6448,5 +6448,90 @@
"zlookup_unique.t1"
]
}
},
{
"comment": "join query using table with muticolumn vindex",
"query": "select 1 from multicol_tbl m1 join multicol_tbl m2 on m1.cola = m2.cola",
"v3-plan": {
"QueryType": "SELECT",
"Original": "select 1 from multicol_tbl m1 join multicol_tbl m2 on m1.cola = m2.cola",
"Instructions": {
"OperatorType": "Join",
"Variant": "Join",
"JoinColumnIndexes": "L:0",
"JoinVars": {
"m1_cola": 1
},
"TableName": "multicol_tbl_multicol_tbl",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "Scatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select 1, m1.cola from multicol_tbl as m1 where 1 != 1",
"Query": "select 1, m1.cola from multicol_tbl as m1",
"Table": "multicol_tbl"
},
{
"OperatorType": "Route",
"Variant": "Scatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select 1 from multicol_tbl as m2 where 1 != 1",
"Query": "select 1 from multicol_tbl as m2 where m2.cola = :m1_cola",
"Table": "multicol_tbl"
}
]
}
},
"gen4-plan": {
"QueryType": "SELECT",
"Original": "select 1 from multicol_tbl m1 join multicol_tbl m2 on m1.cola = m2.cola",
"Instructions": {
"OperatorType": "Join",
"Variant": "Join",
"JoinColumnIndexes": "L:0",
"JoinVars": {
"m1_cola": 1
},
"TableName": "multicol_tbl_multicol_tbl",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "Scatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select 1, m1.cola from multicol_tbl as m1 where 1 != 1",
"Query": "select 1, m1.cola from multicol_tbl as m1",
"Table": "multicol_tbl"
},
{
"OperatorType": "Route",
"Variant": "SubShard",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select 1 from multicol_tbl as m2 where 1 != 1",
"Query": "select 1 from multicol_tbl as m2 where m2.cola = :m1_cola",
"Table": "multicol_tbl",
"Values": [
":m1_cola"
],
"Vindex": "multicolIdx"
}
]
},
"TablesUsed": [
"user.multicol_tbl"
]
}
}
]
Loading