diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/opt_subselect.cc | 17 | ||||
-rw-r--r-- | sql/opt_subselect.h | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 1 | ||||
-rw-r--r-- | sql/sql_select.h | 14 |
4 files changed, 18 insertions, 16 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 794b4f9b750..ca880e8fdaa 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -2504,10 +2504,16 @@ void advance_sj_state(JOIN *join, table_map remaining_tables, uint idx, LooseScan detector in best_access_path) */ remaining_tables &= ~new_join_tab->table->map; - pos->prefix_dups_producing_tables= join->cur_dups_producing_tables; + table_map dups_producing_tables; + + if (idx == join->const_tables) + dups_producing_tables= 0; + else + dups_producing_tables= pos[-1].dups_producing_tables; + TABLE_LIST *emb_sj_nest; if ((emb_sj_nest= new_join_tab->emb_sj_nest)) - join->cur_dups_producing_tables |= emb_sj_nest->sj_inner_tables; + dups_producing_tables |= emb_sj_nest->sj_inner_tables; Semi_join_strategy_picker **strategy; if (idx == join->const_tables) @@ -2560,7 +2566,7 @@ void advance_sj_state(JOIN *join, table_map remaining_tables, uint idx, fanout from semijoin X. 3. We have no clue what to do about fanount of semi-join Y. */ - if ((join->cur_dups_producing_tables & handled_fanout) || + if ((dups_producing_tables & handled_fanout) || (read_time < *current_read_time && !(handled_fanout & pos->inner_tables_handled_with_other_sjs))) { @@ -2573,7 +2579,7 @@ void advance_sj_state(JOIN *join, table_map remaining_tables, uint idx, join->sjm_lookup_tables &= ~handled_fanout; *current_read_time= read_time; *current_record_count= rec_count; - join->cur_dups_producing_tables &= ~handled_fanout; + dups_producing_tables &= ~handled_fanout; //TODO: update bitmap of semi-joins that were handled together with // others. if (is_multiple_semi_joins(join, join->positions, idx, handled_fanout)) @@ -2600,6 +2606,7 @@ void advance_sj_state(JOIN *join, table_map remaining_tables, uint idx, pos->prefix_cost.convert_from_cost(*current_read_time); pos->prefix_record_count= *current_record_count; + pos->dups_producing_tables= dups_producing_tables; } @@ -3111,8 +3118,6 @@ void restore_prev_sj_state(const table_map remaining_tables, tab->join->cur_sj_inner_tables &= ~emb_sj_nest->sj_inner_tables; } } - POSITION *pos= tab->join->positions + idx; - tab->join->cur_dups_producing_tables= pos->prefix_dups_producing_tables; } diff --git a/sql/opt_subselect.h b/sql/opt_subselect.h index 0a74abec68b..e4d679fa377 100644 --- a/sql/opt_subselect.h +++ b/sql/opt_subselect.h @@ -298,7 +298,7 @@ public: }; -extern void advance_sj_state(JOIN *join, table_map remaining_tables, uint idx, +void advance_sj_state(JOIN *join, table_map remaining_tables, uint idx, double *current_record_count, double *current_read_time, POSITION *loose_scan_pos); void restore_prev_sj_state(const table_map remaining_tables, diff --git a/sql/sql_select.cc b/sql/sql_select.cc index dabe46ed1fe..8a53b98d812 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6143,7 +6143,6 @@ choose_plan(JOIN *join, table_map join_tables) DBUG_ENTER("choose_plan"); join->cur_embedding_map= 0; - join->cur_dups_producing_tables= 0; reset_nj_counters(join, join->join_list); qsort2_cmp jtab_sort_func; diff --git a/sql/sql_select.h b/sql/sql_select.h index ce57376a3ec..de5baeee151 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -813,7 +813,12 @@ typedef struct st_position :public Sql_alloc */ uint n_sj_tables; - table_map prefix_dups_producing_tables; + /* + Bitmap of semi-join inner tables that are in the join prefix and for + which there's no provision for how to eliminate semi-join duplicates + they produce. + */ + table_map dups_producing_tables; table_map inner_tables_handled_with_other_sjs; @@ -1034,13 +1039,6 @@ public: */ table_map cur_sj_inner_tables; - /* - Bitmap of semi-join inner tables that are in the join prefix and for - which there's no provision for how to eliminate semi-join duplicates - they produce. - */ - table_map cur_dups_producing_tables; - /* We also maintain a stack of join optimization states in * join->positions[] */ /******* Join optimization state members end *******/ |