Øystein Grøvlen wrote:
> Roy Lyseng wrote:
>>> @@ -13473,12 +13473,14 @@ void advance_sj_state(JOIN *join, table_
>>> dups_cost += p->read_time;
>>> if (p->table->emb_sj_nest)
>>> {
>>> - sj_inner_fanout *= p->records_read;
>>> + // fanout should always be >= 1
>>> + sj_inner_fanout *= p->records_read > 1 ? p->records_read
> : 1;
>>> dups_removed_fanout |= p->table->table->map;
>>> }
>>> else
>>> {
>>> - sj_outer_fanout *= p->records_read;
>>> + // fanout should always be >= 1
>>> + sj_outer_fanout *= p->records_read > 1 ? p->records_read
> : 1;
>>> temptable_rec_size +=
> p->table->table->file->ref_length;
>>> }
>>> }
>>
>> It seems that optimize_wo_join_buffering() does not need to return
>> sj_inner_fanout. The fanout is only used outside this routine to
>> adjust the cost, and the code will be slightly simplified if this
>> routine returns the cost directly.
>
> I am a bit unsure about how to handle this. It is true that where
> optimize_wo_join_buffering is used, inner fanout is not needed by
> advance_sj_state. However, in other parts of advance_sj_state, like the
> code above, inner fanout is actually used for other purposes. Hence,
> for uniformity in how the different strategies are handled, it may make
> sense to keep the concept of inner fanout.
In that case, does it make sense to return the inner fanout and outer fanout
separately, so that you avoid the division after the call?
Thanks,
Roy