mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Rewrite cost computation for filesort operations
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
This commit is contained in:
committed by
Sergei Petrunia
parent
06be2c64bc
commit
50e9f7aee5
@@ -541,11 +541,22 @@ to be fixed later
|
||||
|
||||
class Sort_param {
|
||||
public:
|
||||
uint rec_length; // Length of sorted records.
|
||||
uint sort_length; // Length of sorted columns.
|
||||
// Length of sorted records. ALWAYS equal to sort_length + addon_length
|
||||
uint rec_length;
|
||||
/*
|
||||
Length of what we need to sort: Sorted columns + ref_length if not
|
||||
addon fields are used
|
||||
*/
|
||||
uint sort_length;
|
||||
/* Length of the reference to the row (rowid or primary key etc */
|
||||
uint ref_length; // Length of record ref.
|
||||
/* Length of all addon fields. 0 if no addon fields */
|
||||
uint addon_length; // Length of addon_fields
|
||||
uint res_length; // Length of records in final sorted file/buffer.
|
||||
/*
|
||||
The length of the 'result' we are going to return to the caller for
|
||||
each sort element. Also the length of data in final sorted file/buffer.
|
||||
*/
|
||||
uint res_length;
|
||||
uint max_keys_per_buffer; // Max keys / buffer.
|
||||
uint min_dupl_count;
|
||||
ha_rows limit_rows; // Select limit, or HA_POS_ERROR if unlimited.
|
||||
|
Reference in New Issue
Block a user