• Monty's avatar
    Selectivity: apply found_constraint heuristic only to post-join #rows. · 5e5988db
    Monty authored
    matching_candidates_in_table() computes the number of rows one
    gets from the current table after applying the WHERE clause on
    just this table
    
    The function had a "found_counstraint heuristic" which reduced the
    number of rows after WHERE check by 25% if there were comparisons
    between key parts in table T and previous tables, like WHERE
    T.keyXpartY= func(prev_table.cols)
    
    Note that such comparisons can only be checked when the row of
    table T is joined with rows of the previous tables. It is wrong
    to apply the selectivity before the join operation.
    
    Fixed by moving the 'found_constraint' code to a separate function
    and only reducing the #rows in 'records_out'.
    
    Renamed matching_candidates_in_table() to apply_selectivity_for_table() as
    the function now either applies selectivity on the rows (depending
    on the value of thd->variables.optimizer_use_condition_selectivity)
    or uses the selectivity from the available range conditions.
    5e5988db
opt_trace.result 481 KB