• Sergei Petrunia's avatar
    TODO-4858: Make ref(const) access reuse estimates from range if possible · 10398e57
    Sergei Petrunia authored
    (Variant 3, with @@optimizer_adjust_secondary_key_costs, reuse in two places)
    
    In best_access_path(), ReuseRangeEstimateForRef-3,  the check
    for whether
     "all used key_part_i used key_part_i=const"
    was incorrect: it may produced a "NO" answer for cases when we
    had:
     key_part1= const // some key parts are usable
     key_part2= value_not_in_join_prefix  //present but unusable
     key_part3= non_const_value // unusable due to gap in key parts.
    
    This caused the optimizer to fail to apply ReuseRangeEstimateForRef
    heuristics. The consequence is poor query plan choice when the index
    in question has very skewed data distribution.
    
    The fix is enabled if its @@optimizer_adjust_secondary_key_costs flag
    is set.
    10398e57
sql_priv.h 17.7 KB