• Igor Babaev's avatar
    MDEV-20576 A new assertion added to check validity of calculated · deb9121f
    Igor Babaev authored
               selectivity values fails
    
    After having set the assertion that checks validity of selectivity values
    returned by the function table_cond_selectivity() a test case from
    order_by.tesst failed. The failure occurred because range optimizer could
    return as an estimate of the cardinality of the ranges built for an index
    a number exceeding the total number of records in the table.
    
    The second bug is more subtle. It may happen when there are several
    indexes with same prefix defined on the first joined table t accessed by
    a constant ref access. In this case the range optimizer estimates the
    number of accessed records of t for each usable index and these
    estimates can be different. Only the first of these estimates is taken
    into account when the selectivity of the ref access is calculated.
    However the optimizer later can choose a different index that provides
    a different estimate. The function table_condition_selectivity() could use
    this estimate to discount the selectivity of the ref access. This could
    lead to an selectivity value returned by this function that was greater
    that 1.
    deb9121f
selectivity_innodb.result 93.9 KB