WL#9307: Enabling merging a derived table or view through a optimizer hint

Affects: Server-8.0   —   Status: Complete

Problem
=======

In 5.6 and earlier, derived tables were always materialized. Views were merged
if technically possible.
In 5.7, we have augmented the number of cases were merging is technically
possible, both for derived tables and for views.
This can give faster queries, for example if the outer query's WHERE contains a
selective predicate which can be pushed down to the view's inner tables.

However, some queries with derived tables benefit from better
performance when the subqueries are materialized. One such possible
case is a derived table with dependent subqueries in the select list,
used as the inner table of a left outer join:
select * from t1 left join (select (subq) from t2) as dt on ...;
Such tables will always
be read as many times as there are qualifying rows in the outer table,
and the select list subqueries are evaluated for each row combination.
In 5.6 this case was materialized, in 5.7 it is merged.
Hence, applications may suffer from worse performance due to this merging - a
regression.

This was filed as
BUG#79294 QUERY WITH DOUBLE NESTED SUBQUERY MUCH SLOWER IN 5.7
and fixed in 5.7.11: the fix has disabled merging of derived tables and views
containing dependent subqueries in the SELECT list, so they are materialized,
like in 5.6.

However, implementation of SHOW commands over new data dictionary would have
faster execution if merging happened. 

Fix
===

Add a hint so that the user can force a merge;