• Vicențiu Ciorbaru's avatar
    Rewrite cost computation for filesort operations · 50e9f7ae
    Vicențiu Ciorbaru authored
    This is a rework of how filesort calculates costs to allow functions
    like test_if_skip_sort_order() to calculate the cost of filesort to
    decide between filesort and using a key to resolve ORDER BY.
    
    Changes:
    - Split cost calculation of qsort + optional merge sort and priority queue
      to dedicated functions.
    - Fixed some wrong calculations of cost in old code (use of log() instead
      of log2()).
    - Added costs realted to fetching the rows if addon fields are not used.
    - Updated get_merge_cost() to take into account that we are going to
      read data from temporary files in big chuncks (DISK_CHUNCK_SIZE (64K) and
      not in IO_SIZE (4K).
    - More code documentation including various variables in Sort_param.
    
    One effect of the cost update is that the cost of priority queue
    with addon field has decreased slightly and is used in more cases.
    When the rowid is large (like with InnoDB where rowid is the priority key),
    using addon fields is in many cases preferable.
    
    Reviewer: Monty
    50e9f7ae
sql_sort.h 21.8 KB