Monday, August 28, 2017


Short description of the project:

Implementation of:
  •  a new construction called TABLE VALUE CONSTRUCTOR (TVC)
  • optimization that transforms IN predicate into IN subquery that uses TVC.
What's done:
for TVC implementation:

-construct of TVC (including the case when TVC is used as derived table)
Non-terminals in sql_yacc.yy: table_value_constructor, derived_table_value_constructor
 -class table_value_constr
 Includes the list of values that defines this TVC
-TVC handling  
Pointer to table_value_constr is a member of st_select_lex class. As TVC is needed to be materialized it is handled as UNION.
For the class table_value_constr the methods prepare, exec and optimize are written.
-print method for TVC
-tests: table_value_constr.test
-comments on each new method
*TVC can be used in all constructions except subqueries. Due to the specific implementation of subqueries TVC can be used in a subquery only when it is wrapped into a derived table.

for optimization implementation:
-global variable that controls optimization working (in_subquery_conversion_threshold)
It works only when the total number of scalar values used in IN predicate is more than this variable
-creation of TVC specified by values from IN predicate
-creation of new statement SELECT * FROM (VALUES values) AS tvc_0
Methods:  make_new_subselect_for_tvc
-creation of IN-subselect defined by this statement
Transformer: Item_func_in::in_predicate_to_in_subs_transformer
-tests: opt_tvc.test
-comments on each new method

Optimization works when IN predicate is used in WHERE clause of the query or when it is ON expression of some join. It also works when IN predicate is in derived tables, CTEs and subqueries.

New files added:, sql_tvc.h

No comments:

Post a Comment