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
049c87fc
Commit
049c87fc
authored
Aug 17, 2009
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MWL#17: Table elimination
- More testcases
parent
441434e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
0 deletions
+85
-0
mysql-test/r/table_elim.result
mysql-test/r/table_elim.result
+44
-0
mysql-test/t/table_elim.test
mysql-test/t/table_elim.test
+41
-0
No files found.
mysql-test/r/table_elim.result
View file @
049c87fc
...
...
@@ -218,4 +218,48 @@ select t1.*, t2.* from t1 left join (t2 left join t3 on t3.pk=t2.col) on t2.pk=t
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, t3;
#
# Check things that look like functional dependencies but really are not
#
create table t1 (a char(10) character set latin1 collate latin1_general_ci primary key);
insert into t1 values ('foo');
insert into t1 values ('bar');
create table t2 (a char(10) character set latin1 collate latin1_general_cs primary key);
insert into t2 values ('foo');
insert into t2 values ('FOO');
this must not use table elimination:
explain select t1.* from t1 left join t2 on t2.a='foo' collate latin1_general_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 10 NULL 2 Using index
1 SIMPLE t2 index PRIMARY PRIMARY 10 NULL 2 Using index
this must not use table elimination:
explain select t1.* from t1 left join t2 on t2.a=t1.a collate latin1_general_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 10 NULL 2 Using index
1 SIMPLE t2 index PRIMARY PRIMARY 10 NULL 2 Using index
drop table t1,t2;
create table t1 (a int primary key);
insert into t1 values (1),(2);
create table t2 (a char(10) primary key);
insert into t2 values ('1'),('1.0');
this must not use table elimination:
explain select t1.* from t1 left join t2 on t2.a=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
1 SIMPLE t2 index PRIMARY PRIMARY 10 NULL 2 Using index
this must not use table elimination:
explain select t1.* 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 index NULL PRIMARY 4 NULL 2 Using index
1 SIMPLE t2 index PRIMARY PRIMARY 10 NULL 2 Using index
drop table t1, t2;
create table t1 (a char(10) primary key);
insert into t1 values ('foo'),('bar');
create table t2 (a char(10), unique key(a(2)));
insert into t2 values ('foo'),('bar');
explain select t1.* 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 index NULL PRIMARY 10 NULL 2 Using index
1 SIMPLE t2 ref a a 3 test.t1.a 2
drop table t1, t2;
mysql-test/t/table_elim.test
View file @
049c87fc
...
...
@@ -175,5 +175,46 @@ select t1.* from t1 left join ( t2 left join t3 on t3.pk=t2.col) on t2.col=t1.co
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
,
t3
;
--
echo
#
--
echo
# Check things that look like functional dependencies but really are not
--
echo
#
create
table
t1
(
a
char
(
10
)
character
set
latin1
collate
latin1_general_ci
primary
key
);
insert
into
t1
values
(
'foo'
);
insert
into
t1
values
(
'bar'
);
create
table
t2
(
a
char
(
10
)
character
set
latin1
collate
latin1_general_cs
primary
key
);
insert
into
t2
values
(
'foo'
);
insert
into
t2
values
(
'FOO'
);
--
echo
this
must
not
use
table
elimination:
explain select t1.* from t1 left join t2 on t2.a='foo' collate latin1_general_ci
;
--
echo
this
must
not
use
table
elimination:
explain select t1.* from t1 left join t2 on t2.a=t1.a collate latin1_general_ci
;
drop
table
t1
,
t2
;
create
table
t1
(
a
int
primary
key
);
insert
into
t1
values
(
1
),(
2
);
create
table
t2
(
a
char
(
10
)
primary
key
);
insert
into
t2
values
(
'1'
),(
'1.0'
);
--
echo
this
must
not
use
table
elimination:
explain select t1.* from t1 left join t2 on t2.a=1
;
--
echo
this
must
not
use
table
elimination:
explain select t1.* from t1 left join t2 on t2.a=t1.a
;
drop
table
t1
,
t2
;
# partial unique keys do not work at the moment, although they are able to
# provide one-match guarantees:
create
table
t1
(
a
char
(
10
)
primary
key
);
insert
into
t1
values
(
'foo'
),(
'bar'
);
create
table
t2
(
a
char
(
10
),
unique
key
(
a
(
2
)));
insert
into
t2
values
(
'foo'
),(
'bar'
);
explain
select
t1
.*
from
t1
left
join
t2
on
t2
.
a
=
t1
.
a
;
drop
table
t1
,
t2
;
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