revision-id: d0b74bbacc584e4879a29ae4277f6ce4f9145a60 (mariadb-10.4.7-67-gd0b74bbacc5) parent(s): 60c04be6599597548ad07ce11e1d7d4004a7cc9c author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2019-09-12 19:07:56 +0300 message: MDEV-20440: Optimizer trace: print more details about semi-join optimization Followup patch: fix typos --- mysql-test/main/opt_trace.result | 17 ++++++++++++----- sql/opt_subselect.cc | 8 +++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 3438714fd28..63a86615186 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -2970,7 +2970,7 @@ explain extended select * from t1 where a in (select pk from t10) { "read_time": 27.129 }, { - "chosen_strategy": "SJ-Materialize" + "chosen_strategy": "SJ-Materialization" } ], "estimated_join_cardinality": 3 @@ -4609,7 +4609,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "read_time": 18.315 }, { - "chosen_strategy": "SJ-Materialize" + "chosen_strategy": "SJ-Materialization" } ], "estimated_join_cardinality": 3 @@ -6309,7 +6309,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ] }, { - "fix_semijoin_strategies_for_picked_join_order": [] + "fix_semijoin_strategies_for_picked_join_order": [ + { + "semi_join_strategy": "DuplicateWeedout" + }, + { + "semi_join_strategy": "DuplicateWeedout" + } + ] }, { "best_join_order": [ @@ -6833,7 +6840,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "read_time": 37.226 }, { - "chosen_strategy": "SJ-Materialize" + "chosen_strategy": "SJ-Materialization" } ], "rest_of_plan": [ @@ -6935,7 +6942,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "read_time": 294.96 }, { - "chosen_strategy": "SJ-Materialize" + "chosen_strategy": "SJ-Materialization" } ], "estimated_join_cardinality": 27 diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index c4cb9b81170..f8284ac8b1a 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -2938,10 +2938,10 @@ void advance_sj_state(JOIN *join, table_map remaining_tables, uint idx, const char *sname; switch (pos->sj_strategy) { case SJ_OPT_MATERIALIZE: - sname= "SJ-Materialize"; + sname= "SJ-Materialization"; break; case SJ_OPT_MATERIALIZE_SCAN: - sname= "SJ-Materialize-Scan"; + sname= "SJ-Materialization-Scan"; break; case SJ_OPT_FIRST_MATCH: sname= "FirstMatch"; @@ -3203,7 +3203,7 @@ bool LooseScan_picker::check_qep(JOIN *join, (new_join_tab->table->map & loosescan_need_tables)) { Json_writer_object trace(join->thd); - trace.add("strategy", "SJ-Materialization-Scan"); + trace.add("strategy", "LooseScan"); /* Ok we have LooseScan plan and also have all LooseScan sj-nest's inner tables and outer correlated tables into the prefix. @@ -3899,6 +3899,8 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join) if (pos->sj_strategy == SJ_OPT_DUPS_WEEDOUT) { + Json_writer_object semijoin_strategy(thd); + semijoin_strategy.add("semi_join_strategy","DuplicateWeedout"); /* Duplicate Weedout starting at pos->first_dupsweedout_table, ending at this table.