[Maria-developers] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (psergey:2712)
#At lp:maria based on revid:psergey@askmonty.org-20090609211133-wfau2tgwo2vpgc5d
2712 Sergey Petrunia 2009-06-14
MWL#17: Table elimination
- Do not show eliminated tables in the output of EXPLAIN EXTENDED
modified:
mysql-test/r/table_elim.result
mysql-test/t/table_elim.test
sql/sql_select.cc
sql/sql_select.h
sql/table.h
per-file messages:
mysql-test/r/table_elim.result
MWL#17: Table elimination
- Do not show eliminated tables in the output of EXPLAIN EXTENDED
mysql-test/t/table_elim.test
MWL#17: Table elimination
- Do not show eliminated tables in the output of EXPLAIN EXTENDED
sql/sql_select.cc
MWL#17: Table elimination
- Do not show eliminated tables in the output of EXPLAIN EXTENDED
sql/sql_select.h
MWL#17: Table elimination
- Do not show eliminated tables in the output of EXPLAIN EXTENDED
sql/table.h
MWL#17: Table elimination
- Do not show eliminated tables in the output of EXPLAIN EXTENDED
=== modified file 'mysql-test/r/table_elim.result'
--- a/mysql-test/r/table_elim.result 2009-06-09 21:11:33 +0000
+++ b/mysql-test/r/table_elim.result 2009-06-14 10:01:10 +0000
@@ -10,6 +10,11 @@ as select a, a as b from t1 where a in (
explain select t1.a from t1 left join t2 on t2.a=t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
+explain extended select t1.a from t1 left join t2 on t2.a=t1.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1
select t1.a from t1 left join t2 on t2.a=t1.a;
a
0
@@ -45,14 +50,16 @@ explain select t1.a from t1 left join (t
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
# Elimination when done within an outer join nest:
-explain
+explain extended
select t0.*
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;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t0 ALL NULL NULL NULL NULL 4
-1 SIMPLE t1 ALL NULL NULL NULL NULL 4
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t0 ALL NULL NULL NULL NULL 4 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00
+Warnings:
+Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t0` left join (`test`.`t1`) on((`test`.`t0`.`a` = `test`.`t1`.`a`)) where 1
# Elimination with aggregate functions
explain select count(*) from t1 left join t2 on t2.a=t1.a;
id select_type table type possible_keys key key_len ref rows Extra
=== modified file 'mysql-test/t/table_elim.test'
--- a/mysql-test/t/table_elim.test 2009-06-09 21:11:33 +0000
+++ b/mysql-test/t/table_elim.test 2009-06-14 10:01:10 +0000
@@ -17,6 +17,7 @@ create table t3 (a int primary key, b in
--echo # This will be eliminated:
explain select t1.a from t1 left join t2 on t2.a=t1.a;
+explain extended select t1.a from t1 left join t2 on t2.a=t1.a;
select t1.a from t1 left join t2 on t2.a=t1.a;
@@ -39,7 +40,7 @@ explain select t1.a from t1 left join (t
explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and t3.a=t1.a;
--echo # Elimination when done within an outer join nest:
-explain
+explain extended
select t0.*
from
t0 left join (t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2009-06-07 18:24:03 +0000
+++ b/sql/sql_select.cc 2009-06-14 10:01:10 +0000
@@ -2386,6 +2386,10 @@ mysql_select(THD *thd, Item ***rref_poin
}
else
{
+ // psergey{
+ if (select_options & SELECT_DESCRIBE)
+ free_join= 0;
+ // }psergey
if (!(join= new JOIN(thd, fields, select_options, result)))
DBUG_RETURN(TRUE);
thd_proc_info(thd, "init");
@@ -2523,7 +2527,7 @@ static void mark_table_as_eliminated(JOI
{
DBUG_PRINT("info", ("Eliminated table %s", table->alias));
tab->type= JT_CONST;
- tab->eliminated= TRUE;
+ join->eliminated_tables |= table->map;
*const_tables |= table->map;
join->const_table_map|= table->map;
set_position(join, (*const_tbl_count)++, tab, (KEYUSE*)0);
@@ -2726,6 +2730,10 @@ static void eliminate_tables(JOIN *join,
Item *item;
table_map used_tables;
DBUG_ENTER("eliminate_tables");
+
+ join->eliminated_tables= 0;
+
+ /* MWL#17 is only about outer join elimination, so: */
if (!join->outer_join)
DBUG_VOID_RETURN;
@@ -6060,6 +6068,7 @@ JOIN::make_simple_join(JOIN *parent, TAB
tables= 1;
const_tables= 0;
const_table_map= 0;
+ eliminated_tables= 0;
tmp_table_param.field_count= tmp_table_param.sum_func_count=
tmp_table_param.func_count= 0;
tmp_table_param.copy_field= tmp_table_param.copy_field_end=0;
@@ -16509,7 +16518,7 @@ static void select_describe(JOIN *join,
quick_type= -1;
//psergey-todo:
- if (tab->eliminated)
+ if (table->map & join->eliminated_tables)
{
used_tables|=table->map;
continue;
@@ -16912,6 +16921,7 @@ bool mysql_explain_union(THD *thd, SELEC
*/
static void print_join(THD *thd,
+ table_map eliminated_tables,
String *str,
List
participants (1)
-
Sergey Petrunia