diff options
author | Sergey Petrunia <psergey@askmonty.org> | 2009-06-10 01:11:33 +0400 |
---|---|---|
committer | Sergey Petrunia <psergey@askmonty.org> | 2009-06-10 01:11:33 +0400 |
commit | fd485ad9889f2d8db6a2de6c61efb720cb97e96a (patch) | |
tree | f462823874fbcb7842e5dabe052c8b376323d1c1 /mysql-test/t/table_elim.test | |
parent | cf028a54746d6b166e9ffe8fa1e2e08569fe0dc1 (diff) | |
download | mariadb-git-fd485ad9889f2d8db6a2de6c61efb720cb97e96a.tar.gz |
MWL#17: Table elimination
- 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
Diffstat (limited to 'mysql-test/t/table_elim.test')
-rw-r--r-- | mysql-test/t/table_elim.test | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/mysql-test/t/table_elim.test b/mysql-test/t/table_elim.test index c540db884ea..4c8c360ea04 100644 --- a/mysql-test/t/table_elim.test +++ b/mysql-test/t/table_elim.test @@ -29,8 +29,6 @@ explain select t1.a from t1 left join t2 on t2.a=t1.a order by t2.b; --echo # This will not be eliminated as t2.b is in group list: explain select t1.a from t1 left join t2 on t2.a=t1.a group by t2.b; -## TODO: Aggregate functions prevent table elimination ATM. - --echo # This will not be eliminated as t2.b is in the WHERE explain select t1.a from t1 left join t2 on t2.a=t1.a where t2.b < 3 or t2.b is null; @@ -47,6 +45,13 @@ from t0 left join (t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and t3.a=t1.a) on t0.a=t1.a; +--echo # Elimination with aggregate functions +explain select count(*) from t1 left join t2 on t2.a=t1.a; +explain select count(1) from t1 left join t2 on t2.a=t1.a; +explain select count(1) from t1 left join t2 on t2.a=t1.a group by t1.a; + +--echo This must not use elimination: +explain select count(1) from t1 left join t2 on t2.a=t1.a group by t2.a; drop table t0, t1, t2, t3; |