From 730eb1c4be84b7f06dc8d4a894536941cbe5da63 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Sat, 14 May 2022 20:19:05 +0300 Subject: Code cleanup in/around check_interleaving_with_nj() - In best_extension_by_limited_search(), do not check for "(remaining_tables & real_table_bit)", it is guaranteed to be true. Make it an assert. - In (!idx || check_interleaving_with_nj())", remove the !idx part. This check made sense only in the original version of this function. - "micro optimization" in check_interleaving_with_nj(). --- sql/sql_select.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6d8d389b81d..ee834f5d806 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8962,10 +8962,11 @@ best_extension_by_limited_search(JOIN *join, for (JOIN_TAB **pos= join->best_ref + idx ; (s= *pos) ; pos++) { table_map real_table_bit= s->table->map; - if ((remaining_tables & real_table_bit) && - (allowed_tables & real_table_bit) && + DBUG_ASSERT(remaining_tables & real_table_bit); + + if ((allowed_tables & real_table_bit) && !(remaining_tables & s->dependent) && - (!idx || !check_interleaving_with_nj(s))) + !check_interleaving_with_nj(s)) { double current_record_count, current_read_time; POSITION *position= join->positions + idx; @@ -16076,7 +16077,6 @@ static uint reset_nj_counters(JOIN *join, List *join_list) static bool check_interleaving_with_nj(JOIN_TAB *next_tab) { - TABLE_LIST *next_emb= next_tab->table->pos_in_table_list->embedding; JOIN *join= next_tab->join; if (join->cur_embedding_map & ~next_tab->embedding_map) @@ -16088,6 +16088,7 @@ static bool check_interleaving_with_nj(JOIN_TAB *next_tab) return TRUE; } + TABLE_LIST *next_emb= next_tab->table->pos_in_table_list->embedding; /* Do update counters for "pairs of brackets" that we've left (marked as X,Y,Z in the above picture) -- cgit v1.2.1