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
c3cfb691
Commit
c3cfb691
authored
Jun 24, 2014
by
Sergei Petrunia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-406: ANALYZE $stmt: Scans that never executed will have r_rows=NULL
parent
06a87d77
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
8 deletions
+31
-8
mysql-test/r/analyze_stmt.result
mysql-test/r/analyze_stmt.result
+5
-0
mysql-test/t/analyze_stmt.test
mysql-test/t/analyze_stmt.test
+3
-0
sql/sql_explain.cc
sql/sql_explain.cc
+22
-8
sql/sql_explain.h
sql/sql_explain.h
+1
-0
No files found.
mysql-test/r/analyze_stmt.result
View file @
c3cfb691
...
...
@@ -74,4 +74,9 @@ analyze select a, a in (select t0.b from t0 where t0.b+1=t1.b+1) from t1;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 3 100.00 100.00
2 DEPENDENT SUBQUERY t0 ALL NULL NULL NULL NULL 10 3 100.00 33.33 Using where
# Try a subquery that is never executed
analyze select a, a in (select t0.b from t0 where t0.b+1=t1.b+1) from t1 where t1.a > 5;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 3 100.00 0.00 Using where
2 DEPENDENT SUBQUERY t0 ALL NULL NULL NULL NULL 10 NULL 100.00 NULL Using where
drop table t0,t1;
mysql-test/t/analyze_stmt.test
View file @
c3cfb691
...
...
@@ -58,5 +58,8 @@ insert into t1 values (1,1),(2,2),(3,3);
--
echo
# See .test file for the right values of r_rows and r_filtered.
analyze
select
a
,
a
in
(
select
t0
.
b
from
t0
where
t0
.
b
+
1
=
t1
.
b
+
1
)
from
t1
;
--
echo
# Try a subquery that is never executed
analyze
select
a
,
a
in
(
select
t0
.
b
from
t0
where
t0
.
b
+
1
=
t1
.
b
+
1
)
from
t1
where
t1
.
a
>
5
;
drop
table
t0
,
t1
;
sql/sql_explain.cc
View file @
c3cfb691
...
...
@@ -553,9 +553,16 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
/* `r_rows` */
if
(
is_analyze
)
{
ha_rows
avg_rows
=
tracker
.
get_avg_rows
();
item_list
.
push_back
(
new
Item_int
((
longlong
)
(
ulonglong
)
avg_rows
,
MY_INT64_NUM_DECIMAL_DIGITS
));
if
(
!
tracker
.
has_scans
())
{
item_list
.
push_back
(
item_null
);
}
else
{
ha_rows
avg_rows
=
tracker
.
get_avg_rows
();
item_list
.
push_back
(
new
Item_int
((
longlong
)
(
ulonglong
)
avg_rows
,
MY_INT64_NUM_DECIMAL_DIGITS
));
}
}
/* `filtered` */
...
...
@@ -572,12 +579,19 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
/* `r_filtered` */
if
(
is_analyze
)
{
double
r_filtered
;
if
(
tracker
.
r_rows
>
0
)
r_filtered
=
100.0
*
(
double
)
tracker
.
r_rows_after_table_cond
/
tracker
.
r_rows
;
if
(
!
tracker
.
has_scans
())
{
item_list
.
push_back
(
item_null
);
}
else
r_filtered
=
100.0
;
item_list
.
push_back
(
new
Item_float
(
r_filtered
,
2
));
{
double
r_filtered
;
if
(
tracker
.
r_rows
>
0
)
r_filtered
=
100.0
*
(
double
)
tracker
.
r_rows_after_table_cond
/
tracker
.
r_rows
;
else
r_filtered
=
100.0
;
item_list
.
push_back
(
new
Item_float
(
r_filtered
,
2
));
}
}
/* `Extra` */
...
...
sql/sql_explain.h
View file @
c3cfb691
...
...
@@ -28,6 +28,7 @@ public:
ha_rows
r_rows_after_table_cond
;
/* Rows after applying the table condition */
ha_rows
r_rows_after_where
;
/* Rows after applying attached part of WHERE */
bool
has_scans
()
{
return
(
r_scans
!=
0
);
}
ha_rows
get_avg_rows
()
{
return
r_scans
?
(
ha_rows
)
rint
((
double
)
r_rows
/
r_scans
)
:
0
;
...
...
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