On 08.06.11 09.23, Øystein Grøvlen wrote:
> I have one nit-pick: While I generally agree that the ? operator might make
> assignments clearer than if statements, I do not think this is particularly
>> + /*
>> + Cannot use join buffering if either
>> + 1. Join buffering is disabled by the user, or
>> + 2. Outer joined table, and join buffering disabled for outer join, or
>> + 3. Semi-joined table, and join buffering disabled for semi-join, or
>> + 4. Unlinked cache is forced and there are multiple inner tables of
>> + this outer join.
>> + */
>> + tab->use_join_cache=
>> + (thd->variables.optimizer_join_cache_level == 0 || // 1
>> + ((tab->table->map& join->outer_join)&& // 2
>> + thd->variables.optimizer_join_cache_level<= 2) || // 2
>> + (tab->emb_sj_nest != NULL&& // 3
>> + thd->variables.optimizer_join_cache_level<= 2) || // 3
>> + (force_unlinked_cache&& // 4
>> + tl->in_outer_join_nest()&& // 4
>> + tl->embedding->nested_join->join_list.elements> 1)) ? // 4
>> + JOIN_CACHE::ALG_NONE : // Indicates that join buffering cannot be used
>> + JOIN_CACHE::ALG_BNL | JOIN_CACHE::ALG_BKA | JOIN_CACHE::ALG_BKA_UNIQUE;
> When if-statements are that complex this becomes a bit difficult to read, IMHO.
I will take the liberty to be more specific about which join buffering
strategies are available. This means, in addition to the tests above:
- For JCL >= 1: Enable ALG_BNL
- For JCL = 5 or 6: Enable ALG_BKA
- For JCL = 7 or 8: Enable ALG_BKA_UNIQUE
The information will not be used except for true/false testing, but it may be
useful in later modifications to cost calculations when join buffering is involved.
> Also, I urge you to in some way document the deficiencies in the cost model that
> we discussed in relation to this bug.
I will do that to the cost model wiki page that Olav and Jørgen promised to set up.