Commit 47c344b0 authored by Sergei Petrunia's avatar Sergei Petrunia

MDEV-7904: ANALYZE FORMAT=JSON doesn't print r_rows for union output

Print r_rows. There is no table tracking for reading from tmp table, yet.
parent a2209050
......@@ -405,3 +405,61 @@ ANALYZE
}
}
drop table t1,t2,t3,t4;
#
# MDEV-7904: ANALYZE FORMAT=JSON SELECT .. UNION SELECT doesn't print r_rows for union output
#
create table t0 (a int);
INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (a int);
INSERT INTO t1 select * from t0;
analyze format=json (select * from t1 A where a<5) union (select * from t1 B where a in (2,3));
ANALYZE
{
"query_block": {
"union_result": {
"table_name": "<union1,2>",
"access_type": "ALL",
"r_loops": 1,
"r_rows": 5,
"query_specifications": [
{
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"table": {
"table_name": "A",
"access_type": "ALL",
"r_loops": 1,
"rows": 10,
"r_rows": 10,
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 50,
"attached_condition": "(A.a < 5)"
}
}
},
{
"query_block": {
"select_id": 2,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"table": {
"table_name": "B",
"access_type": "ALL",
"r_loops": 1,
"rows": 10,
"r_rows": 10,
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 20,
"attached_condition": "(B.a in (2,3))"
}
}
}
]
}
}
}
drop table t0, t1;
......@@ -134,3 +134,19 @@ select * from t1, t2 where (t2.key1 between t1.lb1 and t1.rb1) and
(t2.key3=t1.c1 OR t2.key4=t1.c2);
drop table t1,t2,t3,t4;
--echo #
--echo # MDEV-7904: ANALYZE FORMAT=JSON SELECT .. UNION SELECT doesn't print r_rows for union output
--echo #
create table t0 (a int);
INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (a int);
INSERT INTO t1 select * from t0;
--replace_regex /"r_total_time_ms": [0-9]*[.]?[0-9]*/"r_total_time_ms": "REPLACED"/
analyze format=json (select * from t1 A where a<5) union (select * from t1 B where a in (2,3));
drop table t0, t1;
......@@ -514,6 +514,23 @@ void Explain_union::print_explain_json(Explain_query *query,
make_union_table_name(table_name_buffer);
writer->add_member("table_name").add_str(table_name_buffer);
writer->add_member("access_type").add_str("ALL"); // not very useful
/* r_loops (not present in tabular output) */
if (is_analyze)
{
writer->add_member("r_loops").add_ll(fake_select_lex_tracker.get_loops());
}
/* `r_rows` */
if (is_analyze)
{
writer->add_member("r_rows");
if (fake_select_lex_tracker.has_scans())
writer->add_double(fake_select_lex_tracker.get_avg_rows());
else
writer->add_null();
}
writer->add_member("query_specifications").start_array();
for (int i= 0; i < (int) union_members.elements(); i++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment