Closed adofsauron closed 1 year ago
"query_block": {
"select_id": 1,
"cost_info": {
"query_cost": "337.15"
},
"nested_loop": [
{
"table": {
"table_name": "a",
"access_type": "ALL",
"rows_examined_per_scan": 1016,
"rows_produced_per_join": 20,
"filtered": "2.00",
"pushed_condition": "((mbs
.a
.DELETED_FLAG
= '0') and (mbs
.a
.ACCT_FLAG
in ('2','4')))(t0) Pckrows: 1, susp. 1 (0 empty 0 full). Conditions: 2",
"cost_info": {
"read_cost": "259.94",
"eval_cost": "4.06",
"prefix_cost": "264.00",
"data_read_per_join": "314K"
},
"used_columns": [
"COMPANY_ID",
"BANK_ID",
"BANK_NAME",
"HBANK_CODE",
"HBANK_NAME",
"ACCT_FLAG",
"DELETED_FLAG"
]
}
},
{
"table": {
"table_name": "t1",
"access_type": "ALL",
"possible_keys": [
"PRIMARY",
"IDX_MDCOMPANY1"
],
"rows_examined_per_scan": 9,
"rows_produced_per_join": 20,
"filtered": "11.11",
"using_join_buffer": "Block Nested Loop",
"cost_info": {
"read_cost": "20.32",
"eval_cost": "4.06",
"prefix_cost": "288.38",
"data_read_per_join": "155K"
},
"used_columns": [
"ROW_ID",
"TENANT_ID"
],
"attached_condition": "(mbs
.t1
.ROW_ID
= mbs
.a
.COMPANY_ID
)"
}
},
{
"table": {
"table_name": "t2",
"access_type": "ALL",
"possible_keys": [
"IDX_MDCOMPANY1"
],
"rows_examined_per_scan": 9,
"rows_produced_per_join": 20,
"filtered": "22.22",
"first_match": "t1",
"using_join_buffer": "Block Nested Loop",
"cost_info": {
"read_cost": "40.64",
"eval_cost": "4.06",
"prefix_cost": "337.15",
"data_read_per_join": "155K"
},
"used_columns": [
"TENANT_ID"
],
"attached_condition": "(mbs
.t2
.TENANT_ID
= mbs
.t1
.TENANT_ID
)"
}
}
]
}
} |
"nested_loop": [ { "table": { "table_name": "t1", "access_type": "index", "possible_keys": [ "PRIMARY", "IDX_MDCOMPANY1" ], "key": "IDX_MDCOMPANY1", "used_key_parts": [ "TENANT_ID", "COMPANY_NAME" ], "key_length": "1210", "rows_examined_per_scan": 9, "rows_produced_per_join": 9, "filtered": "100.00", "using_index": true, "cost_info": { "read_cost": "1.00", "eval_cost": "1.80", "prefix_cost": "2.80", "data_read_per_join": "68K" }, "used_columns": [ "ROW_ID", "TENANT_ID" ] } },
EXISTS does not care about the selected expressions, only about the existence of rows.
If UNION, we have to modify the SELECT list of each SELECT in the UNION, fortunately this function is indeed called for each SELECT_LEX.
If this is a prepared statement, we must allow the next execution to use materialization. So, we should back up the original SELECT list. If this is a UNION, this means backing up the N original SELECT lists. To avoid this constraint, we change the SELECT list only if this is not a prepared statement.
$6 = {
semi join is wrong. Shut this stupid thing down
Although the semi join results are all wrong now, the bug list can not be closed, we must track when it is completely solved
Optimize each of the semi-join nests that can be run with
materialization. For each of the nests, we
- Generate the best join order for this "sub-join" and remember it;
- Remember the sub-join execution cost (it's part of materialization
cost);
- Calculate other costs that will be incurred if we decide
to use materialization strategy for this semi-join nest.
/// Optimal join order calculated for inner tables of this semijoin op. POSITION *positions{nullptr}; /// True if data types allow the MaterializeLookup semijoin strategy bool lookup_allowed{false}; /// True if data types allow the MaterializeScan semijoin strategy bool scan_allowed{false}; /// Expected number of rows in the materialized table double expected_rowcount{0.0}; /// Materialization cost - execute sub-join and write rows to temp.table Cost_estimate materialization_cost; /// Cost to make one lookup in the temptable Cost_estimate lookup_cost; /// Cost of scanning the materialized table Cost_estimate scan_cost; /// Array of pointers to fields in the
| -> Hash semijoin (d.d1 = c.c1) (cost=1.27 rows=3) -> Table scan on c (cost=0.55 rows=3) -> Hash -> Table scan on d (cost=0.12 rows=3)
"from": "IN (SELECT)",
"to": "semijoin",
"chosen": true,
"transformation_to_semi_join": {
"subquery_predicate": "`c`.`c1` in (/* select#2 */ select `d`.`d1` from `d` where (`c`.`c1` = `d`.`d1`))",
"embedded in": "WHERE",
"evaluating_constant_semijoin_conditions": [
],
"semi-join condition": "((`c`.`c1` = `d`.`d1`) and (`c`.`c1` = `d`.`d1`))",
"decorrelated_predicates": [
{
"outer": "`c`.`c1`",
"inner": "`d`.`d1`"
},
{
"outer": "`c`.`c1`",
"inner": "`d`.`d1`"
}
opt: strategy: "DuplicatesWeedout"
emb_join_list->push_front(sj_nest);
Have you read the Contributing Guidelines on issues?
Please confirm if bug report does NOT exists already ?
Describe the problem
No response
Expected behavior
No response
How To Reproduce
No response
Environment
No response
Are you interested in submitting a PR to solve the problem?