- Make eliminate_tables_for_list() take into account that it is not possible
to eliminate a table if it is used in the upper-side ON expressions. Example:
xxx JOIN (t1 LEFT JOIN t2 ON cond ) ON func(t2.columns)
Here it would eliminate t2 which is not possible because of use of t2.columns.
of the 5.3 code line after a merge with 5.2 on 2010-10-28
in order not to allow the cost to access a joined table to be equal
to 0 ever.
Expanded data sets for many test cases to get the same execution plans
as before.
- Set the default
- Adjust the testcases so that 'new' tests are run with optimizations turned on.
- Pull out relevant tests from "irrelevant" tests and run them with optimizations on.
- Run range.test and innodb.test with both mrr=on and mrr=off
Resolved all conflicts, bad merges and fixed a few minor bugs in the code.
Commented out the queries from multi_update, view, subselect_sj, func_str,
derived_view, view_grant that failed either with crashes in ps-protocol or
with wrong results.
The failures are clear indications of some bugs in the code and these bugs
are to be fixed.
- "Using MRR" is no longer shown with range access.
- Instead, both range and BKA accesses will show one of the following:
= "Rowid-ordered scan"
= "Key-ordered scan"
= "Key-ordered Rowid-ordered scan"
depending on whether DS-MRR implementation will do scan keys in order, rowids in order,
or both.
- The patch also introduces a way for other storage engines/MRR implementations to
pass information to EXPLAIN output about the properties of employed MRR scans.
Changed handler.inc to make test row order independent
mysql-test/r/table_elim.result:
Updated test results for 5.3
mysql-test/suite/handler/aria.result:
Updated result
mysql-test/suite/handler/handler.inc:
Changed handler.inc to make test row order independent
mysql-test/suite/handler/heap.result:
Updated result
mysql-test/suite/handler/innodb.result:
Updated result
mysql-test/suite/handler/myisam.result:
Updated result
- Fix for MySQL BUG#52357 added NESTED_JOIN::is_fully_covered() which would
not take into account that MariaDB's table elimination could eliminate tables
from join plan (and so, from join nest).
Fixed the check in the function to compare post-table-elimination numbers.
Applied the fix for bug #47217 from the mysql-6.0 codebase.
The patch adds not null predicates generated for the left parts
of the equality predicates used for ref accesses. This is done
for such predicates both in where conditions and on conditions.
For the where conditions the not null predicates were generated
but in 5.0/5.1 they actually never were used due to some lame
merge from 4.1 to 5.0. The fix for bug #47217 made these
predicates to be used in the condition pushed to the tables.
Yet only this patch generates not null predicates for equality
predicated from on conditions of outer joins.
This patch introduces a performance regression that can be
observed on a test case from null_key.test. The regression
will disappear after the fix for bug #57024 from mariadb-5.1
is pulled into mariadb-5.3.
The patch contains many changes in the outputs of the EXPLAIN
commands since generated not null predicates are considered as
parts of the conditions pushed to join tables and may add
'Usingwhere' in some rows of EXPLAINs where there used
to be no such comments.
The problem could be demonstrated with an outer join of two single-row
tables where the values of the join attributes were null. Any query
with such a join could return a wrong result set if the where
condition of the query was not empty. For queries with empty
where conditions the result sets were correct.
This was the consequence of two bugs in the code:
- Item_equal objects for on conditions of outer joins were
not built if the processed query had no where condition
- the check for null values in the code that evaluated constant
Item_equal objects was incorrect.
Fixed both above problems.
Added a test case for the bug and adjusted results for some other
test cases.
Save no-records constant tables in JOIN::const_table_map before we invoke
eliminate_tables(). Failure to do so caused crash when the same table was
marked as constant two times
mysql-test/r/table_elim.result:
LPBUG#524025 Running RQG outer_join test leads to crash
- Testcase
mysql-test/t/table_elim.test:
LPBUG#524025 Running RQG outer_join test leads to crash
- Testcase
sql/sql_select.cc:
LPBUG#524025 Running RQG outer_join test leads to crash
Save no-records constant tables in JOIN::const_table_map before we invoke eliminate_tables(). Failure to do so caused crash when the same table was marked as constant two times.
- When analying multiple equalities, take into account that they
may not have a single table field that belongs to one of the tables
that we're trying to eliminate (and they are not useful for table
elimination in that case)
mysql-test/r/table_elim.result:
LPBUG#523593: Running RQG optimizer_no_subquery crashes MariaDB
- Testcase
mysql-test/t/table_elim.test:
LPBUG#523593: Running RQG optimizer_no_subquery crashes MariaDB
- Testcase
WL#2474 "Multi Range Read: Change the default MRR implementation to implement new MRR interface"
WL#2475 "Batched range read functions for MyISAM/InnoDb"
"Index condition pushdown for MyISAM/InnoDB"
Igor's fix from sp1r-igor@olga.mysql.com-20080330055902-07614:
There could be observed the following problems:
1. EXPLAIN did not mention pushdown conditions from on expressions in the
'extra' column. As a result if a query had no where conditions pushed
down to a table, but had on conditions pushed to this table the 'extra'
column in the EXPLAIN for the table missed 'using where'.
2. Conditions for ref access were not eliminated from on expressions
though such conditions were eliminated from the where condition.
include/my_global.h:
MWL#17: Table elimination: fixes for windows
- Add ALIGN_MAX_UNIT (assume malloc returns data aligned to this much)
mysql-test/r/table_elim.result:
MWL#17: Table elimination: fixes for windows
- Use only lower-case as EXPLAIN [EXTENDED] changes case of table names
on windows
mysql-test/t/table_elim.test:
MWL#17: Table elimination: fixes for windows
- Use only lower-case as EXPLAIN [EXTENDED] changes case of table names
on windows
sql/opt_table_elimination.cc:
MWL#17: Table elimination: fixes for windows
- Add extra alignment-padding-space for stack-allocated buffers.
- Fix a trivial problem when OR-merging two multi-equalities
- Amend testsuite to provide full gcov coverage
mysql-test/r/table_elim.result:
MWL#17: Table elimination:
- Amend testsuite to provide full gcov coverage
mysql-test/t/table_elim.test:
MWL#17: Table elimination:
- Amend testsuite to provide full gcov coverage
- More testcases
- Set correct dependencies for non-bound multi-equalities.
mysql-test/r/table_elim.result:
MWL#17: Table elimination
- More testcases
mysql-test/t/table_elim.test:
MWL#17: Table elimination
- More testcases
sql/opt_table_elimination.cc:
MWL#17: Table elimination
- Set correct dependencies for non-bound multi-equalities.
- More testcases
- Let add_ft_key() set keyuse->usable
mysql-test/r/table_elim.result:
MWL#17: Table elimination
- More testcases
mysql-test/t/table_elim.test:
MWL#17: Table elimination
- More testcases
sql/sql_select.cc:
MWL#17: Table elimination
- Let add_ft_key() set keyuse->usable
- Make elimination work with aggregate functions. The problem was that aggregate functions
reported all table bits in used_tables(), and that prevented table elimination. Fixed by
making aggregate functions return more correct value from used_tables().
mysql-test/r/ps_11bugs.result:
MWL#17: Table elimination
- Update test results. The difference is because of Item_ref change: outer references to constants
are now recognized as constants, too.
mysql-test/r/subselect.result:
- Update test results. The difference is because of Item_ref change: outer references to constants
are now recognized as constants, too.
mysql-test/r/table_elim.result:
MWL#17: Table elimination
- Check that elimination works in presense of aggreagate functions
mysql-test/t/table_elim.test:
MWL#17: Table elimination
- Check that elimination works in presense of aggreagate functions
sql/item.h:
MWL#17: Table elimination
- Add Item_ref::const_item() which calls (*ref)->const_item(). Before this diff Item_ref used the
default implementation of const_item(){ return used_tables()==0; }. This is no longer true, as
COUNT(*) now has used_tables()==0 but const_item()==FALSE.
sql/item_sum.cc:
MWL#17: Table elimination
- Make Item_sum() and it descendants not to return all bits in used_tables(). This is needed
because otherwise table elimination can't work in presense of aggregate functions
- COUNT(*) now has used_tables()==0 and const_item()==FALSE. Had to change
Item_ref::const_item() to account for this.
sql/item_sum.h:
MWL#17: Table elimination
- Add comments
- First code. Elimination works for simple cases, passes the testsuite.
- Known issues:
= No elimination is done for aggregate functions.
= EXPLAIN EXTENDED shows eliminated tables (I think it better not)
= No benchmark yet
= The code needs some polishing.
mysql-test/r/table_elim.result:
MWL#17: Table elimination
- Testcases
mysql-test/t/table_elim.test:
MWL#17: Table elimination
- Testcases
sql/sql_select.cc:
MWL#17: Table elimination
sql/sql_select.h:
MWL#17: Table elimination
- Added JOIN_TAB::eliminated (is JOIN_TAB the best place to store this flag?)
sql/table.h:
MWL#17: Table elimination
- ADded NESTED_JOIN::n_tables. We need to have the number of real tables remaining in an outer join nest.