diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
|
index e1eb65079f2..be262c6638b 100644
|
--- a/sql/opt_subselect.cc
|
+++ b/sql/opt_subselect.cc
|
@@ -519,7 +519,7 @@ bool is_materialization_applicable(THD *thd, Item_in_subselect *in_subs,
|
if (optimizer_flag(thd, OPTIMIZER_SWITCH_MATERIALIZATION) && // 0
|
!child_select->is_part_of_union() && // 1
|
parent_unit->first_select()->leaf_tables.elements && // 2
|
- child_select->outer_select()->leaf_tables.elements && // 2A
|
+ child_select->outer_select()->table_list.first && // 2A
|
subquery_types_allow_materialization(in_subs) &&
|
(in_subs->is_top_level_item() || //3
|
optimizer_flag(thd,
|