summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Eduardo Oliveira Lizardo <108760288+mariadb-LuisLizardo@users.noreply.github.com>2022-07-18 17:48:01 +0200
committerSergei Petrunia <sergey@mariadb.com>2022-07-25 12:10:31 +0300
commit81f857928da103a63ec9663038b8671b43921123 (patch)
tree93d4bbd174d251167aea96b75d37c70ed10e9204
parent04aab8283022b9a37969df90f44f0c95b98e01d1 (diff)
downloadmariadb-git-bb-10.11-spetrunia.tar.gz
MDEV-28926 Add time spent on query optimizer to JSON ANALYZE (#2193)bb-10.11-spetrunia
* Add query optimizer timer to ANALYZE FORMAT=JSON * Adapt tests and results * Change logic to always close the writer after printing query blocks
-rw-r--r--mysql-test/main/analyze_format_json.result57
-rw-r--r--mysql-test/main/analyze_stmt_orderby.result27
-rw-r--r--mysql-test/main/cte_recursive.result12
-rw-r--r--mysql-test/main/derived_cond_pushdown.result3
-rw-r--r--mysql-test/main/except.result12
-rw-r--r--mysql-test/main/except_all.result12
-rw-r--r--mysql-test/main/explain_json.result18
-rw-r--r--mysql-test/main/explain_json.test1
-rw-r--r--mysql-test/main/explain_json_format_partitions.result9
-rw-r--r--mysql-test/main/intersect.result12
-rw-r--r--mysql-test/main/intersect_all.result12
-rw-r--r--mysql-test/main/order_by.result21
-rw-r--r--mysql-test/main/order_by_pack_big.result12
-rw-r--r--mysql-test/main/rowid_filter.result42
-rw-r--r--mysql-test/main/rowid_filter_innodb.result45
-rw-r--r--mysql-test/main/show_analyze.result3
-rw-r--r--mysql-test/main/show_analyze_json.result66
-rw-r--r--mysql-test/main/subselect4.result3
-rw-r--r--mysql-test/main/subselect_cache.result6
-rw-r--r--mysql-test/main/table_value_constr.result27
-rw-r--r--mysql-test/main/table_value_constr.test9
-rw-r--r--mysql-test/main/win.result3
-rw-r--r--mysql-test/suite/compat/oracle/r/table_value_constr.result27
-rw-r--r--mysql-test/suite/compat/oracle/t/table_value_constr.test9
-rw-r--r--mysql-test/suite/encryption/r/tempfiles_encrypted.result3
-rw-r--r--mysql-test/suite/federated/federatedx_create_handlers.result6
-rw-r--r--sql/sql_explain.cc71
-rw-r--r--sql/sql_explain.h6
28 files changed, 518 insertions, 16 deletions
diff --git a/mysql-test/main/analyze_format_json.result b/mysql-test/main/analyze_format_json.result
index 6c9b8ce2982..9a756782f96 100644
--- a/mysql-test/main/analyze_format_json.result
+++ b/mysql-test/main/analyze_format_json.result
@@ -5,6 +5,9 @@ INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
analyze format=json select * from t0 where a<3;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -38,6 +41,9 @@ analyze format=json
select * from t0, t1 where t1.a=t0.a and t0.a > 9;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -85,6 +91,9 @@ analyze format=json
select * from t0, t1 where t1.a=t0.a and t1.b<4;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -135,6 +144,9 @@ analyze format=json
select * from t1 tbl1, t1 tbl2 where tbl1.b<20 and tbl2.b<60;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -181,6 +193,9 @@ analyze format=json
select * from t1 tbl1, t1 tbl2 where tbl1.b<20 and tbl2.b<60 and tbl1.c > tbl2.c;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -236,6 +251,9 @@ insert into t2 values (0),(1);
analyze format=json select * from t1 straight_join t2 force index(a) where t2.a=t1.a;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -294,6 +312,9 @@ NULL
analyze format=json select * from test.t1 where t1.a<5;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -334,6 +355,9 @@ analyze format=json
update t1 set b=pk;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_total_time_ms": "REPLACED",
@@ -352,6 +376,9 @@ analyze format=json
select * from t1 where pk < 10 and b > 4;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -383,6 +410,9 @@ analyze format=json
delete from t1 where pk < 10 and b > 4;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_total_time_ms": "REPLACED",
@@ -426,6 +456,9 @@ select * from t1, t2 where (t2.key1 between t1.lb1 and t1.rb1) and
(t2.key3=t1.c1 OR t2.key4=t1.c2);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -485,6 +518,9 @@ INSERT INTO t1 select * from t0;
analyze format=json (select * from t1 tbl1 where a<5) union (select * from t1 tbl2 where a in (2,3));
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@@ -561,6 +597,9 @@ insert into t2 select A.a*1000 + B.a, A.a*1000 + B.a from t0 A, t1 B;
analyze format=json select a, max(b) as TOP from t2 group by a having TOP > a;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -598,6 +637,9 @@ ANALYZE
analyze format=json select a, max(b) as TOP from t2 group by a having 1<>2;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -634,6 +676,9 @@ ANALYZE
analyze format=json select a, max(b) as TOP from t2 group by a having 1=2;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"table": {
@@ -645,6 +690,9 @@ ANALYZE
analyze format=json select a, max(b) as TOP from t2 group by a;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -688,6 +736,9 @@ INSERT INTO t2 VALUES (3),(4);
ANALYZE FORMAT=JSON SELECT STRAIGHT_JOIN * FROM t1, t2 WHERE b IN ( SELECT a FROM t1 );
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -771,6 +822,9 @@ WHERE f3 IN ( 1, 2 )
GROUP BY sq ORDER BY gc;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -888,6 +942,9 @@ create table t2 as select * from t1;
analyze format=json select a, (select t2.b from t2 where t2.a<t1.a order by t2.c limit 1) from t1 where t1.a<0;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/analyze_stmt_orderby.result b/mysql-test/main/analyze_stmt_orderby.result
index d4d0fe6b25b..76bc4d964b8 100644
--- a/mysql-test/main/analyze_stmt_orderby.result
+++ b/mysql-test/main/analyze_stmt_orderby.result
@@ -35,6 +35,9 @@ analyze format=json
update t2 set b=b+1 order by b limit 5;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_total_time_ms": "REPLACED",
@@ -89,6 +92,9 @@ analyze format=json
update t2 set a=a+1 where a<10;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_total_time_ms": "REPLACED",
@@ -137,6 +143,9 @@ analyze format=json
delete from t2 order by b limit 5;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_total_time_ms": "REPLACED",
@@ -208,6 +217,9 @@ analyze format=json
select * from t0,t2 where t2.a=t0.a order by t2.b limit 4;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -308,6 +320,9 @@ analyze format=json
select * from t0,t2 where t2.a=t0.a order by t0.a limit 4;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -376,6 +391,9 @@ analyze format=json
select MAX(b) from t2 where mod(a,2)=0 group by c;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -436,6 +454,9 @@ analyze format=json
select distinct max(t3.b) Q from t0, t3 where t0.a=t3.a group by t0.a order by null;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -500,6 +521,9 @@ where t5.a=t6.a and t6.b > 0 and t5.a <= 5
group by t5.a order by sum limit 1;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -635,6 +659,9 @@ analyze format=json
select col1 f1, col2 f2, col1 f3 from t2 group by f1;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result
index bb01d0d69a2..39f6944914a 100644
--- a/mysql-test/main/cte_recursive.result
+++ b/mysql-test/main/cte_recursive.result
@@ -2455,6 +2455,9 @@ select counter+1 from src where counter<10
) select * from src;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -3861,6 +3864,9 @@ where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2'
select a2 from cte);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -4120,6 +4126,9 @@ select t1.* from t1, r_cte as r where t1.c = r.a )
select 0 as b FROM dual union all select b FROM r_cte as t;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"query_specifications": [
@@ -4285,6 +4294,9 @@ select 0 as b FROM dual union all select b FROM r_cte as t)
select * from t1 as tt;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result
index 9bbd32a9c84..e07f2550297 100644
--- a/mysql-test/main/derived_cond_pushdown.result
+++ b/mysql-test/main/derived_cond_pushdown.result
@@ -19643,6 +19643,9 @@ CREATE VIEW v1 AS SELECT a FROM t1 UNION VALUES (3),(4);
ANALYZE FORMAT=JSON SELECT * from v1 WHERE a=3;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/except.result b/mysql-test/main/except.result
index c88b91991f2..302bfbdd22d 100644
--- a/mysql-test/main/except.result
+++ b/mysql-test/main/except.result
@@ -72,6 +72,9 @@ EXPLAIN
ANALYZE format=json (select a,b from t1) except (select c,d from t2);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<except1,2>",
@@ -131,6 +134,9 @@ ANALYZE
ANALYZE format=json select * from ((select a,b from t1) except (select c,d from t2)) a;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -336,6 +342,9 @@ EXPLAIN
ANALYZE format=json (select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<except1,2>",
@@ -434,6 +443,9 @@ ANALYZE format=json select * from ((select a,b,e,f from t1,t3) except
(select c,d,g,h from t2,t4)) a;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/except_all.result b/mysql-test/main/except_all.result
index f74aeda5ab2..bdb49cdcebb 100644
--- a/mysql-test/main/except_all.result
+++ b/mysql-test/main/except_all.result
@@ -115,6 +115,9 @@ Note 1003 /* select#1 */ select `a`.`a` AS `a`,`a`.`b` AS `b` from ((/* select#2
ANALYZE format=json select * from ((select a,b from t1) except all (select c,d from t2)) a;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -196,6 +199,9 @@ ANALYZE
ANALYZE format=json select * from ((select a from t1) except all (select c from t2)) a;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -463,6 +469,9 @@ EXPLAIN
ANALYZE format=json (select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<except1,2>",
@@ -560,6 +569,9 @@ ANALYZE
ANALYZE format=json select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/explain_json.result b/mysql-test/main/explain_json.result
index cf1aa172146..3c3c0688ab8 100644
--- a/mysql-test/main/explain_json.result
+++ b/mysql-test/main/explain_json.result
@@ -1148,6 +1148,9 @@ EXPLAIN
analyze format=json select count(distinct b) from t1 group by a;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1446,6 +1449,9 @@ analyze format=json
select * from t1;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"table": {
@@ -1497,6 +1503,9 @@ analyze format=json
select * from t1 left join t2 on t2.pk > 10 and t2.pk < 0;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1576,6 +1585,9 @@ analyze format=json
select * from t1 left join t2 on t2.pk=t1.a where t2.pk is null;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1664,6 +1676,9 @@ analyze format=json
select distinct t1.a from t1 join t2 on t2.pk=t1.a;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1770,6 +1785,9 @@ analyze format=json
select * from t3,t4 where t3.a=t4.a and (t4.b+1 <= t3.b+1);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/explain_json.test b/mysql-test/main/explain_json.test
index 07e4ec09ad4..17e2da4754c 100644
--- a/mysql-test/main/explain_json.test
+++ b/mysql-test/main/explain_json.test
@@ -329,6 +329,7 @@ explain
select * from t1;
explain format=json
select * from t1;
+--source include/analyze-format.inc
analyze format=json
select * from t1;
drop table t1;
diff --git a/mysql-test/main/explain_json_format_partitions.result b/mysql-test/main/explain_json_format_partitions.result
index f164006d756..b76fe29625e 100644
--- a/mysql-test/main/explain_json_format_partitions.result
+++ b/mysql-test/main/explain_json_format_partitions.result
@@ -29,6 +29,9 @@ EXPLAIN
analyze format=json select * from t1 where a in (2,3,4);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -55,6 +58,9 @@ ANALYZE
analyze format=json update t1 set a=a+10 where a in (2,3,4);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_total_time_ms": "REPLACED",
@@ -76,6 +82,9 @@ ANALYZE
analyze format=json delete from t1 where a in (20,30,40);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_total_time_ms": "REPLACED",
diff --git a/mysql-test/main/intersect.result b/mysql-test/main/intersect.result
index c6890e464a8..8334bd3ff0b 100644
--- a/mysql-test/main/intersect.result
+++ b/mysql-test/main/intersect.result
@@ -102,6 +102,9 @@ EXPLAIN
ANALYZE format=json (select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<intersect1,2,3>",
@@ -184,6 +187,9 @@ ANALYZE
ANALYZE format=json select * from ((select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3)) a;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -388,6 +394,9 @@ EXPLAIN
ANALYZE format=json (select a,b from t1) intersect (select c,e from t2,t3);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<intersect1,2>",
@@ -466,6 +475,9 @@ ANALYZE
ANALYZE format=json select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/intersect_all.result b/mysql-test/main/intersect_all.result
index 4589d226fa3..e14844ca86e 100644
--- a/mysql-test/main/intersect_all.result
+++ b/mysql-test/main/intersect_all.result
@@ -114,6 +114,9 @@ EXPLAIN
ANALYZE format=json (select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<intersect1,2,3>",
@@ -196,6 +199,9 @@ ANALYZE
ANALYZE format=json select * from ((select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3)) a;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -419,6 +425,9 @@ EXPLAIN
ANALYZE format=json (select a,b from t1) intersect all (select c,e from t2,t3);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<intersect1,2>",
@@ -497,6 +506,9 @@ ANALYZE
ANALYZE format=json select * from ((select a,b from t1) intersect all (select c,e from t2,t3)) a;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result
index b6345cd142e..1311f42dac2 100644
--- a/mysql-test/main/order_by.result
+++ b/mysql-test/main/order_by.result
@@ -3396,6 +3396,9 @@ INSERT INTO t1 SELECT seq,seq from seq_1_to_100;
ANALYZE FORMAT=JSON SELECT * FROM t1 ORDER BY a LIMIT 5;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -3750,6 +3753,9 @@ insert into t1 select seq, seq, seq from seq_1_to_100;
ANALYZE FORMAT=JSON select * from t1 order by a,b,c;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -3913,6 +3919,9 @@ analyze format=json
select a, substr(b, @save_max_sort_length+1) from t1 order by b desc;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -3959,6 +3968,9 @@ insert into t1 values ('def', 4, 4) , ('efg', 5, 5), ('fgh', 6, 6);
ANALYZE FORMAT=JSON select a, b, c from t1 order by a, b;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -4011,6 +4023,9 @@ Warning 1292 Truncated incorrect max_sort_length value: '5'
ANALYZE FORMAT=JSON select a, b, c from t1 order by a, b;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -4077,6 +4092,9 @@ a b
analyze format=json select * from t1 order by a;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -4256,6 +4274,9 @@ ANALYZE FORMAT=JSON
SELECT (SELECT sum(t2.b) FROM t2 WHERE t1.b=t2.b GROUP BY t2.a) FROM t1;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/order_by_pack_big.result b/mysql-test/main/order_by_pack_big.result
index e34b1a4a90a..6b33d7d8202 100644
--- a/mysql-test/main/order_by_pack_big.result
+++ b/mysql-test/main/order_by_pack_big.result
@@ -89,6 +89,9 @@ FROM t3
GROUP BY x;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -250,6 +253,9 @@ FROM t3
GROUP BY x;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -409,6 +415,9 @@ set sort_buffer_size= 2097152;
ANALYZE FORMAT=JSON SELECT id, names, address FROM t3 ORDER BY names, address;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -462,6 +471,9 @@ set sort_buffer_size= 1097152;
ANALYZE FORMAT=JSON SELECT id, names, address FROM t3 ORDER BY names, address;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result
index 10662f0edfa..6eb0a48d4d2 100644
--- a/mysql-test/main/rowid_filter.result
+++ b/mysql-test/main/rowid_filter.result
@@ -113,6 +113,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
l_quantity > 45;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -256,6 +259,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
l_quantity > 45;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -419,6 +425,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
o_totalprice between 200000 and 230000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -561,6 +570,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
o_totalprice between 200000 and 230000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -713,6 +725,9 @@ l_quantity > 45 AND
o_totalprice between 180000 and 230000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -881,6 +896,9 @@ l_quantity > 45 AND
o_totalprice between 180000 and 230000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1027,6 +1045,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
o_totalprice between 200000 and 230000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1195,6 +1216,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
o_totalprice between 200000 and 230000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1368,6 +1392,9 @@ l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
o_totalprice BETWEEN 200000 AND 250000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1502,6 +1529,9 @@ l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
o_totalprice BETWEEN 200000 AND 250000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1642,6 +1672,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1777,6 +1810,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1920,6 +1956,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -2065,6 +2104,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result
index 90a119aa8c8..90e14ea10f6 100644
--- a/mysql-test/main/rowid_filter_innodb.result
+++ b/mysql-test/main/rowid_filter_innodb.result
@@ -116,6 +116,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
l_quantity > 45;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -259,6 +262,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
l_quantity > 45;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -415,6 +421,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
o_totalprice between 200000 and 230000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -547,6 +556,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
o_totalprice between 200000 and 230000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -692,6 +704,9 @@ l_quantity > 45 AND
o_totalprice between 180000 and 230000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -848,6 +863,9 @@ l_quantity > 45 AND
o_totalprice between 180000 and 230000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -987,6 +1005,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
o_totalprice between 200000 and 230000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1145,6 +1166,9 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
o_totalprice between 200000 and 230000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1319,6 +1343,9 @@ l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
o_totalprice BETWEEN 200000 AND 250000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1453,6 +1480,9 @@ l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
o_totalprice BETWEEN 200000 AND 250000;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1593,6 +1623,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1728,6 +1761,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1871,6 +1907,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -2016,6 +2055,9 @@ o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -3052,6 +3094,9 @@ fi.fh in (6311439873746261694,-397087483897438286,
8518228073041491534,-5420422472375069774);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/show_analyze.result b/mysql-test/main/show_analyze.result
index 56dac487117..5595fadd60b 100644
--- a/mysql-test/main/show_analyze.result
+++ b/mysql-test/main/show_analyze.result
@@ -400,6 +400,9 @@ ANALYZE format=json
SELECT 1 FROM t1 GROUP BY convert_tz('1969-12-31 22:00:00',a,'+10:00');
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/show_analyze_json.result b/mysql-test/main/show_analyze_json.result
index dc8ae2aa66b..8506c4b9402 100644
--- a/mysql-test/main/show_analyze_json.result
+++ b/mysql-test/main/show_analyze_json.result
@@ -39,6 +39,9 @@ show analyze format=JSON for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -69,6 +72,9 @@ show analyze format=json for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -100,6 +106,9 @@ show analyze format=json for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -138,6 +147,9 @@ show analyze FORMAT= json for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@@ -204,6 +216,9 @@ show analyze format=JSON for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@@ -271,6 +286,9 @@ show analyze format=json for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@@ -340,6 +358,9 @@ show analyze FORMAT=JSON for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@@ -415,6 +436,9 @@ show analyze format=json for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -472,6 +496,9 @@ show analyze format=json for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -535,6 +562,9 @@ show analyze format=json for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"nested_loop": [
@@ -594,6 +624,9 @@ show analyze format=json for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -655,6 +688,9 @@ show analyze format=json for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -737,6 +773,9 @@ show analyze FORMAT=JSON for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"table": {
@@ -777,6 +816,9 @@ show analyze FORMAT=JSON for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"table": {
@@ -829,6 +871,9 @@ show analyze FORMAT=JSON for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"table": {
@@ -869,6 +914,9 @@ show analyze FORMAT=JSON for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"table": {
@@ -921,6 +969,9 @@ show analyze format=json for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -970,6 +1021,9 @@ show analyze format=json for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1020,6 +1074,9 @@ show analyze format=json for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1084,6 +1141,9 @@ show analyze format=JSON for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1140,6 +1200,9 @@ show analyze format=json for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -1186,6 +1249,9 @@ show analyze format=json for $thr2;
SHOW ANALYZE
{
"r_query_time_in_progress_ms": "REPLACED",
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result
index c23352c6767..6f0a594efb8 100644
--- a/mysql-test/main/subselect4.result
+++ b/mysql-test/main/subselect4.result
@@ -2917,6 +2917,9 @@ SELECT DISTINCT
FROM t1;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/subselect_cache.result b/mysql-test/main/subselect_cache.result
index 132e870a860..d39023b8a84 100644
--- a/mysql-test/main/subselect_cache.result
+++ b/mysql-test/main/subselect_cache.result
@@ -44,6 +44,9 @@ analyze format=json
select a, (select d from t2 where b=c) from t1;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
@@ -98,6 +101,9 @@ analyze format=json
select a, (select d from t2 where b=c), (select d from t2 where b=c union select 1 order by 1 limit 1) from t1;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/main/table_value_constr.result b/mysql-test/main/table_value_constr.result
index b90b5c86c15..e6d973d53ee 100644
--- a/mysql-test/main/table_value_constr.result
+++ b/mysql-test/main/table_value_constr.result
@@ -1667,6 +1667,9 @@ analyze format=json
values (1,2);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"query_specifications": [
@@ -1713,6 +1716,9 @@ union
values (1,2),(3,4);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@@ -1747,6 +1753,9 @@ union
select 1,2;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@@ -1781,6 +1790,9 @@ union
values (1,2),(3,4);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@@ -1828,6 +1840,9 @@ union
values (1,2);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2,3>",
@@ -1894,6 +1909,9 @@ union all
select 1,2;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"query_specifications": [
@@ -1924,6 +1942,9 @@ union
values (1,2),(3,4);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@@ -1958,6 +1979,9 @@ union all
values (1,2),(3,4);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"query_specifications": [
@@ -2000,6 +2024,9 @@ union all
values (1,2);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"query_specifications": [
diff --git a/mysql-test/main/table_value_constr.test b/mysql-test/main/table_value_constr.test
index 05aca941350..b34474bfcbb 100644
--- a/mysql-test/main/table_value_constr.test
+++ b/mysql-test/main/table_value_constr.test
@@ -932,6 +932,7 @@ values (1,2);
analyze
values (1,2);
+--source include/analyze-format.inc
analyze format=json
values (1,2);
@@ -952,16 +953,19 @@ values (5,6)
union
values (1,2),(3,4);
+--source include/analyze-format.inc
analyze format=json
select 1,2
union
values (1,2),(3,4);
+--source include/analyze-format.inc
analyze format=json
values (1,2),(3,4)
union
select 1,2;
+--source include/analyze-format.inc
analyze format=json
values (5,6)
union
@@ -974,6 +978,7 @@ values (3,4)
union
values (1,2);
+--source include/analyze-format.inc
analyze format=json
select 1,2
union
@@ -998,16 +1003,19 @@ values (1,2)
union all
values (1,2),(3,4);
+--source include/analyze-format.inc
analyze format=json
values (1,2),(3,4)
union all
select 1,2;
+--source include/analyze-format.inc
analyze format=json
select 1,2
union
values (1,2),(3,4);
+--source include/analyze-format.inc
analyze format=json
values (1,2)
union all
@@ -1020,6 +1028,7 @@ values (3,4)
union all
values (1,2);
+--source include/analyze-format.inc
analyze format=json
select 1,2
union all
diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result
index c8be04023ea..95ba6372802 100644
--- a/mysql-test/main/win.result
+++ b/mysql-test/main/win.result
@@ -3822,6 +3822,9 @@ INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
ANALYZE FORMAT=JSON SELECT row_number() OVER() FROM t1;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/suite/compat/oracle/r/table_value_constr.result b/mysql-test/suite/compat/oracle/r/table_value_constr.result
index 365edaa7757..af071433d0f 100644
--- a/mysql-test/suite/compat/oracle/r/table_value_constr.result
+++ b/mysql-test/suite/compat/oracle/r/table_value_constr.result
@@ -1665,6 +1665,9 @@ analyze format=json
values (1,2);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"query_specifications": [
@@ -1711,6 +1714,9 @@ union
values (1,2),(3,4);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@@ -1745,6 +1751,9 @@ union
select 1,2;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@@ -1779,6 +1788,9 @@ union
values (1,2),(3,4);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@@ -1826,6 +1838,9 @@ union
values (1,2);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2,3>",
@@ -1892,6 +1907,9 @@ union all
select 1,2;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"query_specifications": [
@@ -1922,6 +1940,9 @@ union
values (1,2),(3,4);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"table_name": "<union1,2>",
@@ -1956,6 +1977,9 @@ union all
values (1,2),(3,4);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"query_specifications": [
@@ -1998,6 +2022,9 @@ union all
values (1,2);
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"union_result": {
"query_specifications": [
diff --git a/mysql-test/suite/compat/oracle/t/table_value_constr.test b/mysql-test/suite/compat/oracle/t/table_value_constr.test
index 4e0dcc05514..ca3c40bb7f9 100644
--- a/mysql-test/suite/compat/oracle/t/table_value_constr.test
+++ b/mysql-test/suite/compat/oracle/t/table_value_constr.test
@@ -934,6 +934,7 @@ values (1,2);
analyze
values (1,2);
+--source include/analyze-format.inc
analyze format=json
values (1,2);
@@ -954,16 +955,19 @@ values (5,6)
union
values (1,2),(3,4);
+--source include/analyze-format.inc
analyze format=json
select 1,2
union
values (1,2),(3,4);
+--source include/analyze-format.inc
analyze format=json
values (1,2),(3,4)
union
select 1,2;
+--source include/analyze-format.inc
analyze format=json
values (5,6)
union
@@ -976,6 +980,7 @@ values (3,4)
union
values (1,2);
+--source include/analyze-format.inc
analyze format=json
select 1,2
union
@@ -1000,16 +1005,19 @@ values (1,2)
union all
values (1,2),(3,4);
+--source include/analyze-format.inc
analyze format=json
values (1,2),(3,4)
union all
select 1,2;
+--source include/analyze-format.inc
analyze format=json
select 1,2
union
values (1,2),(3,4);
+--source include/analyze-format.inc
analyze format=json
values (1,2)
union all
@@ -1022,6 +1030,7 @@ values (3,4)
union all
values (1,2);
+--source include/analyze-format.inc
analyze format=json
select 1,2
union all
diff --git a/mysql-test/suite/encryption/r/tempfiles_encrypted.result b/mysql-test/suite/encryption/r/tempfiles_encrypted.result
index 87f36345027..b934574e621 100644
--- a/mysql-test/suite/encryption/r/tempfiles_encrypted.result
+++ b/mysql-test/suite/encryption/r/tempfiles_encrypted.result
@@ -3828,6 +3828,9 @@ INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
ANALYZE FORMAT=JSON SELECT row_number() OVER() FROM t1;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result
index 6dcd53e77c7..8a82df0ddfc 100644
--- a/mysql-test/suite/federated/federatedx_create_handlers.result
+++ b/mysql-test/suite/federated/federatedx_create_handlers.result
@@ -117,6 +117,9 @@ ANALYZE FORMAT=JSON
SELECT id FROM federated.t1 WHERE id < 5;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"table": {
@@ -223,6 +226,9 @@ FROM federated.t2 GROUP BY name)) t
WHERE federated.t3.name=t.name;
ANALYZE
{
+ "query_optimization": {
+ "r_total_time_ms": "REPLACED"
+ },
"query_block": {
"select_id": 1,
"r_loops": 1,
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 7c3918bfd20..ede486fc297 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -44,9 +44,10 @@ static void append_item_to_str(String *out, Item *item, bool no_tmp_tbl);
Explain_query::Explain_query(THD *thd_arg, MEM_ROOT *root) :
mem_root(root), upd_del_plan(nullptr), insert_plan(nullptr),
- unions(root), selects(root), stmt_thd(thd_arg), apc_enabled(false),
+ unions(root), selects(root), stmt_thd(thd_arg), apc_enabled(false),
operations(0)
{
+ optimization_time_tracker.start_tracking(stmt_thd);
}
static void print_json_array(Json_writer *writer,
@@ -154,6 +155,8 @@ void Explain_query::add_upd_del_plan(Explain_update *upd_del_plan_arg)
void Explain_query::query_plan_ready()
{
+ optimization_time_tracker.stop_tracking(stmt_thd);
+
if (!apc_enabled)
stmt_thd->apc_target.enable();
apc_enabled= true;
@@ -256,44 +259,80 @@ int Explain_query::print_explain_json(select_result_sink *output,
#endif
writer.start_object();
- if (is_analyze && query_time_in_progress_ms > 0)
- writer.add_member("r_query_time_in_progress_ms").
- add_ull(query_time_in_progress_ms);
-
+
/*
If we are printing ANALYZE FORMAT=JSON output, take into account that
query's temporary tables have already been freed. See sql_explain.h,
sql_explain.h:ExplainDataStructureLifetime for details.
*/
if (is_analyze)
- is_show_cmd= true;
+ {
+ if (query_time_in_progress_ms > 0){
+ writer.add_member("r_query_time_in_progress_ms").
+ add_ull(query_time_in_progress_ms);
+ }
+
+ print_query_optimization_json(&writer);
+ is_show_cmd = true;
+ }
+
+ bool plan_found = print_query_blocks_json(&writer, is_analyze, is_show_cmd);
+
+ writer.end_object();
+
+ if( plan_found )
+ {
+ send_explain_json_to_output(&writer, output);
+ }
+
+ return 0;
+}
+void Explain_query::print_query_optimization_json(Json_writer *writer)
+{
+ if (optimization_time_tracker.has_timed_statistics())
+ {
+ // if more timers are added, move the query_optimization member
+ // outside the if statement
+ writer->add_member("query_optimization").start_object();
+ writer->add_member("r_total_time_ms").
+ add_double(optimization_time_tracker.get_time_ms());
+ writer->end_object();
+ }
+}
+
+bool Explain_query::print_query_blocks_json(Json_writer *writer,
+ const bool is_analyze,
+ const bool is_show_cmd)
+{
if (upd_del_plan)
- upd_del_plan->print_explain_json(this, &writer, is_analyze, is_show_cmd);
+ upd_del_plan->print_explain_json(this, writer, is_analyze, is_show_cmd);
else if (insert_plan)
- insert_plan->print_explain_json(this, &writer, is_analyze, is_show_cmd);
+ insert_plan->print_explain_json(this, writer, is_analyze, is_show_cmd);
else
{
- /* Start printing from node with id=1 */
+ /* Start printing from root node with id=1 */
Explain_node *node= get_node(1);
if (!node)
- return 1; /* No query plan */
- node->print_explain_json(this, &writer, is_analyze, is_show_cmd);
+ return false; /* No query plan */
+ node->print_explain_json(this, writer, is_analyze, is_show_cmd);
}
- writer.end_object();
+ return true;
+}
+void Explain_query::send_explain_json_to_output(Json_writer *writer,
+ select_result_sink *output)
+{
CHARSET_INFO *cs= system_charset_info;
List<Item> item_list;
- const String *buf= writer.output.get_string();
+ const String *buf= writer->output.get_string();
THD *thd= output->thd;
item_list.push_back(new (thd->mem_root)
Item_string(thd, buf->ptr(), buf->length(), cs),
thd->mem_root);
output->send_data(item_list);
- return 0;
-}
-
+}
bool print_explain_for_slow_log(LEX *lex, THD *thd, String *str)
{
diff --git a/sql/sql_explain.h b/sql/sql_explain.h
index 919d51aef8b..38c5c3e6595 100644
--- a/sql/sql_explain.h
+++ b/sql/sql_explain.h
@@ -512,6 +512,10 @@ public:
Explain_update *get_upd_del_plan() { return upd_del_plan; }
private:
+ bool print_query_blocks_json(Json_writer *writer, const bool is_analyze, const bool is_show_cmd);
+ void print_query_optimization_json(Json_writer *writer);
+ void send_explain_json_to_output(Json_writer *writer, select_result_sink *output);
+
/* Explain_delete inherits from Explain_update */
Explain_update *upd_del_plan;
@@ -533,6 +537,8 @@ private:
#ifndef DBUG_OFF
bool can_print_json= false;
#endif
+
+ Exec_time_tracker optimization_time_tracker;
};