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
66ad265f
Commit
66ad265f
authored
Mar 07, 2015
by
Sergei Petrunia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-7674: ANALYZE shows r_rows=0
Change r_rows to be double
parent
143f5d91
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
142 additions
and
66 deletions
+142
-66
mysql-test/r/analyze_format_json.result
mysql-test/r/analyze_format_json.result
+45
-5
mysql-test/r/analyze_stmt.result
mysql-test/r/analyze_stmt.result
+52
-40
mysql-test/r/analyze_stmt_slow_query_log.result
mysql-test/r/analyze_stmt_slow_query_log.result
+1
-1
mysql-test/t/analyze_format_json.test
mysql-test/t/analyze_format_json.test
+15
-0
mysql-test/t/analyze_stmt.test
mysql-test/t/analyze_stmt.test
+15
-0
sql/sql_class.cc
sql/sql_class.cc
+1
-2
sql/sql_explain.cc
sql/sql_explain.cc
+11
-16
sql/sql_explain.h
sql/sql_explain.h
+2
-2
No files found.
mysql-test/r/analyze_format_json.result
View file @
66ad265f
...
...
@@ -24,7 +24,7 @@ insert into t1 select A.a*10 + B.a, A.a*10 + B.a, A.a*10 + B.a from t0 A, t0 B;
analyze
select * from t0, t1 where t1.a=t0.a and t0.a > 9;
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 0.00 Using where
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10
.00
100.00 0.00 Using where
1 SIMPLE t1 ref a a 5 test.t0.a 1 NULL 100.00 NULL
analyze format=json
select * from t0, t1 where t1.a=t0.a and t0.a > 9;
...
...
@@ -61,8 +61,8 @@ EXPLAIN
analyze
select * from t0, t1 where t1.a=t0.a and t1.b<4;
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 100.00 Using where
1 SIMPLE t1 ref a a 5 test.t0.a 1 1 100.00 40.00 Using where
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10
.00
100.00 100.00 Using where
1 SIMPLE t1 ref a a 5 test.t0.a 1 1
.00
100.00 40.00 Using where
analyze format=json
select * from t0, t1 where t1.a=t0.a and t1.b<4;
EXPLAIN
...
...
@@ -99,8 +99,8 @@ EXPLAIN
analyze
select * from t1 tbl1, t1 tbl2 where tbl1.b<2 and tbl2.b>5;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE tbl1 ALL NULL NULL NULL NULL 100 100 100.00 2.00 Using where
1 SIMPLE tbl2 ALL NULL NULL NULL NULL 100 100 100.00 94.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE tbl1 ALL NULL NULL NULL NULL 100 100
.00
100.00 2.00 Using where
1 SIMPLE tbl2 ALL NULL NULL NULL NULL 100 100
.00
100.00 94.00 Using where; Using join buffer (flat, BNL join)
analyze format=json
select * from t1 tbl1, t1 tbl2 where tbl1.b<20 and tbl2.b<60;
EXPLAIN
...
...
@@ -170,3 +170,43 @@ EXPLAIN
}
drop table t1;
drop table t0;
#
# MDEV-7674: ANALYZE shows r_rows=0
#
create table t1(a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2 (a int, key(a));
insert into t2 values (0),(1);
analyze format=json select * from t1 straight_join t2 force index(a) where t2.a=t1.a;
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "t1",
"access_type": "ALL",
"r_loops": 1,
"rows": 10,
"r_rows": 10,
"filtered": 100,
"r_filtered": 100,
"attached_condition": "(t1.a is not null)"
},
"table": {
"table_name": "t2",
"access_type": "ref",
"possible_keys": ["a"],
"key": "a",
"key_length": "5",
"used_key_parts": ["a"],
"ref": ["test.t1.a"],
"r_loops": 10,
"rows": 2,
"r_rows": 0.2,
"filtered": 100,
"r_filtered": 100,
"using_index": true
}
}
}
drop table t1,t2;
mysql-test/r/analyze_stmt.result
View file @
66ad265f
This diff is collapsed.
Click to expand it.
mysql-test/r/analyze_stmt_slow_query_log.result
View file @
66ad265f
...
...
@@ -10,6 +10,6 @@ drop table t1;
# explain: id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
# explain: 1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL 100.00 100.00 NULL
# explain: id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
# explain: 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 30.00 Using where
# explain: 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10
.00
100.00 30.00 Using where
# explain: id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
# explain: 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used
mysql-test/t/analyze_format_json.test
View file @
66ad265f
...
...
@@ -36,3 +36,18 @@ select * from t1 tbl1, t1 tbl2 where tbl1.b<20 and tbl2.b<60 and tbl1.c > tbl2.c
drop
table
t1
;
drop
table
t0
;
--
echo
#
--
echo
# MDEV-7674: ANALYZE shows r_rows=0
--
echo
#
create
table
t1
(
a
int
);
insert
into
t1
values
(
0
),(
1
),(
2
),(
3
),(
4
),(
5
),(
6
),(
7
),(
8
),(
9
);
create
table
t2
(
a
int
,
key
(
a
));
insert
into
t2
values
(
0
),(
1
);
analyze
format
=
json
select
*
from
t1
straight_join
t2
force
index
(
a
)
where
t2
.
a
=
t1
.
a
;
drop
table
t1
,
t2
;
mysql-test/t/analyze_stmt.test
View file @
66ad265f
...
...
@@ -244,3 +244,18 @@ create table t1(a int);
prepare
stmt
from
"analyze select * from t1"
;
execute
stmt
;
drop
table
t1
;
--
echo
#
--
echo
# MDEV-7674: ANALYZE shows r_rows=0
--
echo
#
create
table
t1
(
a
int
);
insert
into
t1
values
(
0
),(
1
),(
2
),(
3
),(
4
),(
5
),(
6
),(
7
),(
8
),(
9
);
create
table
t2
(
a
int
,
key
(
a
));
insert
into
t2
values
(
0
),(
1
);
analyze
select
*
from
t1
straight_join
t2
force
index
(
a
)
where
t2
.
a
=
t1
.
a
;
drop
table
t1
,
t2
;
sql/sql_class.cc
View file @
66ad265f
...
...
@@ -2454,8 +2454,7 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
MYSQL_TYPE_LONGLONG
));
if
(
is_analyze
)
{
field_list
.
push_back
(
item
=
new
Item_return_int
(
"r_rows"
,
10
,
MYSQL_TYPE_LONGLONG
));
field_list
.
push_back
(
item
=
new
Item_float
(
"r_rows"
,
0.1234
,
10
,
4
));
item
->
maybe_null
=
1
;
}
...
...
sql/sql_explain.cc
View file @
66ad265f
...
...
@@ -298,7 +298,7 @@ int print_explain_row(select_result_sink *result,
const
char
*
key_len
,
const
char
*
ref
,
ha_rows
*
rows
,
ha_rows
*
r_rows
,
double
*
r_rows
,
double
r_filtered
,
const
char
*
extra
)
{
...
...
@@ -356,10 +356,7 @@ int print_explain_row(select_result_sink *result,
if
(
is_analyze
)
{
if
(
r_rows
)
{
item_list
.
push_back
(
new
Item_int
(
*
r_rows
,
MY_INT64_NUM_DECIMAL_DIGITS
));
}
item_list
.
push_back
(
new
Item_float
(
*
r_rows
,
2
));
else
item_list
.
push_back
(
item_null
);
}
...
...
@@ -472,9 +469,8 @@ int Explain_union::print_explain(Explain_query *query,
/* `r_rows` */
if
(
is_analyze
)
{
ha_rows
avg_rows
=
fake_select_lex_tracker
.
get_avg_rows
();
item_list
.
push_back
(
new
Item_int
((
longlong
)
(
ulonglong
)
avg_rows
,
MY_INT64_NUM_DECIMAL_DIGITS
));
double
avg_rows
=
fake_select_lex_tracker
.
get_avg_rows
();
item_list
.
push_back
(
new
Item_float
(
avg_rows
,
2
));
}
/* `filtered` */
...
...
@@ -1004,9 +1000,8 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
}
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
));
double
avg_rows
=
tracker
.
get_avg_rows
();
item_list
.
push_back
(
new
Item_float
(
avg_rows
,
2
));
}
}
...
...
@@ -1289,8 +1284,8 @@ void Explain_table_access::print_explain_json(Explain_query *query,
writer
->
add_member
(
"r_rows"
);
if
(
tracker
.
has_scans
())
{
ha_rows
avg_rows
=
tracker
.
get_avg_rows
();
writer
->
add_
ll
(
avg_rows
);
double
avg_rows
=
tracker
.
get_avg_rows
();
writer
->
add_
double
(
avg_rows
);
}
else
writer
->
add_null
();
...
...
@@ -1756,7 +1751,7 @@ int Explain_update::print_explain(Explain_query *query,
"Using index condition" is also not possible (which is an unjustified limitation)
*/
double
r_filtered
=
100
*
tracker
.
get_filtered_after_where
();
ha_rows
r_rows
=
tracker
.
get_avg_rows
();
double
r_rows
=
tracker
.
get_avg_rows
();
print_explain_row
(
output
,
explain_flags
,
is_analyze
,
1
,
/* id */
...
...
@@ -1877,8 +1872,8 @@ void Explain_update::print_explain_json(Explain_query *query,
/* `r_rows` */
if
(
is_analyze
&&
tracker
.
has_scans
())
{
ha_rows
avg_rows
=
tracker
.
get_avg_rows
();
writer
->
add_member
(
"r_rows"
).
add_
ll
(
avg_rows
);
double
avg_rows
=
tracker
.
get_avg_rows
();
writer
->
add_member
(
"r_rows"
).
add_
double
(
avg_rows
);
}
/* UPDATE/DELETE do not produce `filtered` estimate */
...
...
sql/sql_explain.h
View file @
66ad265f
...
...
@@ -44,9 +44,9 @@ public:
bool
has_scans
()
{
return
(
r_scans
!=
0
);
}
ha_rows
get_loops
()
{
return
r_scans
;
}
ha_rows
get_avg_rows
()
double
get_avg_rows
()
{
return
r_scans
?
(
ha_rows
)
rint
((
double
)
r_rows
/
r_scans
)
:
0
;
return
r_scans
?
(
(
double
)
r_rows
/
r_scans
)
:
0
;
}
double
get_filtered_after_where
()
...
...
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