Skip to content

Commit aae3233

Browse files
committed
MDEV-34041 Display additional information for materialized subqueries in EXPLAIN/ANALYZE FORMAT=JSON
This commits adds the "materialization" block to the output of EXPLAIN/ANALYZE FORMAT=JSON when materialized subqueries are involved into processing. In the case of ANALYZE additional runtime information is displayed, such as: - chosen strategy of materialization - number of partial match/index lookup loops - sizes of partial match buffers
1 parent a5e4c34 commit aae3233

14 files changed

+2024
-615
lines changed

mysql-test/include/analyze-format.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# The time on ANALYSE FORMAT=JSON is rather variable
22

3-
--replace_regex /("(r_[a-z_]*_time_ms|r_buffer_size)": )[^, \n]*/\1"REPLACED"/
3+
--replace_regex /("(r_[a-z_]*_time_ms|r_buffer_size|r_partial_match_buffer_size)": )[^, \n]*/\1"REPLACED"/

mysql-test/main/analyze_format_json.result

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -659,20 +659,24 @@ ANALYZE
659659
},
660660
"subqueries": [
661661
{
662-
"query_block": {
663-
"select_id": 2,
664-
"r_loops": 1,
665-
"r_total_time_ms": "REPLACED",
666-
"table": {
667-
"table_name": "t1",
668-
"access_type": "ALL",
662+
"materialization": {
663+
"r_strategy": "index_lookup",
664+
"r_loops": 2,
665+
"query_block": {
666+
"select_id": 2,
669667
"r_loops": 1,
670-
"rows": 2,
671-
"r_rows": 2,
672-
"r_table_time_ms": "REPLACED",
673-
"r_other_time_ms": "REPLACED",
674-
"filtered": 100,
675-
"r_filtered": 100
668+
"r_total_time_ms": "REPLACED",
669+
"table": {
670+
"table_name": "t1",
671+
"access_type": "ALL",
672+
"r_loops": 1,
673+
"rows": 2,
674+
"r_rows": 2,
675+
"r_table_time_ms": "REPLACED",
676+
"r_other_time_ms": "REPLACED",
677+
"filtered": 100,
678+
"r_filtered": 100
679+
}
676680
}
677681
}
678682
}

mysql-test/main/derived_cond_pushdown.result

Lines changed: 118 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -7671,10 +7671,12 @@ EXPLAIN
76717671
"filtered": 100,
76727672
"materialized": {
76737673
"unique": 1,
7674-
"query_block": {
7675-
"select_id": 2,
7676-
"table": {
7677-
"message": "Select tables optimized away"
7674+
"materialization": {
7675+
"query_block": {
7676+
"select_id": 2,
7677+
"table": {
7678+
"message": "Select tables optimized away"
7679+
}
76787680
}
76797681
}
76807682
}
@@ -7731,10 +7733,12 @@ EXPLAIN
77317733
"filtered": 100,
77327734
"materialized": {
77337735
"unique": 1,
7734-
"query_block": {
7735-
"select_id": 2,
7736-
"table": {
7737-
"message": "Select tables optimized away"
7736+
"materialization": {
7737+
"query_block": {
7738+
"select_id": 2,
7739+
"table": {
7740+
"message": "Select tables optimized away"
7741+
}
77387742
}
77397743
}
77407744
}
@@ -7815,10 +7819,12 @@ EXPLAIN
78157819
"filtered": 100,
78167820
"materialized": {
78177821
"unique": 1,
7818-
"query_block": {
7819-
"select_id": 3,
7820-
"table": {
7821-
"message": "Select tables optimized away"
7822+
"materialization": {
7823+
"query_block": {
7824+
"select_id": 3,
7825+
"table": {
7826+
"message": "Select tables optimized away"
7827+
}
78227828
}
78237829
}
78247830
}
@@ -7872,10 +7878,12 @@ EXPLAIN
78727878
"filtered": 100,
78737879
"materialized": {
78747880
"unique": 1,
7875-
"query_block": {
7876-
"select_id": 3,
7877-
"table": {
7878-
"message": "Select tables optimized away"
7881+
"materialization": {
7882+
"query_block": {
7883+
"select_id": 3,
7884+
"table": {
7885+
"message": "Select tables optimized away"
7886+
}
78797887
}
78807888
}
78817889
}
@@ -7924,10 +7932,12 @@ EXPLAIN
79247932
"filtered": 100,
79257933
"materialized": {
79267934
"unique": 1,
7927-
"query_block": {
7928-
"select_id": 3,
7929-
"table": {
7930-
"message": "Select tables optimized away"
7935+
"materialization": {
7936+
"query_block": {
7937+
"select_id": 3,
7938+
"table": {
7939+
"message": "Select tables optimized away"
7940+
}
79317941
}
79327942
}
79337943
}
@@ -7976,10 +7986,12 @@ EXPLAIN
79767986
"filtered": 100,
79777987
"materialized": {
79787988
"unique": 1,
7979-
"query_block": {
7980-
"select_id": 3,
7981-
"table": {
7982-
"message": "Select tables optimized away"
7989+
"materialization": {
7990+
"query_block": {
7991+
"select_id": 3,
7992+
"table": {
7993+
"message": "Select tables optimized away"
7994+
}
79837995
}
79847996
}
79857997
}
@@ -8030,10 +8042,12 @@ EXPLAIN
80308042
"filtered": 100,
80318043
"materialized": {
80328044
"unique": 1,
8033-
"query_block": {
8034-
"select_id": 3,
8035-
"table": {
8036-
"message": "Select tables optimized away"
8045+
"materialization": {
8046+
"query_block": {
8047+
"select_id": 3,
8048+
"table": {
8049+
"message": "Select tables optimized away"
8050+
}
80378051
}
80388052
}
80398053
}
@@ -8082,10 +8096,12 @@ EXPLAIN
80828096
"filtered": 100,
80838097
"materialized": {
80848098
"unique": 1,
8085-
"query_block": {
8086-
"select_id": 3,
8087-
"table": {
8088-
"message": "Select tables optimized away"
8099+
"materialization": {
8100+
"query_block": {
8101+
"select_id": 3,
8102+
"table": {
8103+
"message": "Select tables optimized away"
8104+
}
80898105
}
80908106
}
80918107
}
@@ -8134,10 +8150,12 @@ EXPLAIN
81348150
"filtered": 100,
81358151
"materialized": {
81368152
"unique": 1,
8137-
"query_block": {
8138-
"select_id": 3,
8139-
"table": {
8140-
"message": "Select tables optimized away"
8153+
"materialization": {
8154+
"query_block": {
8155+
"select_id": 3,
8156+
"table": {
8157+
"message": "Select tables optimized away"
8158+
}
81418159
}
81428160
}
81438161
}
@@ -8223,10 +8241,12 @@ EXPLAIN
82238241
},
82248242
"subqueries": [
82258243
{
8226-
"query_block": {
8227-
"select_id": 2,
8228-
"table": {
8229-
"message": "Impossible WHERE"
8244+
"materialization": {
8245+
"query_block": {
8246+
"select_id": 2,
8247+
"table": {
8248+
"message": "Impossible WHERE"
8249+
}
82308250
}
82318251
}
82328252
}
@@ -9294,27 +9314,29 @@ EXPLAIN
92949314
"filtered": 100,
92959315
"materialized": {
92969316
"unique": 1,
9297-
"query_block": {
9298-
"select_id": 2,
9299-
"temporary_table": {
9300-
"table": {
9301-
"table_name": "<derived3>",
9302-
"access_type": "ALL",
9303-
"rows": 5,
9304-
"filtered": 100,
9305-
"attached_condition": "d_tab.e > 1",
9306-
"materialized": {
9307-
"query_block": {
9308-
"select_id": 3,
9309-
"filesort": {
9310-
"sort_key": "t2.e",
9311-
"temporary_table": {
9312-
"table": {
9313-
"table_name": "t2",
9314-
"access_type": "ALL",
9315-
"rows": 5,
9316-
"filtered": 100,
9317-
"attached_condition": "t2.e > 1"
9317+
"materialization": {
9318+
"query_block": {
9319+
"select_id": 2,
9320+
"temporary_table": {
9321+
"table": {
9322+
"table_name": "<derived3>",
9323+
"access_type": "ALL",
9324+
"rows": 5,
9325+
"filtered": 100,
9326+
"attached_condition": "d_tab.e > 1",
9327+
"materialized": {
9328+
"query_block": {
9329+
"select_id": 3,
9330+
"filesort": {
9331+
"sort_key": "t2.e",
9332+
"temporary_table": {
9333+
"table": {
9334+
"table_name": "t2",
9335+
"access_type": "ALL",
9336+
"rows": 5,
9337+
"filtered": 100,
9338+
"attached_condition": "t2.e > 1"
9339+
}
93189340
}
93199341
}
93209342
}
@@ -9396,27 +9418,29 @@ EXPLAIN
93969418
"filtered": 100,
93979419
"materialized": {
93989420
"unique": 1,
9399-
"query_block": {
9400-
"select_id": 2,
9401-
"temporary_table": {
9402-
"table": {
9403-
"table_name": "<derived3>",
9404-
"access_type": "ALL",
9405-
"rows": 5,
9406-
"filtered": 100,
9407-
"attached_condition": "d_tab.max_f > 20",
9408-
"materialized": {
9409-
"query_block": {
9410-
"select_id": 3,
9411-
"having_condition": "max_f > 20",
9412-
"filesort": {
9413-
"sort_key": "t2.e",
9414-
"temporary_table": {
9415-
"table": {
9416-
"table_name": "t2",
9417-
"access_type": "ALL",
9418-
"rows": 5,
9419-
"filtered": 100
9421+
"materialization": {
9422+
"query_block": {
9423+
"select_id": 2,
9424+
"temporary_table": {
9425+
"table": {
9426+
"table_name": "<derived3>",
9427+
"access_type": "ALL",
9428+
"rows": 5,
9429+
"filtered": 100,
9430+
"attached_condition": "d_tab.max_f > 20",
9431+
"materialized": {
9432+
"query_block": {
9433+
"select_id": 3,
9434+
"having_condition": "max_f > 20",
9435+
"filesort": {
9436+
"sort_key": "t2.e",
9437+
"temporary_table": {
9438+
"table": {
9439+
"table_name": "t2",
9440+
"access_type": "ALL",
9441+
"rows": 5,
9442+
"filtered": 100
9443+
}
94209444
}
94219445
}
94229446
}
@@ -10826,16 +10850,18 @@ EXPLAIN
1082610850
"attached_condition": "t4.c = `<subquery2>`.`sum(b)`",
1082710851
"materialized": {
1082810852
"unique": 1,
10829-
"query_block": {
10830-
"select_id": 2,
10831-
"having_condition": "`f1(a)` > 1 and `sum(b)` > 123",
10832-
"temporary_table": {
10833-
"table": {
10834-
"table_name": "t1",
10835-
"access_type": "ALL",
10836-
"rows": 3,
10837-
"filtered": 100,
10838-
"attached_condition": "t1.a + 1 > 10"
10853+
"materialization": {
10854+
"query_block": {
10855+
"select_id": 2,
10856+
"having_condition": "`f1(a)` > 1 and `sum(b)` > 123",
10857+
"temporary_table": {
10858+
"table": {
10859+
"table_name": "t1",
10860+
"access_type": "ALL",
10861+
"rows": 3,
10862+
"filtered": 100,
10863+
"attached_condition": "t1.a + 1 > 10"
10864+
}
1083910865
}
1084010866
}
1084110867
}

mysql-test/main/explain_json.result

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -574,14 +574,16 @@ EXPLAIN
574574
"filtered": 100,
575575
"materialized": {
576576
"unique": 1,
577-
"query_block": {
578-
"select_id": 2,
579-
"temporary_table": {
580-
"table": {
581-
"table_name": "t1",
582-
"access_type": "ALL",
583-
"rows": 10,
584-
"filtered": 100
577+
"materialization": {
578+
"query_block": {
579+
"select_id": 2,
580+
"temporary_table": {
581+
"table": {
582+
"table_name": "t1",
583+
"access_type": "ALL",
584+
"rows": 10,
585+
"filtered": 100
586+
}
585587
}
586588
}
587589
}
@@ -906,13 +908,15 @@ EXPLAIN
906908
},
907909
"subqueries": [
908910
{
909-
"query_block": {
910-
"select_id": 2,
911-
"table": {
912-
"table_name": "t2",
913-
"access_type": "ALL",
914-
"rows": 2,
915-
"filtered": 100
911+
"materialization": {
912+
"query_block": {
913+
"select_id": 2,
914+
"table": {
915+
"table_name": "t2",
916+
"access_type": "ALL",
917+
"rows": 2,
918+
"filtered": 100
919+
}
916920
}
917921
}
918922
}

0 commit comments

Comments
 (0)