• Monty's avatar
    Adjust costs for doing index scan in cost_group_min_max() · 6fa74517
    Monty authored
    The idea is that when doing a tree dive (once per group), we need to
    compare key values, which is fast.  For each new group, we have to
    compare the full where clause for the row.
    Compared to original code, the cost of group_min_max() has slightly
    increased which affects some test with only a few rows.
    main.group_min_max and main.distinct have been modified to show the
    effect of the change.
    
    The patch also adjust the number of groups in case of quick selects:
    - For simple WHERE clauses, ensure that we have at least as many groups
      as we have conditions on the used group-by key parts.
      The assumption is that each condition will create at least one group.
    - Ensure that there are no more groups than rows found by quick_select
    
    Test changes:
    - For some small tables there has been a change of
      Using index for group-by -> Using index for group-by (scanning)
      Range -> Index and Using index for group-by -> Using index
    6fa74517
group_by.test 69.9 KB