summaryrefslogtreecommitdiff
path: root/sql/filesort_utils.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2022-06-30 14:02:53 +0300
committerSergei Petrunia <sergey@mariadb.com>2023-02-02 23:08:23 +0300
commit013ba37ae23040ca804c1ac2c293cab4ccb5731e (patch)
treea2d50f7da82e20b67631efc71ba57b1353c39b67 /sql/filesort_utils.cc
parent59193ef67361354e8a5702ade8ce69d8b0ffe014 (diff)
downloadmariadb-git-013ba37ae23040ca804c1ac2c293cab4ccb5731e.tar.gz
Fix cost calculation in test_if_cheaper_ordering() to be cost based
The original code was mostly rule based and preferred clustered or covering indexed independent of cost. There where a few test changes: - Some test changed from using filesort to index or table scan. This happened when most of the rows had to be sorted and the ORDER BY could use covering or a clustered index (innodb_mysql, create_spatial_index). - Some test changed range to filesort. This where mainly because the range was scanning most of the rows or using index scan + row lookup and filesort with table scan is cheaper. (order_by). - Change in join_cache was because sorting 2 rows is faster than retrieving 10 rows. - In selectivity_innodb.test one test changed to use a cheaper index.
Diffstat (limited to 'sql/filesort_utils.cc')
-rw-r--r--sql/filesort_utils.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/filesort_utils.cc b/sql/filesort_utils.cc
index 4a75817add4..854033cc8d8 100644
--- a/sql/filesort_utils.cc
+++ b/sql/filesort_utils.cc
@@ -28,7 +28,8 @@ const LEX_CSTRING filesort_names[]=
{ STRING_WITH_LEN("priority_queue with addon fields")},
{ STRING_WITH_LEN("priority_queue with row lookup")},
{ STRING_WITH_LEN("merge_sort with addon fields")},
- { STRING_WITH_LEN("merge_sort with row lookup)")}
+ { STRING_WITH_LEN("merge_sort with row lookup)")},
+ { STRING_WITH_LEN("Error while computing filesort cost")}
};
/*
@@ -447,7 +448,7 @@ double cost_of_filesort(TABLE *table, ORDER *order_by, ha_rows rows_to_read,
for (ORDER *ptr= order_by; ptr ; ptr= ptr->next)
{
Item_field *field= (Item_field*) (*ptr->item)->real_item();
- size_t length= get_sort_length(table->in_use, field);
+ size_t length= get_sort_length(thd, field);
set_if_smaller(length, thd->variables.max_sort_length);
sort_len+= (uint) length;
}