← Back to team overview

maria-developers team mailing list archive

Re: Likely a dead optimizer related code

 

Hi!

> Hi Igor,
>
> I noticed that during Item_cond::fix_fields() and
> Item_func_between::fix_fields() update these optimizer
> related SELECT_LEX members:
>
> thd->lex->current_select->cond_count and
> thd->lex->current_select->between_count
>
> The purpose of these members is to allocate optimizer related buffers
> in:
> - update_ref_and_keys() in sql_select.cc and
> - check_func_dependency() in opt_table_elimination,cc
> and it seems they have no any other purposes..

Correct.

>  From my understanding, this is a dead code and the collected values are
> never used:
>
> - cond_count and_between_count are later always initialized to 0
> before the walk(count_sargable_conds) call in update_ref_and_keys().

And the call to check_func_dependency() is done after this call.

> - moreover, using the values collected during fix_fields() would not be
> correct to allocate optimized related buffers, because the code
> in fix_fields() does not distinguish between different query parts,
> so the items can be just a part of the SELECT list rather than a
> part of WHERE/HAVING/ON.

This would note be a problem as the count was supposed to be an upper bound.
As it's not normal that you have many IF or BETWEEN in the SELECT
part, this was not a problem.

I looked at the patch and it's ok to commit.

Regards,
Monty


Follow ups

References