From 979cad229148ba8d28d94c1ca621bacd11847b66 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 21 Jun 2017 16:07:54 +0200 Subject: MDEV-9531 GROUP_CONCAT with ORDER BY inside takes a lot of memory while it's executed group concat tree is allocated in a memroot, so the only way to free memory is to copy a part of the tree into a new memroot. track the accumilated length of the result, and when it crosses the threshold - copy the result into a new tree, free the old one. --- sql/item_sum.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sql/item_sum.h') diff --git a/sql/item_sum.h b/sql/item_sum.h index dc672486bce..001d1d13fe4 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -1431,6 +1431,7 @@ class Item_func_group_concat : public Item_sum String *separator; TREE tree_base; TREE *tree; + size_t tree_len; Item **ref_pointer_array; /** @@ -1468,6 +1469,8 @@ class Item_func_group_concat : public Item_sum element_count count __attribute__((unused)), void* item_arg); + bool repack_tree(THD *thd); + public: Item_func_group_concat(THD *thd, Name_resolution_context *context_arg, bool is_distinct, List *is_select, -- cgit v1.2.1