Databases Reference
In-Depth Information
For the purpose of optimizing Information Schema tables, we are only interested
in the conditions of the form field=constant , where field is a field in our
Information Schema table. Alternatively, other comparison operators such as <= , > ,
or BETWEEN can be used. Possibly many of these conditions can be used together in
a WHERE clause, combined with OR or AND operators. The corresponding part of the
Item hierarchy is shown in the following simplified graph (it is simplified, because
it omits seven intermediate classes—between Item and Item_field , between Item
and Item_func , and so on):
An expression in MySQL is represented as a tree of Item objects. Every class derived
from Item_func has the arguments() method that returns an array of arguments
of this function or operator. To parse the expression tree and extract constants for
early checking, which is the whole point of condition pushdown, one needs to do
something like the following:
1.
Check if COND is, in fact, an Item_cond_or or Item_cond_and instance.
2.
If yes, repeat the procedure recursively for each of the COND arguments.
Otherwise, check if it is one of the operators we support, for example, if it is
Item_func_eq or Item_func_equal .
3.
If yes, check if one of its arguments is Item_field that corresponds to the
field of our table that we can optimize on. Also, check if the other argument
is a constant. If everything is good, remember that the user only wants rows
where a given field must be equal to the given constant.
Search WWH ::




Custom Search