• unknown's avatar
    MWL#89 · 15da3d8b
    unknown authored
    Fixed LP BUG#714808 Assertion `outer_lookup_keys <= outer_record_count'
    
    Analysis:
    
    The function best_access_path() computes the number or records as
    follows:
    
    ...
          if (rec < MATCHING_ROWS_IN_OTHER_TABLE)
            rec= MATCHING_ROWS_IN_OTHER_TABLE; // Fix for small tables
    ...
                  if (table->quick_keys.is_set(key))
                    records= (double) table->quick_rows[key];
                  else
                  {
                    /* quick_range couldn't use key! */
                    records= (double) s->records/rec;
                  }
    
    Above MATCHING_ROWS_IN_OTHER_TABLE == 10, and s->records == 1,
    thus we get an estimated 0.1 records. As a result JOIN::get_partial_join_cost()
    for the outer query computes outer_record_count == 0.1 records, which is
    meaningless in this context.
    
    Solution:
    Round row count estimates that are < 1 to 1.
    15da3d8b
subselect_mat_cost.test 10.5 KB