• Sergei Petrunia's avatar
    MDEV-34993: Incorrect cardinality estimation causes poor query plan · 8166a5d3
    Sergei Petrunia authored
    When calculate_cond_selectivity_for_table() takes into account multi-
    column selectivities from range access, it tries to take-into account
    that selectivity for some columns may have been already taken into account.
    
    For example, for range access on IDX1 using {kp1, kp2}, the selectivity
    of restrictions on "kp2" might have already been taken into account
    to some extent.
    So, the code tries to "discount" that using rec_per_key[] estimates.
    
    This seems to be wrong and unreliable: the "discounting" may produce a
    rselectivity_multiplier number that hints that the overall selectivity
    of range access on IDX1 was greater than 1.
    
    Do a conservative fix: if we arrive at conclusion that selectivity of
    range access on condition in IDX1 >1.0, clip it down to 1.
    8166a5d3
selectivity_innodb_notembedded.test 514 Bytes