1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-27021 Add explicit indication of SHOW EXPLAIN/ANALYZE.

1. Add explicit indication that the output is produced by
SHOW EXPLAIN/ANALYZE FORMAT=JSON command.
2. Remove useless "r_total_time_ms" field from SHOW ANALYZE FORMAT=JSON
output when there is no timed statistics gathered.
3. Add "r_query_time_in_progress_ms" to the output of SHOW ANALYZE FORMAT=JSON.
This commit is contained in:
Oleg Smirnov
2022-02-16 13:03:46 +07:00
committed by Sergei Petrunia
parent d1a1ad4c28
commit a0475cb9ca
65 changed files with 207 additions and 187 deletions

View File

@ -36,12 +36,12 @@ SET debug_dbug='+d,show_explain_probe_join_exec_end';
select count(*) from t1 where c < 500;
connection default;
show analyze format=JSON for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
@ -50,7 +50,7 @@ ANALYZE
"r_loops": 1,
"rows": 1000,
"r_rows": 1000,
"filtered": 59.375,
"filtered": 50,
"r_filtered": 50,
"attached_condition": "t1.c < 500"
}
@ -66,12 +66,12 @@ count(*)
select max(c) from t1 where c < 10;
connection default;
show analyze format=json for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
@ -80,7 +80,7 @@ ANALYZE
"r_loops": 1,
"rows": 1000,
"r_rows": 1000,
"filtered": 10.15625,
"filtered": 10,
"r_filtered": 10,
"attached_condition": "t1.c < 10"
}
@ -97,8 +97,9 @@ max(c)
analyze select max(c) from t1 where a < 10;
connection default;
show analyze format=json for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_loops": 1,
@ -131,11 +132,12 @@ SET debug_dbug=@old_debug;
# UNION, select, first branch
set @show_explain_probe_select_id=1;
SET debug_dbug='+d,show_explain_probe_join_exec_end';
select max(a) from t0 A where a<=5 union select max(a+1) from t0 B where a>=9;
select max(a) from t0 a where a<=5 union select max(a+1) from t0 b where a>=9;
connection default;
show analyze FORMAT= json for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@ -147,11 +149,10 @@ ANALYZE
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
"table_name": "A",
"table_name": "a",
"access_type": "ALL",
"r_loops": 1,
"rows": 10,
@ -171,7 +172,7 @@ ANALYZE
"nested_loop": [
{
"table": {
"table_name": "B",
"table_name": "b",
"access_type": "ALL",
"r_loops": 0,
"rows": 10,
@ -189,7 +190,7 @@ ANALYZE
}
}
Warnings:
Note 1003 select max(a) from t0 A where a<=5 union select max(a+1) from t0 B where a>=9
Note 1003 select max(a) from t0 a where a<=5 union select max(a+1) from t0 b where a>=9
connection con1;
max(a)
5
@ -197,11 +198,12 @@ max(a)
# UNION, select, second branch
set @show_explain_probe_select_id=2;
SET debug_dbug='+d,show_explain_probe_join_exec_end';
select max(a) from t0 A where a<=5 union select max(a+1) from t0 B where a>=9;
select max(a) from t0 a where a<=5 union select max(a+1) from t0 b where a>=9;
connection default;
show analyze format=JSON for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@ -213,11 +215,10 @@ ANALYZE
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
"table_name": "A",
"table_name": "a",
"access_type": "ALL",
"r_loops": 1,
"rows": 10,
@ -235,11 +236,10 @@ ANALYZE
"select_id": 2,
"operation": "UNION",
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
"table_name": "B",
"table_name": "b",
"access_type": "ALL",
"r_loops": 1,
"rows": 10,
@ -257,7 +257,7 @@ ANALYZE
}
}
Warnings:
Note 1003 select max(a) from t0 A where a<=5 union select max(a+1) from t0 B where a>=9
Note 1003 select max(a) from t0 a where a<=5 union select max(a+1) from t0 b where a>=9
connection con1;
max(a)
5
@ -265,11 +265,12 @@ max(a)
# UNION, analyze, first branch
set @show_explain_probe_select_id=1;
SET debug_dbug='+d,show_explain_probe_join_exec_end';
analyze select a from t0 A where a<=5 union select a+1 from t0 B where a>=9;
analyze select a from t0 a where a<=5 union select a+1 from t0 b where a>=9;
connection default;
show analyze format=json for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@ -285,7 +286,7 @@ ANALYZE
"nested_loop": [
{
"table": {
"table_name": "A",
"table_name": "a",
"access_type": "ALL",
"r_loops": 1,
"rows": 10,
@ -307,7 +308,7 @@ ANALYZE
"nested_loop": [
{
"table": {
"table_name": "B",
"table_name": "b",
"access_type": "ALL",
"r_loops": 0,
"rows": 10,
@ -325,19 +326,20 @@ ANALYZE
}
}
Warnings:
Note 1003 analyze select a from t0 A where a<=5 union select a+1 from t0 B where a>=9
Note 1003 analyze select a from t0 a where a<=5 union select a+1 from t0 b where a>=9
connection con1;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10 10.00 100.00 60.00 Using where
2 UNION B ALL NULL NULL NULL NULL 10 10.00 100.00 10.00 Using where
1 PRIMARY a ALL NULL NULL NULL NULL 10 10.00 100.00 60.00 Using where
2 UNION b ALL NULL NULL NULL NULL 10 10.00 100.00 10.00 Using where
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL 7.00 NULL NULL
# UNION, analyze, second branch
set @show_explain_probe_select_id=2;
analyze select a from t0 A where a<=5 union select a+1 from t0 B where a>=9;
analyze select a from t0 a where a<=5 union select a+1 from t0 b where a>=9;
connection default;
show analyze FORMAT=JSON for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@ -353,7 +355,7 @@ ANALYZE
"nested_loop": [
{
"table": {
"table_name": "A",
"table_name": "a",
"access_type": "ALL",
"r_loops": 1,
"rows": 10,
@ -377,7 +379,7 @@ ANALYZE
"nested_loop": [
{
"table": {
"table_name": "B",
"table_name": "b",
"access_type": "ALL",
"r_loops": 1,
"rows": 10,
@ -397,29 +399,29 @@ ANALYZE
}
}
Warnings:
Note 1003 analyze select a from t0 A where a<=5 union select a+1 from t0 B where a>=9
Note 1003 analyze select a from t0 a where a<=5 union select a+1 from t0 b where a>=9
connection con1;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10 10.00 100.00 60.00 Using where
2 UNION B ALL NULL NULL NULL NULL 10 10.00 100.00 10.00 Using where
1 PRIMARY a ALL NULL NULL NULL NULL 10 10.00 100.00 60.00 Using where
2 UNION b ALL NULL NULL NULL NULL 10 10.00 100.00 10.00 Using where
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL 7.00 NULL NULL
SET debug_dbug=@old_debug;
# Uncorrelated subquery, select
set @show_explain_probe_select_id=1;
SET debug_dbug='+d,show_explain_probe_join_exec_end';
select a, (select max(a) from t0 B where a>6) from t0 A where a<2;
select a, (select max(a) from t0 b where a>6) from t0 a where a<2;
connection default;
show analyze format=json for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
"table_name": "A",
"table_name": "a",
"access_type": "ALL",
"r_loops": 1,
"rows": 10,
@ -435,11 +437,10 @@ ANALYZE
"query_block": {
"select_id": 2,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
"table_name": "B",
"table_name": "b",
"access_type": "ALL",
"r_loops": 1,
"rows": 10,
@ -456,20 +457,21 @@ ANALYZE
}
}
Warnings:
Note 1003 select a, (select max(a) from t0 B where a>6) from t0 A where a<2
Note 1003 select a, (select max(a) from t0 b where a>6) from t0 a where a<2
connection con1;
a (select max(a) from t0 B where a>6)
a (select max(a) from t0 b where a>6)
0 9
1 9
SET debug_dbug=@old_debug;
# Uncorrelated subquery, analyze
set @show_explain_probe_select_id=1;
SET debug_dbug='+d,show_explain_probe_join_exec_end';
analyze select a, (select max(a) from t0 B where a>6) from t0 A where a<2;
analyze select a, (select max(a) from t0 b where a>6) from t0 a where a<2;
connection default;
show analyze format=json for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_loops": 1,
@ -477,7 +479,7 @@ ANALYZE
"nested_loop": [
{
"table": {
"table_name": "A",
"table_name": "a",
"access_type": "ALL",
"r_loops": 1,
"rows": 10,
@ -499,7 +501,7 @@ ANALYZE
"nested_loop": [
{
"table": {
"table_name": "B",
"table_name": "b",
"access_type": "ALL",
"r_loops": 1,
"rows": 10,
@ -518,11 +520,11 @@ ANALYZE
}
}
Warnings:
Note 1003 analyze select a, (select max(a) from t0 B where a>6) from t0 A where a<2
Note 1003 analyze select a, (select max(a) from t0 b where a>6) from t0 a where a<2
connection con1;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10 10.00 100.00 20.00 Using where
2 SUBQUERY B ALL NULL NULL NULL NULL 10 10.00 100.00 30.00 Using where
1 PRIMARY a ALL NULL NULL NULL NULL 10 10.00 100.00 20.00 Using where
2 SUBQUERY b ALL NULL NULL NULL NULL 10 10.00 100.00 30.00 Using where
SET debug_dbug=@old_debug;
# correlated subquery, select, before execution start
set @show_explain_probe_select_id=1;
@ -530,8 +532,9 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start';
select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<2;
connection default;
show analyze format=json for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"nested_loop": [
@ -588,12 +591,12 @@ SET debug_dbug='+d,show_explain_probe_join_exec_end';
select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<2;
connection default;
show analyze format=json for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
@ -616,7 +619,6 @@ ANALYZE
"query_block": {
"select_id": 2,
"r_loops": 2,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
@ -650,8 +652,9 @@ SET debug_dbug='+d,show_explain_probe_join_exec_end';
analyze select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<2;
connection default;
show analyze format=json for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_loops": 1,
@ -731,11 +734,11 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start';
update t2 set dummy=0 where (select max(a) from t0 where t2.a + t0.a <3) >3 ;
connection default;
show analyze FORMAT=JSON for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_total_time_ms": "REPLACED",
"table": {
"update": 1,
"table_name": "t2",
@ -771,11 +774,11 @@ ANALYZE
Warnings:
Note 1003 update t2 set dummy=0 where (select max(a) from t0 where t2.a + t0.a <3) >3
show analyze FORMAT=JSON for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_total_time_ms": "REPLACED",
"table": {
"update": 1,
"table_name": "t2",
@ -790,7 +793,6 @@ ANALYZE
"query_block": {
"select_id": 2,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
@ -824,11 +826,11 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start';
delete from t2 where (select max(a) from t0 where t2.a + t0.a <3) >3 ;
connection default;
show analyze FORMAT=JSON for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_total_time_ms": "REPLACED",
"table": {
"delete": 1,
"table_name": "t2",
@ -864,11 +866,11 @@ ANALYZE
Warnings:
Note 1003 delete from t2 where (select max(a) from t0 where t2.a + t0.a <3) >3
show analyze FORMAT=JSON for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_total_time_ms": "REPLACED",
"table": {
"delete": 1,
"table_name": "t2",
@ -883,7 +885,6 @@ ANALYZE
"query_block": {
"select_id": 2,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
@ -917,12 +918,12 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start';
select t2.a, ((select max(a) from t0 where t2.a + t0.a <3) >3) as SUBQ from t2;
connection default;
show analyze format=json for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
@ -966,12 +967,12 @@ ANALYZE
Warnings:
Note 1003 select t2.a, ((select max(a) from t0 where t2.a + t0.a <3) >3) as SUBQ from t2
show analyze format=json for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
@ -993,7 +994,6 @@ ANALYZE
"query_block": {
"select_id": 2,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
@ -1017,12 +1017,12 @@ ANALYZE
Warnings:
Note 1003 select t2.a, ((select max(a) from t0 where t2.a + t0.a <3) >3) as SUBQ from t2
show analyze format=json for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
@ -1044,7 +1044,6 @@ ANALYZE
"query_block": {
"select_id": 2,
"r_loops": 2,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"table": {
@ -1082,12 +1081,12 @@ set @show_explain_probe_select_id=1;
select * from t0 order by a;
connection default;
show analyze format=JSON for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"nested_loop": [
{
"read_sorted_file": {
@ -1138,12 +1137,12 @@ set @show_explain_probe_select_id=1;
select distinct a from t0;
connection default;
show analyze format=json for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"temporary_table": {
"nested_loop": [
{
@ -1184,12 +1183,12 @@ set @show_explain_probe_select_id=1;
select distinct a from t0;
connection default;
show analyze format=json for $thr2;
ANALYZE
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"temporary_table": {
"nested_loop": [
{