Skip to content

Commit 730eb1c

Browse files
committed
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().
1 parent 8c28b27 commit 730eb1c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

sql/sql_select.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8962,10 +8962,11 @@ best_extension_by_limited_search(JOIN *join,
89628962
for (JOIN_TAB **pos= join->best_ref + idx ; (s= *pos) ; pos++)
89638963
{
89648964
table_map real_table_bit= s->table->map;
8965-
if ((remaining_tables & real_table_bit) &&
8966-
(allowed_tables & real_table_bit) &&
8965+
DBUG_ASSERT(remaining_tables & real_table_bit);
8966+
8967+
if ((allowed_tables & real_table_bit) &&
89678968
!(remaining_tables & s->dependent) &&
8968-
(!idx || !check_interleaving_with_nj(s)))
8969+
!check_interleaving_with_nj(s))
89698970
{
89708971
double current_record_count, current_read_time;
89718972
POSITION *position= join->positions + idx;
@@ -16076,7 +16077,6 @@ static uint reset_nj_counters(JOIN *join, List<TABLE_LIST> *join_list)
1607616077

1607716078
static bool check_interleaving_with_nj(JOIN_TAB *next_tab)
1607816079
{
16079-
TABLE_LIST *next_emb= next_tab->table->pos_in_table_list->embedding;
1608016080
JOIN *join= next_tab->join;
1608116081

1608216082
if (join->cur_embedding_map & ~next_tab->embedding_map)
@@ -16088,6 +16088,7 @@ static bool check_interleaving_with_nj(JOIN_TAB *next_tab)
1608816088
return TRUE;
1608916089
}
1609016090

16091+
TABLE_LIST *next_emb= next_tab->table->pos_in_table_list->embedding;
1609116092
/*
1609216093
Do update counters for "pairs of brackets" that we've left (marked as
1609316094
X,Y,Z in the above picture)

0 commit comments

Comments
 (0)