Skip to content

Commit 6dd5417

Browse files
author
Kristofer Pettersson
committed
Bug#21299665 INORDERNATE MEMORY USAGE QUERYING I_S.COLUMNS
Some queries using the INFORMATION_SCHEMA can consume excessive amount of memory because of a suboptimal query plan and lack of proper materialization. This patch applies a temporary mem_root on during the JOIN-execution phase when the I_S tables are materialized as temporary tables.
1 parent cccf865 commit 6dd5417

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

sql/sql_show.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3683,14 +3683,15 @@ make_table_name_list(THD *thd, List<LEX_STRING> *table_names, LEX *lex,
36833683
@retval TRUE - Failure.
36843684
*/
36853685
static bool
3686-
fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
3686+
fill_schema_table_by_open(THD *thd, MEM_ROOT *mem_root,
3687+
bool is_show_fields_or_keys,
36873688
TABLE *table, ST_SCHEMA_TABLE *schema_table,
36883689
LEX_STRING *orig_db_name,
36893690
LEX_STRING *orig_table_name,
36903691
Open_tables_backup *open_tables_state_backup,
36913692
bool can_deadlock)
36923693
{
3693-
Query_arena i_s_arena(thd->mem_root,
3694+
Query_arena i_s_arena(mem_root,
36943695
Query_arena::STMT_CONVENTIONAL_EXECUTION),
36953696
backup_arena, *old_arena;
36963697
LEX *old_lex= thd->lex, temp_lex, *lex;
@@ -4390,7 +4391,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, Item *cond)
43904391
table_name.str= const_cast<char*>(lsel->table_list.first->table_name);
43914392
table_name.length= lsel->table_list.first->table_name_length;
43924393

4393-
error= fill_schema_table_by_open(thd, TRUE,
4394+
error= fill_schema_table_by_open(thd, &tmp_mem_root, TRUE,
43944395
table, schema_table,
43954396
&db_name, &table_name,
43964397
&open_tables_state_backup,
@@ -4532,7 +4533,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, Item *cond)
45324533

45334534
DEBUG_SYNC(thd, "before_open_in_get_all_tables");
45344535

4535-
if (fill_schema_table_by_open(thd, FALSE,
4536+
if (fill_schema_table_by_open(thd, &tmp_mem_root, FALSE,
45364537
table, schema_table,
45374538
db_name, table_name,
45384539
&open_tables_state_backup,

0 commit comments

Comments
 (0)