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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
b561a98a
Commit
b561a98a
authored
Jun 25, 2014
by
Sergei Petrunia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-406: ANALYZE $stmt: add some tests for joins
parent
7711999d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
3 deletions
+52
-3
mysql-test/r/analyze_stmt.result
mysql-test/r/analyze_stmt.result
+31
-1
mysql-test/t/analyze_stmt.test
mysql-test/t/analyze_stmt.test
+21
-2
No files found.
mysql-test/r/analyze_stmt.result
View file @
b561a98a
...
@@ -115,5 +115,35 @@ analyze select * from t0, t1 where t0.a<5 and t1.a<5 and t1.b=t0.b;
...
@@ -115,5 +115,35 @@ analyze select * from t0, t1 where t0.a<5 and t1.a<5 and t1.b=t0.b;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10 100.00 50.00 Using where
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10 100.00 50.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 10.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 10.00 Using where; Using join buffer (flat, BNL join)
drop table t0,t1;
# TODO: Check what is counted for "range checked for each record".
# TODO: Check what is counted for "range checked for each record".
#
# Test for joins
#
create table t2 (key1 int, key2x int, col1 int, key(key1), key(key2x));
insert into t2 select A.a + 10 *B.a +100 * C.a,
(A.a + 10 *B.a +100 * C.a)*2,
A.a + 10 *B.a +100 * C.a
from t0 A, t0 B, t0 C;
# This always has matches, filtered=100%.
analyze select * from t1,t2 where t2.key1=t1.a;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 100.00 Using where
1 SIMPLE t2 ref key1 key1 5 test.t1.a 1 1 100.00 100.00
# This shows r_rows=0. It is actually 0.5 (should r_rows be changed to double?)
analyze select * from t1,t2 where t2.key2x=t1.a;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 100.00 Using where
1 SIMPLE t2 ref key2x key2x 5 test.t1.a 1 0 100.00 100.00
select * from t1,t2 where t2.key2x=t1.a;
a b key1 key2x col1
0 0 0 0 0
2 2 1 2 1
4 4 2 4 2
6 6 3 6 3
8 8 4 8 4
# This has t2.filtered=40% (there are 5 values: {0,1,2,3,4}. two of them have mod=0)
analyze select * from t1,t2 where t2.key2x=t1.a and mod(t2.col1,4)=0;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 100.00 Using where
1 SIMPLE t2 ref key2x key2x 5 test.t1.a 1 0 100.00 40.00 Using where
drop table t0,t1,t2;
mysql-test/t/analyze_stmt.test
View file @
b561a98a
...
@@ -84,7 +84,26 @@ explain select * from t0, t1 where t0.a<5 and t1.a<5 and t1.b=t0.b;
...
@@ -84,7 +84,26 @@ explain select * from t0, t1 where t0.a<5 and t1.a<5 and t1.b=t0.b;
--
echo
# Now, t1 should have filtered=10
--
echo
# Now, t1 should have filtered=10
analyze
select
*
from
t0
,
t1
where
t0
.
a
<
5
and
t1
.
a
<
5
and
t1
.
b
=
t0
.
b
;
analyze
select
*
from
t0
,
t1
where
t0
.
a
<
5
and
t1
.
a
<
5
and
t1
.
b
=
t0
.
b
;
drop
table
t0
,
t1
;
--
echo
# TODO: Check what is counted for "range checked for each record".
--
echo
# TODO: Check what is counted for "range checked for each record".
--
echo
#
--
echo
# Test for joins
--
echo
#
create
table
t2
(
key1
int
,
key2x
int
,
col1
int
,
key
(
key1
),
key
(
key2x
));
insert
into
t2
select
A
.
a
+
10
*
B
.
a
+
100
*
C
.
a
,
(
A
.
a
+
10
*
B
.
a
+
100
*
C
.
a
)
*
2
,
A
.
a
+
10
*
B
.
a
+
100
*
C
.
a
from
t0
A
,
t0
B
,
t0
C
;
--
echo
# This always has matches, filtered=100%.
analyze
select
*
from
t1
,
t2
where
t2
.
key1
=
t1
.
a
;
--
echo
# This shows r_rows=0. It is actually 0.5 (should r_rows be changed to double?)
analyze
select
*
from
t1
,
t2
where
t2
.
key2x
=
t1
.
a
;
select
*
from
t1
,
t2
where
t2
.
key2x
=
t1
.
a
;
--
echo
# This has t2.filtered=40% (there are 5 values: {0,1,2,3,4}. two of them have mod=0)
analyze
select
*
from
t1
,
t2
where
t2
.
key2x
=
t1
.
a
and
mod
(
t2
.
col1
,
4
)
=
0
;
drop
table
t0
,
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