diff options
| author | Sergei Krivonos <sergei.krivonos@mariadb.com> | 2021-11-14 09:48:20 +0200 |
|---|---|---|
| committer | Sergei Krivonos <sergeikrivonos@gmail.com> | 2021-11-26 15:11:06 +0200 |
| commit | 73df7a30094a0fac8f59de1c91a7bce6cd3ff643 (patch) | |
| tree | a768b2533689fe63e7b54a1cf06770b0f8118218 /mysql-test/main/explain_json.result | |
| parent | a01c82ef2e95b31334034e55e97fb4f2e25ff4be (diff) | |
| download | mariadb-git-73df7a30094a0fac8f59de1c91a7bce6cd3ff643.tar.gz | |
MDEV-27036: resolve duplicated key issues of JSON tracing outputs:
MDEV-27036: repeated "table" key resolve for print_explain_json
MDEV-27036: duplicated keys in best_access_path
MDEV-27036: Explain_aggr_filesort::print_json_members: resolve duplicated "filesort" member in Json object
MDEV-27036: Explain_basic_join::
print_explain_json_interns fixed start_dups_weedout case for main.explain_json test
Diffstat (limited to 'mysql-test/main/explain_json.result')
| -rw-r--r-- | mysql-test/main/explain_json.result | 1804 |
1 files changed, 1046 insertions, 758 deletions
diff --git a/mysql-test/main/explain_json.result b/mysql-test/main/explain_json.result index 98a2fec91fa..35f2d11c8b6 100644 --- a/mysql-test/main/explain_json.result +++ b/mysql-test/main/explain_json.result @@ -6,12 +6,16 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t0", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] } } explain format=json select * from t0 where 1>2; @@ -29,13 +33,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t0", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "attached_condition": "t0.a < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "t0.a < 3" + } + } + ] } } # Try a basic join @@ -51,24 +59,30 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t0", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "attached_condition": "t0.a is not null" - }, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t0.a"], - "rows": 1, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "t0.a is not null" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t0.a"], + "rows": 1, + "filtered": 100 + } + } + ] } } # Try range and index_merge @@ -79,17 +93,21 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["a1"], - "key": "a1", - "key_length": "5", - "used_key_parts": ["a1"], - "rows": 5, - "filtered": 100, - "index_condition": "t2.a1 < 5" - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": ["a1"], + "key": "a1", + "key_length": "5", + "used_key_parts": ["a1"], + "rows": 5, + "filtered": 100, + "index_condition": "t2.a1 < 5" + } + } + ] } } explain format=json select * from t2 where a1=1 or b1=2; @@ -97,27 +115,35 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "index_merge", - "possible_keys": ["a1", "b1"], - "key_length": "5,5", - "index_merge": { - "sort_union": { - "range": { - "key": "a1", - "used_key_parts": ["a1"] + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": ["a1", "b1"], + "key_length": "5,5", + "index_merge": { + "sort_union": [ + { + "range": { + "key": "a1", + "used_key_parts": ["a1"] + } + }, + { + "range": { + "key": "b1", + "used_key_parts": ["b1"] + } + } + ] }, - "range": { - "key": "b1", - "used_key_parts": ["b1"] - } + "rows": 2, + "filtered": 100, + "attached_condition": "t2.a1 = 1 or t2.b1 = 2" } - }, - "rows": 2, - "filtered": 100, - "attached_condition": "t2.a1 = 1 or t2.b1 = 2" - } + } + ] } } explain format=json select * from t2 where a1=1 or (b1=2 and b2=3); @@ -125,27 +151,35 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "index_merge", - "possible_keys": ["a1", "b1"], - "key_length": "5,10", - "index_merge": { - "sort_union": { - "range": { - "key": "a1", - "used_key_parts": ["a1"] + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": ["a1", "b1"], + "key_length": "5,10", + "index_merge": { + "sort_union": [ + { + "range": { + "key": "a1", + "used_key_parts": ["a1"] + } + }, + { + "range": { + "key": "b1", + "used_key_parts": ["b1", "b2"] + } + } + ] }, - "range": { - "key": "b1", - "used_key_parts": ["b1", "b2"] - } + "rows": 2, + "filtered": 100, + "attached_condition": "t2.a1 = 1 or t2.b1 = 2 and t2.b2 = 3" } - }, - "rows": 2, - "filtered": 100, - "attached_condition": "t2.a1 = 1 or t2.b1 = 2 and t2.b2 = 3" - } + } + ] } } explain format=json select * from t2 where (a1=1 and a2=1) or @@ -154,27 +188,35 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "index_merge", - "possible_keys": ["a1", "b1"], - "key_length": "10,10", - "index_merge": { - "union": { - "range": { - "key": "a1", - "used_key_parts": ["a1", "a2"] + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": ["a1", "b1"], + "key_length": "10,10", + "index_merge": { + "union": [ + { + "range": { + "key": "a1", + "used_key_parts": ["a1", "a2"] + } + }, + { + "range": { + "key": "b1", + "used_key_parts": ["b1", "b2"] + } + } + ] }, - "range": { - "key": "b1", - "used_key_parts": ["b1", "b2"] - } + "rows": 2, + "filtered": 100, + "attached_condition": "t2.a1 = 1 and t2.a2 = 1 or t2.b1 = 2 and t2.b2 = 1" } - }, - "rows": 2, - "filtered": 100, - "attached_condition": "t2.a1 = 1 and t2.a2 = 1 or t2.b1 = 2 and t2.b2 = 1" - } + } + ] } } # Try ref access on two key components @@ -183,24 +225,30 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t0", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "attached_condition": "t0.a is not null" - }, - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["b1"], - "key": "b1", - "key_length": "10", - "used_key_parts": ["b1", "b2"], - "ref": ["test.t0.a", "const"], - "rows": 1, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "t0.a is not null" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["b1"], + "key": "b1", + "key_length": "10", + "used_key_parts": ["b1", "b2"], + "ref": ["test.t0.a", "const"], + "rows": 1, + "filtered": 100 + } + } + ] } } drop table t1,t2; @@ -218,24 +266,32 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "A", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "A", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] } }, { "query_block": { "select_id": 2, "operation": "UNION", - "table": { - "table_name": "B", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "B", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] } } ] @@ -253,24 +309,32 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "A", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "A", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] } }, { "query_block": { "select_id": 2, "operation": "UNION", - "table": { - "table_name": "B", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "B", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] } } ] @@ -287,25 +351,33 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t0", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ], "subqueries": [ { "expression_cache": { "state": "uninitialized", "query_block": { "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "attached_condition": "t1.b = t0.a" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "t1.b = t0.a" + } + } + ] } } } @@ -319,26 +391,34 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t0", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "attached_condition": "t0.a > (subquery#2) or t0.a < 3" - }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "t0.a > (subquery#2) or t0.a < 3" + } + } + ], "subqueries": [ { "expression_cache": { "state": "uninitialized", "query_block": { "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "attached_condition": "t1.b = t0.a" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "t1.b = t0.a" + } + } + ] } } } @@ -357,26 +437,32 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "tbl1", - "access_type": "ALL", - "rows": 100, - "filtered": 100, - "attached_condition": "tbl1.b < 3" - }, - "block-nl-join": { - "table": { - "table_name": "tbl2", - "access_type": "ALL", - "rows": 100, - "filtered": 100, - "attached_condition": "tbl2.b < 5" + "nested_loop": [ + { + "table": { + "table_name": "tbl1", + "access_type": "ALL", + "rows": 100, + "filtered": 100, + "attached_condition": "tbl1.b < 3" + } }, - "buffer_type": "flat", - "buffer_size": "1Kb", - "join_type": "BNL", - "attached_condition": "tbl2.a = tbl1.a" - } + { + "block-nl-join": { + "table": { + "table_name": "tbl2", + "access_type": "ALL", + "rows": 100, + "filtered": 100, + "attached_condition": "tbl2.b < 5" + }, + "buffer_type": "flat", + "buffer_size": "1Kb", + "join_type": "BNL", + "attached_condition": "tbl2.a = tbl1.a" + } + } + ] } } drop table t1; @@ -454,12 +540,16 @@ EXPLAIN { "query_block": { "select_id": 2, - "table": { - "table_name": "t0", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] } } ] @@ -478,30 +568,38 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "attached_condition": "tbl.cnt > 0", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "cnt > 0", - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "tbl.cnt > 0", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "cnt > 0", + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } explain format=json @@ -511,41 +609,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "tbl2", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "attached_condition": "tbl2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "8", - "used_key_parts": ["cnt"], - "ref": ["test.tbl2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "tbl1.cnt = tbl2.a", - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "tbl2", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "tbl2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "8", + "used_key_parts": ["cnt"], + "ref": ["test.tbl2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "tbl1.cnt = tbl2.a", + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } # @@ -557,38 +665,48 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "attached_condition": "t1.a is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "4", - "used_key_parts": ["max(a)"], - "ref": ["test.t1.a"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "t1.a is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "4", + "used_key_parts": ["max(a)"], + "ref": ["test.t1.a"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] + } } } } } - } + ] } } # @@ -603,46 +721,58 @@ EXPLAIN "query_block": { "select_id": 1, "const_condition": "1", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "4", - "used_key_parts": ["a"], - "ref": ["func"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "4", + "used_key_parts": ["a"], + "ref": ["func"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] + } + } + } + }, + { + "block-nl-join": { "table": { - "table_name": "t0", + "table_name": "t2", "access_type": "ALL", "rows": 10, "filtered": 100 - } + }, + "buffer_type": "flat", + "buffer_size": "1Kb", + "join_type": "BNL" } } - }, - "block-nl-join": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "1Kb", - "join_type": "BNL" - } + ] } } # @@ -659,25 +789,31 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "first_match": "t2" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "141", - "join_type": "BNL", - "attached_condition": "t1.b = t2.b and t1.a = t2.a" - } + { + "block-nl-join": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "first_match": "t2" + }, + "buffer_type": "flat", + "buffer_size": "141", + "join_type": "BNL", + "attached_condition": "t1.b = t2.b and t1.a = t2.a" + } + } + ] } } # @@ -696,26 +832,32 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - }, - "duplicates_removal": { - "block-nl-join": { + "nested_loop": [ + { "table": { - "table_name": "t1", + "table_name": "t2", "access_type": "ALL", "rows": 10, "filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "206", - "join_type": "BNL", - "attached_condition": "t1.b = t2.b and t1.a = t2.a" + } + }, + { + "duplicates_removal": { + "block-nl-join": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "206", + "join_type": "BNL", + "attached_condition": "t1.b = t2.b and t1.a = t2.a" + } + } } - } + ] } } set optimizer_switch=@tmp; @@ -732,18 +874,22 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 2, - "filtered": 100, - "index_condition": "t1.a < 3", - "mrr_type": "Rowid-ordered scan" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 2, + "filtered": 100, + "index_condition": "t1.a < 3", + "mrr_type": "Rowid-ordered scan" + } + } + ] } } # 'Range checked for each record' @@ -754,22 +900,28 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "tbl1", - "access_type": "ALL", - "rows": 100, - "filtered": 100 - }, - "range-checked-for-each-record": { - "keys": ["a"], - "table": { - "table_name": "tbl2", - "access_type": "ALL", - "possible_keys": ["a"], - "rows": 100, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "tbl1", + "access_type": "ALL", + "rows": 100, + "filtered": 100 + } + }, + { + "range-checked-for-each-record": { + "keys": ["a"], + "table": { + "table_name": "tbl2", + "access_type": "ALL", + "possible_keys": ["a"], + "rows": 100, + "filtered": 100 + } + } } - } + ] } } drop table t1; @@ -786,49 +938,59 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "outer_t1", - "access_type": "index", - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 2, - "filtered": 100, - "attached_condition": "!<in_optimizer>(outer_t1.a,<exists>(subquery#2))", - "using_index": true - }, + "nested_loop": [ + { + "table": { + "table_name": "outer_t1", + "access_type": "index", + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 2, + "filtered": 100, + "attached_condition": "!<in_optimizer>(outer_t1.a,<exists>(subquery#2))", + "using_index": true + } + } + ], "subqueries": [ { "query_block": { "select_id": 2, "having_condition": "trigcond(t1.a is null)", - "full-scan-on-null_key": { - "table": { - "table_name": "t1", - "access_type": "ref_or_null", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["func"], - "rows": 2, - "filtered": 100, - "attached_condition": "trigcond(<cache>(outer_t1.a) = t1.a or t1.a is null)", - "using_index": true - } - }, - "block-nl-join": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 2, - "filtered": 100 + "nested_loop": [ + { + "full-scan-on-null_key": { + "table": { + "table_name": "t1", + "access_type": "ref_or_null", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["func"], + "rows": 2, + "filtered": 100, + "attached_condition": "trigcond(<cache>(outer_t1.a) = t1.a or t1.a is null)", + "using_index": true + } + } }, - "buffer_type": "flat", - "buffer_size": "65", - "join_type": "BNL", - "attached_condition": "t2.b <> outer_t1.a" - } + { + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL", + "attached_condition": "t2.b <> outer_t1.a" + } + } + ] } } ] @@ -852,34 +1014,44 @@ EXPLAIN "query_block": { "select_id": 1, "const_condition": "<not>(<in_optimizer>(20000,<max>(subquery#2) >= 20000))", - "table": { - "table_name": "t0", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ], "subqueries": [ { "query_block": { "select_id": 2, - "table": { - "table_name": "tbl1", - "access_type": "ALL", - "rows": 100, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "tbl2", - "access_type": "ALL", - "rows": 100, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "tbl1", + "access_type": "ALL", + "rows": 100, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "1Kb", - "join_type": "BNL", - "attached_condition": "tbl2.b = tbl1.b" - } + { + "block-nl-join": { + "table": { + "table_name": "tbl2", + "access_type": "ALL", + "rows": 100, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "1Kb", + "join_type": "BNL", + "attached_condition": "tbl2.b = tbl1.b" + } + } + ] } } ] @@ -899,23 +1071,31 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "!<in_optimizer>(t1.a,t1.a in (subquery#2))" - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "!<in_optimizer>(t1.a,t1.a in (subquery#2))" + } + } + ], "subqueries": [ { "query_block": { "select_id": 2, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 2, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } + } + ] } } ] @@ -949,16 +1129,20 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "key": "a", - "key_length": "10", - "used_key_parts": ["a", "b"], - "rows": 101, - "filtered": 100, - "using_index_for_group_by": true - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "key": "a", + "key_length": "10", + "used_key_parts": ["a", "b"], + "rows": 101, + "filtered": 100, + "using_index_for_group_by": true + } + } + ] } } analyze format=json select count(distinct b) from t1 group by a; @@ -968,21 +1152,25 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "range", - "key": "a", - "key_length": "10", - "used_key_parts": ["a", "b"], - "r_loops": 1, - "rows": 101, - "r_rows": 100, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "using_index_for_group_by": true - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "key": "a", + "key_length": "10", + "used_key_parts": ["a", "b"], + "r_loops": 1, + "rows": 101, + "r_rows": 100, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "using_index_for_group_by": true + } + } + ] } } drop table t1,t2; @@ -1043,17 +1231,21 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "key": "idx_t1_1", - "key_length": "147", - "used_key_parts": ["a1", "a2", "b"], - "rows": 17, - "filtered": 100, - "attached_condition": "t1.b = 'a' and t1.a2 >= 'b'", - "using_index_for_group_by": true - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "key": "idx_t1_1", + "key_length": "147", + "used_key_parts": ["a1", "a2", "b"], + "rows": 17, + "filtered": 100, + "attached_condition": "t1.b = 'a' and t1.a2 >= 'b'", + "using_index_for_group_by": true + } + } + ] } } explain format=json select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); @@ -1061,17 +1253,21 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "key": "idx_t1_1", - "key_length": "163", - "used_key_parts": ["a1", "a2", "b", "c"], - "rows": 65, - "filtered": 100, - "attached_condition": "t1.b = 'a' and t1.c = 'i121' and t1.a2 >= 'b'", - "using_index_for_group_by": true - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "key": "idx_t1_1", + "key_length": "163", + "used_key_parts": ["a1", "a2", "b", "c"], + "rows": 65, + "filtered": 100, + "attached_condition": "t1.b = 'a' and t1.c = 'i121' and t1.a2 >= 'b'", + "using_index_for_group_by": true + } + } + ] } } drop table t1; @@ -1085,13 +1281,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t1.a = _latin1'\xDF'" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.a = _latin1'\xDF'" + } + } + ] } } DROP TABLE t1; @@ -1105,13 +1305,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "(case when convert(t1.a using utf8mb3) = <cache>(_utf8mb3'a' collate utf8mb3_bin) then NULL else t1.a end)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "(case when convert(t1.a using utf8mb3) = <cache>(_utf8mb3'a' collate utf8mb3_bin) then NULL else t1.a end)" + } + } + ] } } DROP TABLE t1; @@ -1138,12 +1342,16 @@ EXPLAIN "filesort": { "sort_key": "t2.a", "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 256, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 256, + "filtered": 100 + } + } + ] } } } @@ -1157,12 +1365,16 @@ EXPLAIN "filesort": { "sort_key": "t2.a", "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 256, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 256, + "filtered": 100 + } + } + ] } } } @@ -1187,12 +1399,16 @@ EXPLAIN "filesort": { "sort_key": "t2.a", "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 256, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 256, + "filtered": 100 + } + } + ] } } } @@ -1213,13 +1429,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "system", - "rows": 0, - "filtered": 0, - "const_row_not_found": true - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "system", + "rows": 0, + "filtered": 0, + "const_row_not_found": true + } + } + ] } } analyze format=json @@ -1251,20 +1471,26 @@ EXPLAIN "query_block": { "select_id": 1, "const_condition": "1", - "table": { - "table_name": "t2", - "access_type": "const", - "possible_keys": ["PRIMARY"], - "rows": 1, - "filtered": 100, - "impossible_on_condition": true - }, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "const", + "possible_keys": ["PRIMARY"], + "rows": 1, + "filtered": 100, + "impossible_on_condition": true + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } + } + ] } } analyze format=json @@ -1276,28 +1502,34 @@ ANALYZE "r_loops": 1, "r_total_time_ms": "REPLACED", "const_condition": "1", - "table": { - "table_name": "t2", - "access_type": "const", - "possible_keys": ["PRIMARY"], - "r_loops": 0, - "rows": 1, - "r_rows": null, - "filtered": 100, - "r_filtered": null, - "impossible_on_condition": true - }, - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 2, - "r_rows": 2, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "const", + "possible_keys": ["PRIMARY"], + "r_loops": 0, + "rows": 1, + "r_rows": null, + "filtered": 100, + "r_filtered": null, + "impossible_on_condition": true + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } } # Check ET_NOT_EXISTS: @@ -1312,26 +1544,32 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100 - }, - "table": { - "table_name": "t2", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["pk"], - "ref": ["test.t1.a"], - "rows": 1, - "filtered": 100, - "attached_condition": "trigcond(t2.pk is null) and trigcond(trigcond(t1.a is not null))", - "using_index": true, - "not_exists": true - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["pk"], + "ref": ["test.t1.a"], + "rows": 1, + "filtered": 100, + "attached_condition": "trigcond(t2.pk is null) and trigcond(trigcond(t1.a is not null))", + "using_index": true, + "not_exists": true + } + } + ] } } analyze format=json @@ -1342,36 +1580,42 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 2, - "r_rows": 2, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "table": { - "table_name": "t2", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["pk"], - "ref": ["test.t1.a"], - "r_loops": 2, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "trigcond(t2.pk is null) and trigcond(trigcond(t1.a is not null))", - "using_index": true, - "not_exists": true - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["pk"], + "ref": ["test.t1.a"], + "r_loops": 2, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "trigcond(t2.pk is null) and trigcond(trigcond(t1.a is not null))", + "using_index": true, + "not_exists": true + } + } + ] } } # Check ET_DISTINCT @@ -1387,26 +1631,32 @@ EXPLAIN "query_block": { "select_id": 1, "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t1.a is not null" - }, - "table": { - "table_name": "t2", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["pk"], - "ref": ["test.t1.a"], - "rows": 1, - "filtered": 100, - "using_index": true, - "distinct": true - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.a is not null" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["pk"], + "ref": ["test.t1.a"], + "rows": 1, + "filtered": 100, + "using_index": true, + "distinct": true + } + } + ] } } } @@ -1419,36 +1669,42 @@ ANALYZE "r_loops": 1, "r_total_time_ms": "REPLACED", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 2, - "r_rows": 2, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "t1.a is not null" - }, - "table": { - "table_name": "t2", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["pk"], - "ref": ["test.t1.a"], - "r_loops": 2, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "using_index": true, - "distinct": true - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "t1.a is not null" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["pk"], + "ref": ["test.t1.a"], + "r_loops": 2, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "using_index": true, + "distinct": true + } + } + ] } } } @@ -1477,31 +1733,37 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "attached_condition": "t3.a is not null" - }, - "block-nl-join": { - "table": { - "table_name": "t4", - "access_type": "ref", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t3.a"], - "rows": 1, - "filtered": 100, - "index_condition_bka": "t4.b + 1 <= t3.b + 1" + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "t3.a is not null" + } }, - "buffer_type": "flat", - "buffer_size": "400", - "join_type": "BKA", - "mrr_type": "Rowid-ordered scan" - } + { + "block-nl-join": { + "table": { + "table_name": "t4", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t3.a"], + "rows": 1, + "filtered": 100, + "index_condition_bka": "t4.b + 1 <= t3.b + 1" + }, + "buffer_type": "flat", + "buffer_size": "400", + "join_type": "BKA", + "mrr_type": "Rowid-ordered scan" + } + } + ] } } analyze format=json @@ -1512,42 +1774,48 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 10, - "r_rows": 10, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "t3.a is not null" - }, - "block-nl-join": { - "table": { - "table_name": "t4", - "access_type": "ref", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t3.a"], - "r_loops": 1, - "rows": 1, - "r_rows": 10, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "index_condition_bka": "t4.b + 1 <= t3.b + 1" + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 10, + "r_rows": 10, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "t3.a is not null" + } }, - "buffer_type": "flat", - "buffer_size": "400", - "join_type": "BKA", - "mrr_type": "Rowid-ordered scan", - "r_filtered": 100 - } + { + "block-nl-join": { + "table": { + "table_name": "t4", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t3.a"], + "r_loops": 1, + "rows": 1, + "r_rows": 10, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "index_condition_bka": "t4.b + 1 <= t3.b + 1" + }, + "buffer_type": "flat", + "buffer_size": "400", + "join_type": "BKA", + "mrr_type": "Rowid-ordered scan", + "r_filtered": 100 + } + } + ] } } set optimizer_switch=@tmp_optimizer_switch; @@ -1566,12 +1834,16 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t0", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ], "subqueries": [ { "expression_cache": { @@ -1579,13 +1851,17 @@ EXPLAIN "query_block": { "select_id": 2, "outer_ref_condition": "t0.a < 5", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "attached_condition": "t1.b < t0.a" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "t1.b < t0.a" + } + } + ] } } } @@ -1603,17 +1879,21 @@ EXPLAIN { "query_block": { "select_id": 1, - "read_sorted_file": { - "filesort": { - "sort_key": "t1.a, t1.b desc", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "read_sorted_file": { + "filesort": { + "sort_key": "t1.a, t1.b desc", + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } } } - } + ] } } explain format=json select * from t1 order by a desc, b desc; @@ -1621,17 +1901,21 @@ EXPLAIN { "query_block": { "select_id": 1, - "read_sorted_file": { - "filesort": { - "sort_key": "t1.a desc, t1.b desc", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "read_sorted_file": { + "filesort": { + "sort_key": "t1.a desc, t1.b desc", + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } } } - } + ] } } explain format=json select * from t1 order by a desc, b ; @@ -1639,17 +1923,21 @@ EXPLAIN { "query_block": { "select_id": 1, - "read_sorted_file": { - "filesort": { - "sort_key": "t1.a desc, t1.b", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "read_sorted_file": { + "filesort": { + "sort_key": "t1.a desc, t1.b", + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } } } - } + ] } } drop table t1; |
