Implementation of the following optimization of the queries that use non-mergiable views and/or derived tables.
The conditions in the WHERE clause of such a query that depend only on the columns of non-mergiable view/derived
tables are pushed into the query defining this view/derived table.
In the general case conditions can be pushed only in the HAVING clause of the non-mergiable view/derived tables,
but at some conditions it makes sence to push them into the WHERE clause.
-building item clones;
Methods: virtual build_clone, virtual get_copy.
-pushing conditions into HAVING;
Mark subformulas of a condition unusable for the condition pushed into table.
Build condition extractable from the given one depended only on this table.
-pushing conditions into WHERE;
For a condition check possibility of exraction a formula over grouping fields.
Build condition extractable from the given one.
-pushing conditions into embedded derived tables;
-using equalities to extract pushable conditions;
-implementation of the case when derived table with UNION is used;
-comments to each new method;
The code is ready to be merged into MariaDB 10.2.
Here is the list of commits on github:
And here is the commit with the consolidated patch: