Skip to content

Instantly share code, notes, and snippets.

@spetrunia
Created June 15, 2018 13:46
Show Gist options
  • Save spetrunia/cb4a1a382a9e81a60491d524dbfc08f6 to your computer and use it in GitHub Desktop.
Save spetrunia/cb4a1a382a9e81a60491d524dbfc08f6 to your computer and use it in GitHub Desktop.
*************************** 2. row ***************************
QUERY: SELECT SUM(alias2.col_varchar_nokey) , alias2.pk AS field2 FROM t1 AS alias1
STRAIGHT_JOIN t2 AS alias2 ON alias2.pk = alias1.col_int_key WHERE alias1.pk
GROUP BY field2 ORDER BY alias1.col_int_key,alias2.pk
OPT_TRACE: {
"join_optimization": {
"select #": 1,
"steps": {
"inner": {
"select #": 1,
"steps": [
{
"condition_processing": {
"condition": "WHERE",
"original_condition": "`test`.`alias1`.`pk` <> 0 and `test`.`alias2`.`pk` = `test`.`alias1`.`col_int_key`",
"steps": [
{
"transformation": "equality_propagation",
"subselect_evaluation": [],
"resulting_condition": "`test`.`alias1`.`pk` <> 0 and multiple equal(`test`.`alias2`.`pk`, `test`.`alias1`.`col_int_key`)-??"
},
{
"transformation": "constant_propagation",
"subselect_evaluation": [],
"resulting_condition": "`test`.`alias1`.`pk` <> 0 and multiple equal(`test`.`alias2`.`pk`, `test`.`alias1`.`col_int_key`)-??"
},
{
"transformation": "trivial_condition_removal",
"subselect_evaluation": [],
"resulting_condition": "`test`.`alias1`.`pk` <> 0 and multiple equal(`test`.`alias2`.`pk`, `test`.`alias1`.`col_int_key`)-??"
}
]
}
},
{
"condition_processing": {
"condition": "WHERE",
"original_condition": "`test`.`alias1`.`pk` <> 0 and multiple equal(`test`.`alias2`.`pk`, `test`.`alias1`.`col_int_key`)-??",
"steps": [
{
"transformation": "equality_propagation",
"resulting_condition": "`test`.`alias1`.`pk` <> 0 and multiple equal(`test`.`alias2`.`pk`, `test`.`alias1`.`col_int_key`)-??"
}
]
}
},
{
"ref_optimizer_key_uses": [
{
"table": "`test`.`t2` `alias2`",
"field": "pk",
"equals": "`test`.`alias1`.`col_int_key`",
"null_rejecting": true
}
]
},
{
"rows_estimation": [
{
"table": "`test`.`t1` `alias1`",
"range_analysis": {
"table_scan": {
"rows": 20,
"cost": 7.1
}
}
},
{
"table": "`test`.`t2` `alias2`",
"range_analysis": {
"table_scan": {
"rows": 100,
"cost": 23.1
},
"potential_range_indexes": [
{
"index": "PRIMARY",
"usable": true,
"key_parts": ["pk"]
}
],
"group_index_range": {
"chosen": false,
"cause": "not_single_table"
}
}
}
]
},
{
"stage2": {
"select #": 1,
"steps": []
}
}
]
}
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment