summaryrefslogtreecommitdiff
path: root/sql/filesort.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/filesort.cc')
-rw-r--r--sql/filesort.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 70926d7d449..40db6e0070a 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -2199,7 +2199,11 @@ sortlength(THD *thd, Sort_keys *sort_keys, bool *allow_packing_for_sortkeys)
length=0;
uint nullable_cols=0;
- sort_keys->reset_parameters();
+ if (!sort_keys->is_first_execution())
+ {
+ *allow_packing_for_sortkeys= sort_keys->using_packed_sortkeys();
+ return sort_keys->get_sort_length_with_memcmp_values();
+ }
for (SORT_FIELD *sortorder= sort_keys->begin();
sortorder != sort_keys->end();
@@ -2262,6 +2266,8 @@ sortlength(THD *thd, Sort_keys *sort_keys, bool *allow_packing_for_sortkeys)
// add bytes for nullable_cols
sort_keys->increment_original_sort_length(nullable_cols);
*allow_packing_for_sortkeys= allow_packing_for_keys;
+ sort_keys->set_sort_length_with_memcmp_values(length + nullable_cols);
+ sort_keys->set_first_execution(false);
DBUG_PRINT("info",("sort_length: %d",length));
return length + nullable_cols;
}
@@ -2520,7 +2526,7 @@ void Sort_param::try_to_pack_sortkeys()
return;
const uint sz= Sort_keys::size_of_length_field;
- uint sort_len= sort_keys->get_sort_length();
+ uint sort_len= sort_keys->get_sort_length_with_original_values();
/*
Heuristic introduced, skip packing sort keys if saving less than 128 bytes