• Varun Gupta's avatar
    MDEV-20519: Query plan regression with optimizer_use_condition_selectivity > 1 · b1ab2ba5
    Varun Gupta authored
    The issue here is the wrong estimate of the cardinality of a partial join,
    the cardinality is too high because the function table_cond_selectivity()
    returns an absurd number 100 while selectivity cannot be greater than 1.
    
    When accessing table t by outer reference t1.a via index we do not perform any
    range analysis for t. Yet we see TABLE::quick_key_parts[key] and
    TABLE->quick_rows[key] contain a non-zero value though these should have been
    remained untouched and equal to 0.
    
    Thus real cause of the problem is that TABLE::init does not clean the arrays
    TABLE::quick_key_parts[] and TABLE::>quick_rows[].
    It should have done it because the TABLE structure created for any
    instance of a table can be reused for many queries.
    b1ab2ba5
selectivity_innodb.result 98.1 KB