Monday, August 22, 2016

Final evaluation

Short description of the project:

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.

What's done:

-building item clones;
Methods: virtual build_clone, virtual get_copy.

-pushing conditions into HAVING;
Methods:
  1. TABLE_LIST::check_pushable_cond_for_table:
    Mark subformulas of a condition unusable for the condition pushed into table.
  2. TABLE_LIST::build_pushable_cond_for_table:
    Build condition extractable from the given one depended only on this table.

-pushing conditions into WHERE;

Methods:
  1. st_select_lex::check_cond_extraction_for_grouping_fields:
    For a condition check possibility of exraction a formula over grouping fields.
  2. st_select_lex::extract_cond_for_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;
-tests:
  derived_cond_pushdown.test;
-comments to each new method;


The code is ready to be merged into MariaDB 10.2.

Here is the list of commits on github:


https://github.com/MariaDB/server/compare/10.2...shagalla:10.2-mdev9197

And here is the commit with the consolidated patch:

https://github.com/MariaDB/server/compare/10.2...shagalla:10.2-mdev9197-cons