-
Roy Lyseng authored
The current implementation of pushdown_on_conditions() is rather badly structured and it is possible to make it simpler and slightly more efficient. - Comments are added all over the place and use of local variables cleaned up. - Function pushdown_on_conditions() is renamed to JOIN::attach_join_conditions(). The name is based on the fact that conditions are isolated and "attached" to the table where they can be evaluated in an optimal way. - pushdown_on_conditions() has a separate section that analyzes const conditions for outer join. This code is called for every table that is added to the plan and when called, it visits every table present in the plan. However, it is more efficient to call it only when a complete outer join operation has been formed and then attach the condition to the first inner table of the outer join. - pushdown_on_conditions() loops over all tables added to the plan, but it is only needed to loop over all inner tables of the plan. This is handled by setting the "prefix_tables" field for the first inner table to cover all tables up to and including this table. - The effect of these changes is also a simplification of some redundant table conditions. - make_join_select() has a first stage that looks at const join conditions. However, this is easily handled exclusively within JOIN::attach_join_conditions(). - Function add_found_match_trig_cond() can be slightly rewritten and comments can be improved. Recursion is replaced with iteration (which causes slight change to optimizer trace). add_found_match_trig_cond() is called by pushdown_on_conditions(). - The test file join_nested.test contains a few test cases that check nested outer join operations. However, these test cases use MySQL- specific syntax making it difficult to compare test results with other SQL databases. The patch adds duplicate test cases with standard compliant syntax. mysql-test/r/join_nested.result mysql-test/r/join_nested_bka.result mysql-test/r/join_nested_bka_nixbnl.result Test results for duplicate tests with standard compliant SQL syntax. mysql-test/r/subquery_sj_dupsweed.result mysql-test/r/subquery_sj_dupsweed_bka.result mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result mysql-test/r/subquery_sj_dupsweed_bkaunique.result mysql-test/r/subquery_sj_firstmatch.result mysql-test/r/subquery_sj_firstmatch_bka.result mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result mysql-test/r/subquery_sj_firstmatch_bkaunique.result mysql-test/r/subquery_sj_loosescan.result mysql-test/r/subquery_sj_loosescan_bka.result mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result mysql-test/r/subquery_sj_loosescan_bkaunique.result Some simplified conditions. mysql-test/suite/opt_trace/r/general2_no_prot.result mysql-test/suite/opt_trace/r/general2_ps_prot.result Optimizer trace: Reversed wrapping order of triggered conditions. mysql-test/t/join_nested.test Added some duplicate nested join tests with standard SQL syntax. sql/sql_optimizer.cc Altered make_join_select(), attach_join_conditions() and add_found_match_trig_cond() according to above specification. quick_fix_fields() replaced with fix_fields() because hitting a problem where data is not correctly propagated using update_used_tables(). sql/sql_optimizer.h Added attach_join_conditions() as member function in class JOIN. sql/sql_select.h Added comments. sql/table.h Added comments.
Roy Lyseng authoredThe current implementation of pushdown_on_conditions() is rather badly structured and it is possible to make it simpler and slightly more efficient. - Comments are added all over the place and use of local variables cleaned up. - Function pushdown_on_conditions() is renamed to JOIN::attach_join_conditions(). The name is based on the fact that conditions are isolated and "attached" to the table where they can be evaluated in an optimal way. - pushdown_on_conditions() has a separate section that analyzes const conditions for outer join. This code is called for every table that is added to the plan and when called, it visits every table present in the plan. However, it is more efficient to call it only when a complete outer join operation has been formed and then attach the condition to the first inner table of the outer join. - pushdown_on_conditions() loops over all tables added to the plan, but it is only needed to loop over all inner tables of the plan. This is handled by setting the "prefix_tables" field for the first inner table to cover all tables up to and including this table. - The effect of these changes is also a simplification of some redundant table conditions. - make_join_select() has a first stage that looks at const join conditions. However, this is easily handled exclusively within JOIN::attach_join_conditions(). - Function add_found_match_trig_cond() can be slightly rewritten and comments can be improved. Recursion is replaced with iteration (which causes slight change to optimizer trace). add_found_match_trig_cond() is called by pushdown_on_conditions(). - The test file join_nested.test contains a few test cases that check nested outer join operations. However, these test cases use MySQL- specific syntax making it difficult to compare test results with other SQL databases. The patch adds duplicate test cases with standard compliant syntax. mysql-test/r/join_nested.result mysql-test/r/join_nested_bka.result mysql-test/r/join_nested_bka_nixbnl.result Test results for duplicate tests with standard compliant SQL syntax. mysql-test/r/subquery_sj_dupsweed.result mysql-test/r/subquery_sj_dupsweed_bka.result mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result mysql-test/r/subquery_sj_dupsweed_bkaunique.result mysql-test/r/subquery_sj_firstmatch.result mysql-test/r/subquery_sj_firstmatch_bka.result mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result mysql-test/r/subquery_sj_firstmatch_bkaunique.result mysql-test/r/subquery_sj_loosescan.result mysql-test/r/subquery_sj_loosescan_bka.result mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result mysql-test/r/subquery_sj_loosescan_bkaunique.result Some simplified conditions. mysql-test/suite/opt_trace/r/general2_no_prot.result mysql-test/suite/opt_trace/r/general2_ps_prot.result Optimizer trace: Reversed wrapping order of triggered conditions. mysql-test/t/join_nested.test Added some duplicate nested join tests with standard SQL syntax. sql/sql_optimizer.cc Altered make_join_select(), attach_join_conditions() and add_found_match_trig_cond() according to above specification. quick_fix_fields() replaced with fix_fields() because hitting a problem where data is not correctly propagated using update_used_tables(). sql/sql_optimizer.h Added attach_join_conditions() as member function in class JOIN. sql/sql_select.h Added comments. sql/table.h Added comments.
Loading