Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
441434e5
Commit
441434e5
authored
Aug 17, 2009
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MWL#17: Table elimination
- More dbug printouts - More testcases
parent
a14b5d24
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
6 deletions
+49
-6
mysql-test/r/table_elim.result
mysql-test/r/table_elim.result
+17
-0
mysql-test/t/table_elim.test
mysql-test/t/table_elim.test
+19
-0
sql/opt_table_elimination.cc
sql/opt_table_elimination.cc
+13
-6
No files found.
mysql-test/r/table_elim.result
View file @
441434e5
...
...
@@ -202,3 +202,20 @@ t2.pk3=t2.pk1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
drop table t1, t2;
create table t1 (pk int primary key, col int);
insert into t1 values (1,1),(2,2);
create table t2 like t1;
insert into t2 select * from t1;
create table t3 like t1;
insert into t3 select * from t1;
explain
select t1.* from t1 left join ( t2 left join t3 on t3.pk=t2.col) on t2.col=t1.col;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
explain
select t1.*, t2.* from t1 left join (t2 left join t3 on t3.pk=t2.col) on t2.pk=t1.col;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.col 1
drop table t1, t2;
mysql-test/t/table_elim.test
View file @
441434e5
...
...
@@ -157,4 +157,23 @@ explain select t1.* from t1 left join t2 on t2.pk2=t1.a and
t2.pk3=t2.pk1
;
drop
table
t1
,
t2
;
#
# Check that equality propagation is taken into account
#
create
table
t1
(
pk
int
primary
key
,
col
int
);
insert
into
t1
values
(
1
,
1
),(
2
,
2
);
create
table
t2
like
t1
;
insert
into
t2
select
*
from
t1
;
create
table
t3
like
t1
;
insert
into
t3
select
*
from
t1
;
explain
select
t1
.*
from
t1
left
join
(
t2
left
join
t3
on
t3
.
pk
=
t2
.
col
)
on
t2
.
col
=
t1
.
col
;
explain
select
t1
.*
,
t2
.*
from
t1
left
join
(
t2
left
join
t3
on
t3
.
pk
=
t2
.
col
)
on
t2
.
pk
=
t1
.
col
;
drop
table
t1
,
t2
;
sql/opt_table_elimination.cc
View file @
441434e5
...
...
@@ -136,7 +136,8 @@ class Table_elimination;
/*
A value.
A value, something that can be bound or not bound. Also, values can be linked
in a list.
*/
class
Value_dep
:
public
Sql_alloc
...
...
@@ -203,7 +204,7 @@ public:
/*
A 'module'
A 'module'
. Module has dependencies
*/
class
Module_dep
:
public
Sql_alloc
...
...
@@ -227,7 +228,6 @@ public:
};
/*
A "tbl.column= expr" equality dependency. tbl.column depends on fields
used in expr.
...
...
@@ -333,6 +333,9 @@ Equality_module *merge_func_deps(Equality_module *start, Equality_module *new_fi
static
Table_value
*
get_table_value
(
Table_elimination
*
te
,
TABLE
*
table
);
static
Field_value
*
get_field_value
(
Table_elimination
*
te
,
Field
*
field
);
static
Outer_join_module
*
get_outer_join_dep
(
Table_elimination
*
te
,
TABLE_LIST
*
outer_join
,
table_map
deps_map
);
static
void
run_elimination_wave
(
Table_elimination
*
te
,
Module_dep
*
bound_modules
);
void
eliminate_tables
(
JOIN
*
join
);
...
...
@@ -1212,15 +1215,19 @@ void run_elimination_wave(Table_elimination *te, Module_dep *bound_modules)
- expressions that depend on us.
*/
Field_value
*
field_dep
=
(
Field_value
*
)
bound_values
;
DBUG_PRINT
(
"info"
,
(
"field %s.%s is now bound"
,
field_dep
->
field
->
table
->
alias
,
field_dep
->
field
->
field_name
));
for
(
Key_module
*
key_dep
=
field_dep
->
table
->
keys
;
key_dep
;
key_dep
=
key_dep
->
next_table_key
)
{
DBUG_PRINT
(
"info"
,
(
"key %s.%s is now bound"
,
key_dep
->
table
->
table
->
alias
,
key_dep
->
table
->
table
->
key_info
[
key_dep
->
keyno
].
name
));
if
(
field_dep
->
field
->
part_of_key
.
is_set
(
key_dep
->
keyno
)
&&
key_dep
->
unknown_args
&&
!--
key_dep
->
unknown_args
)
{
DBUG_PRINT
(
"info"
,
(
"key %s.%s is now bound"
,
key_dep
->
table
->
table
->
alias
,
key_dep
->
table
->
table
->
key_info
[
key_dep
->
keyno
].
name
));
/* Mark as bound and add to the list */
key_dep
->
next
=
bound_modules
;
bound_modules
=
key_dep
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment