diff options
Diffstat (limited to 'mysql-test/main')
123 files changed, 38282 insertions, 18204 deletions
diff --git a/mysql-test/main/analyze_format_json.result b/mysql-test/main/analyze_format_json.result index fc643d1a8af..6c9b8ce2982 100644 --- a/mysql-test/main/analyze_format_json.result +++ b/mysql-test/main/analyze_format_json.result @@ -9,18 +9,22 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t0", - "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": 30, - "attached_condition": "t0.a < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t0", + "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": 30, + "attached_condition": "t0.a < 3" + } + } + ] } } create table t1 (a int, b int, c int, key(a)); @@ -38,32 +42,38 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t0", - "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": 0, - "attached_condition": "t0.a > 9 and 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"], - "r_loops": 0, - "rows": 1, - "r_rows": null, - "filtered": 100, - "r_filtered": null - } + "nested_loop": [ + { + "table": { + "table_name": "t0", + "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": 0, + "attached_condition": "t0.a > 9 and 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"], + "r_loops": 0, + "rows": 1, + "r_rows": null, + "filtered": 100, + "r_filtered": null + } + } + ] } } analyze @@ -79,35 +89,41 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t0", - "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": "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"], - "r_loops": 10, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 40, - "attached_condition": "t1.b < 4" - } + "nested_loop": [ + { + "table": { + "table_name": "t0", + "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": "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"], + "r_loops": 10, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 40, + "attached_condition": "t1.b < 4" + } + } + ] } } analyze @@ -123,36 +139,42 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "tbl1", - "access_type": "ALL", - "r_loops": 1, - "rows": 100, - "r_rows": 100, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 20, - "attached_condition": "tbl1.b < 20" - }, - "block-nl-join": { - "table": { - "table_name": "tbl2", - "access_type": "ALL", - "r_loops": 1, - "rows": 100, - "r_rows": 100, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 60, - "attached_condition": "tbl2.b < 60" + "nested_loop": [ + { + "table": { + "table_name": "tbl1", + "access_type": "ALL", + "r_loops": 1, + "rows": 100, + "r_rows": 100, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 20, + "attached_condition": "tbl1.b < 20" + } }, - "buffer_type": "flat", - "buffer_size": "1Kb", - "join_type": "BNL", - "r_filtered": 100 - } + { + "block-nl-join": { + "table": { + "table_name": "tbl2", + "access_type": "ALL", + "r_loops": 1, + "rows": 100, + "r_rows": 100, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 60, + "attached_condition": "tbl2.b < 60" + }, + "buffer_type": "flat", + "buffer_size": "1Kb", + "join_type": "BNL", + "r_filtered": 100 + } + } + ] } } analyze format=json @@ -163,37 +185,43 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "tbl1", - "access_type": "ALL", - "r_loops": 1, - "rows": 100, - "r_rows": 100, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 20, - "attached_condition": "tbl1.b < 20" - }, - "block-nl-join": { - "table": { - "table_name": "tbl2", - "access_type": "ALL", - "r_loops": 1, - "rows": 100, - "r_rows": 100, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 60, - "attached_condition": "tbl2.b < 60" + "nested_loop": [ + { + "table": { + "table_name": "tbl1", + "access_type": "ALL", + "r_loops": 1, + "rows": 100, + "r_rows": 100, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 20, + "attached_condition": "tbl1.b < 20" + } }, - "buffer_type": "flat", - "buffer_size": "1Kb", - "join_type": "BNL", - "attached_condition": "tbl1.c > tbl2.c", - "r_filtered": 15.83333333 - } + { + "block-nl-join": { + "table": { + "table_name": "tbl2", + "access_type": "ALL", + "r_loops": 1, + "rows": 100, + "r_rows": 100, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 60, + "attached_condition": "tbl2.b < 60" + }, + "buffer_type": "flat", + "buffer_size": "1Kb", + "join_type": "BNL", + "attached_condition": "tbl1.c > tbl2.c", + "r_filtered": 15.83333333 + } + } + ] } } drop table t1; @@ -212,35 +240,41 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "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": "t1.a is not null" - }, - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t1.a"], - "r_loops": 10, - "rows": 2, - "r_rows": 0.2, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "using_index": true - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "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": "t1.a is not null" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t1.a"], + "r_loops": 10, + "rows": 2, + "r_rows": 0.2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "using_index": true + } + } + ] } } drop table t1,t2; @@ -264,18 +298,22 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "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": 50, - "attached_condition": "test.t1.a < 5" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "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": 50, + "attached_condition": "test.t1.a < 5" + } + } + ] } } disconnect con1; @@ -318,23 +356,27 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["pk"], - "r_loops": 1, - "rows": 10, - "r_rows": 10, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 50, - "index_condition": "t1.pk < 10", - "attached_condition": "t1.b > 4" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["pk"], + "r_loops": 1, + "rows": 10, + "r_rows": 10, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 50, + "index_condition": "t1.pk < 10", + "attached_condition": "t1.b > 4" + } + } + ] } } analyze format=json @@ -388,42 +430,48 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 5, - "r_rows": 5, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "range-checked-for-each-record": { - "keys": ["key1", "key2", "key3", "key4"], - "r_keys": { - "full_scan": 1, - "index_merge": 1, - "range": { - "key1": 2, - "key2": 1, - "key3": 0, - "key4": 0 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 5, + "r_rows": 5, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 } }, - "table": { - "table_name": "t2", - "access_type": "ALL", - "possible_keys": ["key1", "key2", "key3", "key4"], - "r_loops": 5, - "rows": 1010, - "r_rows": 203.8, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 98.13542689 + { + "range-checked-for-each-record": { + "keys": ["key1", "key2", "key3", "key4"], + "r_keys": { + "full_scan": 1, + "index_merge": 1, + "range": { + "key1": 2, + "key2": 1, + "key3": 0, + "key4": 0 + } + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": ["key1", "key2", "key3", "key4"], + "r_loops": 5, + "rows": 1010, + "r_rows": 203.8, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 98.13542689 + } + } } - } + ] } } drop table t1,t2,t3,t4; @@ -449,18 +497,22 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "tbl1", - "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": 50, - "attached_condition": "tbl1.a < 5" - } + "nested_loop": [ + { + "table": { + "table_name": "tbl1", + "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": 50, + "attached_condition": "tbl1.a < 5" + } + } + ] } }, { @@ -469,18 +521,22 @@ ANALYZE "operation": "UNION", "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "tbl2", - "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": 20, - "attached_condition": "tbl2.a in (2,3)" - } + "nested_loop": [ + { + "table": { + "table_name": "tbl2", + "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": 20, + "attached_condition": "tbl2.a in (2,3)" + } + } + ] } } ] @@ -519,17 +575,21 @@ ANALYZE "r_buffer_size": "REPLACED", "r_sort_mode": "sort_key,rowid", "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 1, - "rows": 256, - "r_rows": 256, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 256, + "r_rows": 256, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } } } @@ -551,17 +611,21 @@ ANALYZE "r_buffer_size": "REPLACED", "r_sort_mode": "sort_key,rowid", "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 1, - "rows": 256, - "r_rows": 256, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 256, + "r_rows": 256, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } } } @@ -594,17 +658,21 @@ ANALYZE "r_buffer_size": "REPLACED", "r_sort_mode": "sort_key,rowid", "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 1, - "rows": 256, - "r_rows": 256, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 256, + "r_rows": 256, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } } } @@ -624,44 +692,24 @@ 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 - }, - "block-nl-join": { - "table": { - "table_name": "t2", - "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": 0, - "attached_condition": "<in_optimizer>(t2.b,t2.b in (subquery#2))" - }, - "buffer_type": "flat", - "buffer_size": "65", - "join_type": "BNL", - "attached_condition": "<in_optimizer>(t2.b,t2.b in (subquery#2))", - "r_filtered": null - }, - "subqueries": [ + "nested_loop": [ { - "query_block": { - "select_id": 2, + "table": { + "table_name": "t1", + "access_type": "ALL", "r_loops": 1, - "r_total_time_ms": "REPLACED", + "rows": 2, + "r_rows": 2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + }, + { + "block-nl-join": { "table": { - "table_name": "t1", + "table_name": "t2", "access_type": "ALL", "r_loops": 1, "rows": 2, @@ -669,8 +717,38 @@ ANALYZE "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, - "r_filtered": 100 - } + "r_filtered": 0, + "attached_condition": "<in_optimizer>(t2.b,t2.b in (subquery#2))" + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL", + "attached_condition": "<in_optimizer>(t2.b,t2.b in (subquery#2))", + "r_filtered": null + } + } + ], + "subqueries": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "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 + } + } + ] } } ] @@ -715,35 +793,41 @@ ANALYZE "r_buffer_size": "REPLACED", "r_sort_mode": "sort_key,rowid", "temporary_table": { - "table": { - "table_name": "t2", - "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 - }, - "block-nl-join": { - "table": { - "table_name": "t3", - "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": 0, - "attached_condition": "t3.f3 in (1,2)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "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 + } }, - "buffer_type": "flat", - "buffer_size": "1", - "join_type": "BNL", - "r_filtered": null - }, + { + "block-nl-join": { + "table": { + "table_name": "t3", + "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": 0, + "attached_condition": "t3.f3 in (1,2)" + }, + "buffer_type": "flat", + "buffer_size": "1", + "join_type": "BNL", + "r_filtered": null + } + } + ], "subqueries": [ { "expression_cache": { @@ -751,31 +835,37 @@ ANALYZE "r_loops": 0, "query_block": { "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 0, - "rows": 2, - "r_rows": null, - "filtered": 100, - "r_filtered": null - }, - "block-nl-join": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 0, - "rows": 2, - "r_rows": null, - "filtered": 100, - "r_filtered": null + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 0, + "rows": 2, + "r_rows": null, + "filtered": 100, + "r_filtered": null + } }, - "buffer_type": "flat", - "buffer_size": "65", - "join_type": "BNL", - "attached_condition": "t2.f2 = t3.f3", - "r_filtered": null - } + { + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 0, + "rows": 2, + "r_rows": null, + "filtered": 100, + "r_filtered": null + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL", + "attached_condition": "t2.f2 = t3.f3", + "r_filtered": null + } + } + ] } } } @@ -802,18 +892,22 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "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": 0, - "attached_condition": "t1.a < 0" - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "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": 0, + "attached_condition": "t1.a < 0" + } + } + ], "subqueries": [ { "expression_cache": { @@ -821,27 +915,31 @@ ANALYZE "r_loops": 0, "query_block": { "select_id": 2, - "read_sorted_file": { - "r_rows": null, - "filesort": { - "sort_key": "t2.c", - "r_loops": null, - "r_limit": null, - "r_used_priority_queue": null, - "r_output_rows": null, - "r_sort_mode": "sort_key,rowid", - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 0, - "rows": 10, + "nested_loop": [ + { + "read_sorted_file": { "r_rows": null, - "filtered": 100, - "r_filtered": null, - "attached_condition": "t2.a < t1.a" + "filesort": { + "sort_key": "t2.c", + "r_loops": null, + "r_limit": null, + "r_used_priority_queue": null, + "r_output_rows": null, + "r_sort_mode": "sort_key,rowid", + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 0, + "rows": 10, + "r_rows": null, + "filtered": 100, + "r_filtered": null, + "attached_condition": "t2.a < t1.a" + } + } } } - } + ] } } } diff --git a/mysql-test/main/analyze_stmt_orderby.result b/mysql-test/main/analyze_stmt_orderby.result index 11736c47a49..d4d0fe6b25b 100644 --- a/mysql-test/main/analyze_stmt_orderby.result +++ b/mysql-test/main/analyze_stmt_orderby.result @@ -176,24 +176,30 @@ EXPLAIN "filesort": { "sort_key": "t2.b", "temporary_table": { - "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": ["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": "t2", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t0.a"], + "rows": 1, + "filtered": 100 + } + } + ] } } } @@ -215,34 +221,40 @@ ANALYZE "r_output_rows": 4, "r_sort_mode": "sort_key,rowid", "temporary_table": { - "table": { - "table_name": "t0", - "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": "t0.a is not null" - }, - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t0.a"], - "r_loops": 10, - "rows": 1, - "r_rows": 0.4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t0", + "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": "t0.a is not null" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t0.a"], + "r_loops": 10, + "rows": 1, + "r_rows": 0.4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } } } @@ -261,29 +273,35 @@ EXPLAIN { "query_block": { "select_id": 1, - "read_sorted_file": { - "filesort": { - "sort_key": "t0.a", + "nested_loop": [ + { + "read_sorted_file": { + "filesort": { + "sort_key": "t0.a", + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "t0.a is not null" + } + } + } + }, + { "table": { - "table_name": "t0", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "attached_condition": "t0.a is not null" + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t0.a"], + "rows": 1, + "filtered": 100 } } - }, - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t0.a"], - "rows": 1, - "filtered": 100 - } + ] } } analyze format=json @@ -294,46 +312,52 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "read_sorted_file": { - "r_rows": 10, - "filesort": { - "sort_key": "t0.a", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "r_used_priority_queue": false, - "r_output_rows": 10, - "r_buffer_size": "REPLACED", - "r_sort_mode": "sort_key,addon_fields", - "table": { - "table_name": "t0", - "access_type": "ALL", - "r_loops": 1, - "rows": 10, + "nested_loop": [ + { + "read_sorted_file": { "r_rows": 10, + "filesort": { + "sort_key": "t0.a", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 10, + "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,addon_fields", + "table": { + "table_name": "t0", + "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": "t0.a is not null" + } + } + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t0.a"], + "r_loops": 10, + "rows": 1, + "r_rows": 0.4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 100, - "r_filtered": 100, - "attached_condition": "t0.a is not null" + "r_filtered": 100 } } - }, - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t0.a"], - "r_loops": 10, - "rows": 1, - "r_rows": 0.4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + ] } } drop table t2; @@ -365,18 +389,22 @@ ANALYZE "r_buffer_size": "REPLACED", "r_sort_mode": "sort_key,rowid", "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 1, - "rows": 1000, - "r_rows": 1000, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 50, - "attached_condition": "t2.a MOD 2 = 0" - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 1000, + "r_rows": 1000, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 50, + "attached_condition": "t2.a MOD 2 = 0" + } + } + ] } } } @@ -414,35 +442,41 @@ ANALYZE "r_total_time_ms": "REPLACED", "duplicate_removal": { "temporary_table": { - "table": { - "table_name": "t0", - "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 - }, - "block-nl-join": { - "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 + "nested_loop": [ + { + "table": { + "table_name": "t0", + "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 + } }, - "buffer_type": "flat", - "buffer_size": "65", - "join_type": "BNL", - "attached_condition": "t3.a = t0.a", - "r_filtered": 10 - } + { + "block-nl-join": { + "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 + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL", + "attached_condition": "t3.a = t0.a", + "r_filtered": 10 + } + } + ] } } } @@ -488,36 +522,42 @@ ANALYZE "r_buffer_size": "REPLACED", "r_sort_mode": "sort_key,rowid", "temporary_table": { - "table": { - "table_name": "t6", - "access_type": "ALL", - "r_loops": 1, - "rows": 5, - "r_rows": 5, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 80, - "attached_condition": "t6.b > 0 and t6.a <= 5" - }, - "block-nl-join": { - "table": { - "table_name": "t5", - "access_type": "ALL", - "r_loops": 1, - "rows": 7, - "r_rows": 7, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t6", + "access_type": "ALL", + "r_loops": 1, + "rows": 5, + "r_rows": 5, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 80, + "attached_condition": "t6.b > 0 and t6.a <= 5" + } }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL", - "attached_condition": "t5.a = t6.a", - "r_filtered": 21.42857143 - } + { + "block-nl-join": { + "table": { + "table_name": "t5", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "attached_condition": "t5.a = t6.a", + "r_filtered": 21.42857143 + } + } + ] } } } @@ -538,25 +578,31 @@ EXPLAIN "filesort": { "sort_key": "t5.a", "temporary_table": { - "table": { - "table_name": "t6", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t6.b > 0 and t6.a <= 5" - }, - "block-nl-join": { - "table": { - "table_name": "t5", - "access_type": "ALL", - "rows": 7, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t6", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t6.b > 0 and t6.a <= 5" + } }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL", - "attached_condition": "t5.a = t6.a" - } + { + "block-nl-join": { + "table": { + "table_name": "t5", + "access_type": "ALL", + "rows": 7, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "attached_condition": "t5.a = t6.a" + } + } + ] } } } @@ -593,21 +639,25 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "access_type": "range", - "key": "idx", - "key_length": "5", - "used_key_parts": ["col1"], - "r_loops": 1, - "rows": 7, - "r_rows": 20, - "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": "t2", + "access_type": "range", + "key": "idx", + "key_length": "5", + "used_key_parts": ["col1"], + "r_loops": 1, + "rows": 7, + "r_rows": 20, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "using_index_for_group_by": true + } + } + ] } } drop table t2; diff --git a/mysql-test/main/brackets.result b/mysql-test/main/brackets.result index 5229416c035..3fd19ef968a 100644 --- a/mysql-test/main/brackets.result +++ b/mysql-test/main/brackets.result @@ -261,17 +261,21 @@ EXPLAIN { "query_block": { "select_id": 1, - "read_sorted_file": { - "filesort": { - "sort_key": "t1.a desc", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "read_sorted_file": { + "filesort": { + "sort_key": "t1.a desc", + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } } } - } + ] } } (select a from t1 order by a desc) limit 1; @@ -287,17 +291,21 @@ EXPLAIN { "query_block": { "select_id": 1, - "read_sorted_file": { - "filesort": { - "sort_key": "t1.a desc", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "read_sorted_file": { + "filesort": { + "sort_key": "t1.a desc", + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } } } - } + ] } } (select a from t1 where a=20 union select a from t1) order by a desc limit 1; @@ -321,25 +329,33 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t1.a = 20" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.a = 20" + } + } + ] } }, { "query_block": { "select_id": 2, "operation": "UNION", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] } } ] @@ -367,25 +383,33 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t1.a = 20" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.a = 20" + } + } + ] } }, { "query_block": { "select_id": 2, "operation": "UNION", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] } } ] @@ -421,30 +445,38 @@ EXPLAIN { "query_block": { "select_id": 1, - "read_sorted_file": { - "filesort": { - "sort_key": "t1.pk", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100 + "nested_loop": [ + { + "read_sorted_file": { + "filesort": { + "sort_key": "t1.pk", + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } } } - } + ] } }, { "query_block": { "select_id": 2, "operation": "UNION", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.pk > 4" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.pk > 4" + } + } + ] } } ] diff --git a/mysql-test/main/charset_client_win.test b/mysql-test/main/charset_client_win.test index b4a21d4f0a4..8f3767c530f 100644 --- a/mysql-test/main/charset_client_win.test +++ b/mysql-test/main/charset_client_win.test @@ -1,2 +1,7 @@ --source include/windows.inc +--source include/no_utf8_cli.inc +if(!`select $MTR_PARALLEL = 1`) +{ + skip race condition with parallel builds; +} --exec chcp 1257 > NUL && $MYSQL --default-character-set=auto -e "select @@character_set_client" diff --git a/mysql-test/main/charset_client_win_utf8mb4.result b/mysql-test/main/charset_client_win_utf8mb4.result new file mode 100644 index 00000000000..9bbf751e45c --- /dev/null +++ b/mysql-test/main/charset_client_win_utf8mb4.result @@ -0,0 +1,6 @@ +@@character_set_client +utf8mb4 +ERROR 1045 (28000): Access denied for user 'u'@'localhost' (using password: YES) +2 +2 +DROP user u; diff --git a/mysql-test/main/charset_client_win_utf8mb4.test b/mysql-test/main/charset_client_win_utf8mb4.test new file mode 100644 index 00000000000..e08afa250bd --- /dev/null +++ b/mysql-test/main/charset_client_win_utf8mb4.test @@ -0,0 +1,22 @@ +--source include/windows.inc +--source include/check_utf8_cli.inc +--exec $MYSQL --default-character-set=auto -e "select @@character_set_client" + +# Test that a user with old, non-UTF8 password can still connect +# by setting setting non-auto --default-character-set +# This is important for backward compatibility + +# Emulate creating password in an interactive client session, with older clients +# which communicates with the server using with something like cp850 + +exec chcp 850 > NUL && echo CREATE USER 'u' IDENTIFIED by 'ü' | $MYSQL --default-character-set=cp850; + + +# Can't connect with UTF8 +--error 1 +exec $MYSQL --default-character-set=auto --user=u --password=ü -e "select 1" 2>&1; + +# Can connect with tweaked --default-character-set +exec $MYSQL --default-character-set=cp850 --user=u --password=ü -e "select 2"; +DROP user u; + diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result index dd82ef46229..de9a979dd94 100644 --- a/mysql-test/main/cte_recursive.result +++ b/mysql-test/main/cte_recursive.result @@ -1339,107 +1339,133 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 24, - "filtered": 100, - "materialized": { - "query_block": { - "recursive_union": { - "table_name": "<union4,6,5>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 4, - "table": { - "table_name": "folks", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "folks.`name` = 'Me2'" - } - } - }, - { - "query_block": { - "select_id": 6, - "operation": "UNION", - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "prev_gen.`id` < 345", - "materialized": { - "query_block": { - "recursive_union": { - "table_name": "<union3,2>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 3, - "table": { - "table_name": "folks", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "folks.`name` = 'Me'" - } - } - }, - { + "nested_loop": [ + { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 24, + "filtered": 100, + "materialized": { + "query_block": { + "recursive_union": { + "table_name": "<union4,6,5>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 4, + "nested_loop": [ + { + "table": { + "table_name": "folks", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "folks.`name` = 'Me2'" + } + } + ] + } + }, + { + "query_block": { + "select_id": 6, + "operation": "UNION", + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "prev_gen.`id` < 345", + "materialized": { "query_block": { - "select_id": 2, - "operation": "UNION", - "table": { - "table_name": "folks", + "recursive_union": { + "table_name": "<union3,2>", "access_type": "ALL", - "possible_keys": ["PRIMARY"], - "rows": 12, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 12, - "filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "686", - "join_type": "BNL", - "attached_condition": "prev_gen.father = folks.`id` or prev_gen.mother = folks.`id`" + "query_specifications": [ + { + "query_block": { + "select_id": 3, + "nested_loop": [ + { + "table": { + "table_name": "folks", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "folks.`name` = 'Me'" + } + } + ] + } + }, + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "nested_loop": [ + { + "table": { + "table_name": "folks", + "access_type": "ALL", + "possible_keys": ["PRIMARY"], + "rows": 12, + "filtered": 100 + } + }, + { + "block-nl-join": { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 12, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "686", + "join_type": "BNL", + "attached_condition": "prev_gen.father = folks.`id` or prev_gen.mother = folks.`id`" + } + } + ] + } + } + ] } } } - ] + } } - } + ] + } + }, + { + "query_block": { + "select_id": 5, + "operation": "UNION", + "nested_loop": [ + { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 24, + "filtered": 100, + "attached_condition": "ancestors.`id` < 234" + } + } + ] } } - } - }, - { - "query_block": { - "select_id": 5, - "operation": "UNION", - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 24, - "filtered": 100, - "attached_condition": "ancestors.`id` < 234" - } - } + ] } - ] + } } } } - } + ] } } # @@ -1473,91 +1499,111 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "materialized": { - "query_block": { - "recursive_union": { - "table_name": "<union3,2>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 3, - "table": { - "table_name": "v", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "v.`name` = 'Me' and v.father is not null and v.mother is not null" - }, - "table": { - "table_name": "h", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["id"], - "ref": ["test.v.father"], - "rows": 1, - "filtered": 100 - }, - "table": { - "table_name": "w", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["id"], - "ref": ["test.v.mother"], - "rows": 1, - "filtered": 100 - } - } - }, - { - "query_block": { - "select_id": 2, - "operation": "UNION", - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "a.father is not null and a.mother is not null" - }, - "table": { - "table_name": "h", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["id"], - "ref": ["a.father"], - "rows": 1, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "materialized": { + "query_block": { + "recursive_union": { + "table_name": "<union3,2>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 3, + "nested_loop": [ + { + "table": { + "table_name": "v", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "v.`name` = 'Me' and v.father is not null and v.mother is not null" + } + }, + { + "table": { + "table_name": "h", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["id"], + "ref": ["test.v.father"], + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "w", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["id"], + "ref": ["test.v.mother"], + "rows": 1, + "filtered": 100 + } + } + ] + } }, - "table": { - "table_name": "w", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["id"], - "ref": ["a.mother"], - "rows": 1, - "filtered": 100 + { + "query_block": { + "select_id": 2, + "operation": "UNION", + "nested_loop": [ + { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "a.father is not null and a.mother is not null" + } + }, + { + "table": { + "table_name": "h", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["id"], + "ref": ["a.father"], + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "w", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["id"], + "ref": ["a.mother"], + "rows": 1, + "filtered": 100 + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } create table my_ancestors @@ -1778,46 +1824,58 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "materialized": { - "query_block": { - "recursive_union": { - "table_name": "<union2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "attached_condition": "t.a < 1000" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "materialized": { + "query_block": { + "recursive_union": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "t.a < 1000" + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } drop table t1; @@ -2401,57 +2459,65 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "r_loops": 1, - "rows": 2, - "r_rows": 10, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "materialized": { - "query_block": { - "recursive_union": { - "table_name": "<union2,3>", - "access_type": "ALL", - "r_loops": 0, - "r_rows": null, - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "table": { - "message": "No tables used" - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "r_loops": 10, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "r_loops": 10, - "rows": 2, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 90, - "attached_condition": "src.counter < 10" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 10, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "recursive_union": { + "table_name": "<union2,3>", + "access_type": "ALL", + "r_loops": 0, + "r_rows": null, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "r_loops": 10, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 10, + "rows": 2, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 90, + "attached_condition": "src.counter < 10" + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } # @@ -3799,105 +3865,121 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "t1.a1 is not null" - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "23", - "used_key_parts": ["a2"], - "ref": ["test.t1.a1"], - "r_loops": 3, - "rows": 1, - "r_rows": 0.333333333, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "first_match": "t1", - "materialized": { - "query_block": { - "recursive_union": { - "table_name": "<union3,4>", - "access_type": "ALL", - "r_loops": 0, - "r_rows": null, - "query_specifications": [ - { - "query_block": { - "select_id": 3, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "access_type": "const", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "22", - "used_key_parts": ["a2"], - "ref": ["const"], - "r_loops": 0, - "rows": 1, - "r_rows": null, - "filtered": 100, - "r_filtered": null, - "using_index": true - } - } - }, - { - "query_block": { - "select_id": 4, - "operation": "UNION", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "r_loops": 1, - "rows": 2, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "cte.a2 is not null" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "t1.a1 is not null" + } + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "23", + "used_key_parts": ["a2"], + "ref": ["test.t1.a1"], + "r_loops": 3, + "rows": 1, + "r_rows": 0.333333333, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "first_match": "t1", + "materialized": { + "query_block": { + "recursive_union": { + "table_name": "<union3,4>", + "access_type": "ALL", + "r_loops": 0, + "r_rows": null, + "query_specifications": [ + { + "query_block": { + "select_id": 3, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "const", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "22", + "used_key_parts": ["a2"], + "ref": ["const"], + "r_loops": 0, + "rows": 1, + "r_rows": null, + "filtered": 100, + "r_filtered": null, + "using_index": true + } + } + ] + } }, - "table": { - "table_name": "tt2", - "access_type": "ref", - "possible_keys": ["b1"], - "key": "b1", - "key_length": "23", - "used_key_parts": ["b1"], - "ref": ["cte.a2"], - "r_loops": 1, - "rows": 2, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + { + "query_block": { + "select_id": 4, + "operation": "UNION", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "cte.a2 is not null" + } + }, + { + "table": { + "table_name": "tt2", + "access_type": "ref", + "possible_keys": ["b1"], + "key": "b1", + "key_length": "23", + "used_key_parts": ["b1"], + "ref": ["cte.a2"], + "r_loops": 1, + "rows": 2, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } drop function f1; @@ -4055,83 +4137,97 @@ ANALYZE "operation": "UNION", "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "r_loops": 1, - "rows": 4, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "materialized": { - "query_block": { - "recursive_union": { - "table_name": "<union2,3>", - "access_type": "ALL", - "r_loops": 0, - "r_rows": null, - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "s", - "access_type": "ALL", - "r_loops": 1, - "rows": 4, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 4, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "t1.c is not null" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "recursive_union": { + "table_name": "<union2,3>", + "access_type": "ALL", + "r_loops": 0, + "r_rows": null, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "s", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "9", - "used_key_parts": ["a"], - "ref": ["test.t1.c"], - "r_loops": 4, - "rows": 2, - "r_rows": 0.5, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "t1.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "9", + "used_key_parts": ["a"], + "ref": ["test.t1.c"], + "r_loops": 4, + "rows": 2, + "r_rows": 0.5, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } ] @@ -4193,17 +4289,21 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "tt", - "access_type": "ALL", - "r_loops": 1, - "rows": 4, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } } prepare stmt from "with h_cte as diff --git a/mysql-test/main/ctype_ldml.result b/mysql-test/main/ctype_ldml.result index 05b31a4ea70..d4b24ad9af3 100644 --- a/mysql-test/main/ctype_ldml.result +++ b/mysql-test/main/ctype_ldml.result @@ -34,6 +34,9 @@ Bar +7-912-800-80-01 SELECT * FROM t1 WHERE phone='7 9 1 2 8 0 0 8 0 0 1'; name phone Bar +7-912-800-80-01 +SELECT * FROM t1 WHERE phone='tel.79128008001'; +name phone +Bar +7-912-800-80-01 DROP TABLE t1; show collation like 'utf8mb3_test_ci'; Collation Charset Id Default Compiled Sortlen @@ -3042,3 +3045,37 @@ SHOW COLLATION LIKE 'latin1_test_replace'; Collation Charset Id Default Compiled Sortlen SELECT 'foo' = 'foo ' COLLATE latin1_test_replace; ERROR HY000: Unknown collation: 'latin1_test_replace' +# +# MDEV-27042 UCA: Resetting contractions to ignorable does not work well +# +CREATE TABLE t1 ( +phone VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_phone_ci +); +INSERT INTO t1 VALUES ('123'); +INSERT INTO t1 VALUES ('tel.123'); +INSERT INTO t1 VALUES ('tél.123'); +INSERT INTO t1 VALUES ('tèl.123'); +INSERT INTO t1 VALUES ('ťel.123'); +INSERT INTO t1 VALUES ('ťèl.123'); +INSERT INTO t1 VALUES ('tex.123'); +SELECT * FROM t1 WHERE phone='123' ORDER BY BINARY phone; +phone +123 +tel.123 +tél.123 +ťel.123 +SELECT * FROM t1 WHERE phone<>'123' ORDER BY BINARY phone; +phone +tex.123 +tèl.123 +ťèl.123 +SELECT phone, HEX(WEIGHT_STRING(phone)) FROM t1 ORDER BY phone, BINARY phone; +phone HEX(WEIGHT_STRING(phone)) +123 0E2A0E2B0E2C +tel.123 0E2A0E2B0E2C +tél.123 0E2A0E2B0E2C +ťel.123 0E2A0E2B0E2C +tèl.123 10020E8B0F2E025D0E2A0E2B0E2C +ťèl.123 10020E8B0F2E025D0E2A0E2B0E2C +tex.123 10020E8B105A025D0E2A0E2B0E2C +DROP TABLE t1; diff --git a/mysql-test/main/ctype_ldml.test b/mysql-test/main/ctype_ldml.test index 2da99e89de5..447a9b4565a 100644 --- a/mysql-test/main/ctype_ldml.test +++ b/mysql-test/main/ctype_ldml.test @@ -36,6 +36,7 @@ SELECT * FROM t1 ORDER BY phone; SELECT * FROM t1 WHERE phone='+7(912)800-80-01'; SELECT * FROM t1 WHERE phone='79128008001'; SELECT * FROM t1 WHERE phone='7 9 1 2 8 0 0 8 0 0 1'; +SELECT * FROM t1 WHERE phone='tel.79128008001'; DROP TABLE t1; show collation like 'utf8mb3_test_ci'; @@ -618,3 +619,23 @@ SELECT 'a' COLLATE utf8_czech_test_bad_w2; SHOW COLLATION LIKE 'latin1_test_replace'; --error ER_UNKNOWN_COLLATION SELECT 'foo' = 'foo ' COLLATE latin1_test_replace; + + +--echo # +--echo # MDEV-27042 UCA: Resetting contractions to ignorable does not work well +--echo # + +CREATE TABLE t1 ( + phone VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_phone_ci +); +INSERT INTO t1 VALUES ('123'); +INSERT INTO t1 VALUES ('tel.123'); +INSERT INTO t1 VALUES ('tél.123'); +INSERT INTO t1 VALUES ('tèl.123'); +INSERT INTO t1 VALUES ('ťel.123'); +INSERT INTO t1 VALUES ('ťèl.123'); +INSERT INTO t1 VALUES ('tex.123'); +SELECT * FROM t1 WHERE phone='123' ORDER BY BINARY phone; +SELECT * FROM t1 WHERE phone<>'123' ORDER BY BINARY phone; +SELECT phone, HEX(WEIGHT_STRING(phone)) FROM t1 ORDER BY phone, BINARY phone; +DROP TABLE t1; diff --git a/mysql-test/main/ctype_utf8mb4_uca_allkeys400.result b/mysql-test/main/ctype_utf8mb4_uca_allkeys400.result new file mode 100644 index 00000000000..77a180602e7 --- /dev/null +++ b/mysql-test/main/ctype_utf8mb4_uca_allkeys400.result @@ -0,0 +1,73 @@ +# +# Start of 10.8 tests +# +SET NAMES utf8mb4 COLLATE utf8mb4_bin; +CREATE TABLE allchars AS SELECT 1 AS code, ' ' AS str LIMIT 0; +SHOW CREATE TABLE allchars; +Table Create Table +allchars CREATE TABLE `allchars` ( + `code` int(1) NOT NULL, + `str` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +CREATE TABLE t1tmp (a INT NOT NULL); +FOR i IN 0..0xFFF +DO +INSERT INTO t1tmp VALUES (i); +END FOR; +$$ +INSERT INTO allchars SELECT +t1.a*0x1000+t2.a, +CHAR(t1.a*0x1000+t2.a USING utf32) +FROM t1tmp t1, t1tmp t2 +WHERE t1.a BETWEEN 0 AND 0x10F; +DROP TABLE t1tmp; +SELECT COUNT(*) FROM allchars; +COUNT(*) +1114112 +CREATE TABLE allkeys_txt (a TEXT, b TEXT, c TEXT) ENGINE=MyISAM; +LOAD DATA INFILE '../../std_data/unicode/allkeys400.txt' +INTO TABLE allkeys_txt FIELDS TERMINATED BY ';' (@a,@b,@qq) +SET a=TRIM(@a), b=TRIM(REGEXP_SUBSTR(@b,'^[^#]*')), c=TRIM(REGEXP_SUBSTR(@b, '#.*$')); +CREATE TABLE allkeys AS +SELECT +a, +CONVERT(CAST(UNHEX(regexp_replace(regexp_replace(regexp_replace(a,'(\\b[0-9A-Z]{4}\\b)','-0000\\1-'),'(\\b[0-9A-Z]{5}\\b)','-000\\1-'),'[ -]','')) AS CHAR CHARACTER SET utf32) USING utf8mb4) COLLATE utf8mb4_bin AS str, +HEX(WEIGHT_STRING(CONVERT(CAST(UNHEX(regexp_replace(regexp_replace(regexp_replace(a,'(\\b[0-9A-Z]{4}\\b)','-0000\\1-'),'(\\b[0-9A-Z]{5}\\b)','-000\\1-'),'[ -]','')) AS CHAR CHARACTER SET utf32) USING utf8mb4) COLLATE utf8mb4_unicode_ci)) as ws, +REPLACE(REPLACE(REGEXP_REPLACE(b,'[[][.*](....)[.]....[.]....[.].{4,5}]','-\\1-'),'-0000-',''),'-','') AS wd, +c +FROM allkeys_txt +WHERE a RLIKE '^[0-9A-Z]'; +ALTER TABLE allkeys ADD KEY(str(3)); +SELECT COUNT(*), SUM(ws<>wd) FROM allkeys WHERE OCTET_LENGTH(str)<=3; +COUNT(*) SUM(ws<>wd) +12073 1 +SELECT a, ws, wd FROM allkeys WHERE ws<>wd AND OCTET_LENGTH(str)<=3; +a ws wd +FDFA FBC1FDFA 138713AB13C70209135013AB13AB13B70209138F13AB13C813B7020913BD138113AB13B0 +SELECT +HEX(code), +HEX(WEIGHT_STRING(str COLLATE utf8mb4_unicode_ci)) AS ws, +CASE +WHEN code >= 0x10000 THEN 'FFFD' + WHEN code >= 0x3400 AND code <= 0x4DB5 THEN +CONCAT(LPAD(HEX(0xFB80 + (code >> 15)),4,'0'), +LPAD(HEX(0x8000 | (code & 0x7FFF)),4,'0')) +WHEN code >= 0x4E00 AND code <= 0x9FA5 THEN +CONCAT(LPAD(HEX(0xFB40 + (code >> 15)),4,'0'), +LPAD(HEX(0x8000 | (code & 0x7FFF)),4,'0')) +ELSE +CONCAT(LPAD(HEX(0xFBC0 + (code >> 15)),4,'0'), +LPAD(HEX(0x8000 | (code & 0x7FFF)),4,'0')) +END AS wd +FROM allchars +LEFT OUTER JOIN allkeys USING (str) +WHERE allkeys.str IS NULL +HAVING ws<>wd +ORDER BY HEX(str); +HEX(code) ws wd +DROP TABLE allkeys_txt; +DROP TABLE allkeys; +DROP TABLE allchars; +# +# End of 10.8 tests +# diff --git a/mysql-test/main/ctype_utf8mb4_uca_allkeys400.test b/mysql-test/main/ctype_utf8mb4_uca_allkeys400.test new file mode 100644 index 00000000000..f3d891a0eeb --- /dev/null +++ b/mysql-test/main/ctype_utf8mb4_uca_allkeys400.test @@ -0,0 +1,77 @@ +--source include/have_utf32.inc +--source include/have_utf8mb4.inc + +--echo # +--echo # Start of 10.8 tests +--echo # + + +SET NAMES utf8mb4 COLLATE utf8mb4_bin; +--source include/ctype_unicode_allchars.inc + +# +# Load allkeys.txt from Unicode-4.0.0 +# +# The 4.0.0 file has four weight levels and an optional extra field +# after the character name, e.g. "; QQK" +#00A0 ; [*0209.0020.001B.00A0] # NO-BREAK SPACE; QQK +# + +CREATE TABLE allkeys_txt (a TEXT, b TEXT, c TEXT) ENGINE=MyISAM; +LOAD DATA INFILE '../../std_data/unicode/allkeys400.txt' +INTO TABLE allkeys_txt FIELDS TERMINATED BY ';' (@a,@b,@qq) +SET a=TRIM(@a), b=TRIM(REGEXP_SUBSTR(@b,'^[^#]*')), c=TRIM(REGEXP_SUBSTR(@b, '#.*$')); +CREATE TABLE allkeys AS +SELECT + a, + CONVERT(CAST(UNHEX(regexp_replace(regexp_replace(regexp_replace(a,'(\\b[0-9A-Z]{4}\\b)','-0000\\1-'),'(\\b[0-9A-Z]{5}\\b)','-000\\1-'),'[ -]','')) AS CHAR CHARACTER SET utf32) USING utf8mb4) COLLATE utf8mb4_bin AS str, + HEX(WEIGHT_STRING(CONVERT(CAST(UNHEX(regexp_replace(regexp_replace(regexp_replace(a,'(\\b[0-9A-Z]{4}\\b)','-0000\\1-'),'(\\b[0-9A-Z]{5}\\b)','-000\\1-'),'[ -]','')) AS CHAR CHARACTER SET utf32) USING utf8mb4) COLLATE utf8mb4_unicode_ci)) as ws, + REPLACE(REPLACE(REGEXP_REPLACE(b,'[[][.*](....)[.]....[.]....[.].{4,5}]','-\\1-'),'-0000-',''),'-','') AS wd, + c +FROM allkeys_txt +WHERE a RLIKE '^[0-9A-Z]'; +ALTER TABLE allkeys ADD KEY(str(3)); + +# +# Test explicit weights +# utf8mb4_unicode_ci supports only BMP characters. +# Built-in default contractions are not supported. +# The (OCTET_LENGTH(str)<=3) part of the condition filters out +# characters outside BMP and contractions. + +SELECT COUNT(*), SUM(ws<>wd) FROM allkeys WHERE OCTET_LENGTH(str)<=3; +SELECT a, ws, wd FROM allkeys WHERE ws<>wd AND OCTET_LENGTH(str)<=3; + +# +# Test implicit weights +# Non-BMP characters all have the same weight FFFD. +# + +SELECT + HEX(code), + HEX(WEIGHT_STRING(str COLLATE utf8mb4_unicode_ci)) AS ws, + CASE + WHEN code >= 0x10000 THEN 'FFFD' + WHEN code >= 0x3400 AND code <= 0x4DB5 THEN + CONCAT(LPAD(HEX(0xFB80 + (code >> 15)),4,'0'), + LPAD(HEX(0x8000 | (code & 0x7FFF)),4,'0')) + WHEN code >= 0x4E00 AND code <= 0x9FA5 THEN + CONCAT(LPAD(HEX(0xFB40 + (code >> 15)),4,'0'), + LPAD(HEX(0x8000 | (code & 0x7FFF)),4,'0')) + ELSE + CONCAT(LPAD(HEX(0xFBC0 + (code >> 15)),4,'0'), + LPAD(HEX(0x8000 | (code & 0x7FFF)),4,'0')) + END AS wd +FROM allchars +LEFT OUTER JOIN allkeys USING (str) +WHERE allkeys.str IS NULL +HAVING ws<>wd +ORDER BY HEX(str); + +DROP TABLE allkeys_txt; +DROP TABLE allkeys; +DROP TABLE allchars; + +--echo # +--echo # End of 10.8 tests +--echo # diff --git a/mysql-test/main/ctype_utf8mb4_uca_allkeys520.result b/mysql-test/main/ctype_utf8mb4_uca_allkeys520.result new file mode 100644 index 00000000000..04d788a4055 --- /dev/null +++ b/mysql-test/main/ctype_utf8mb4_uca_allkeys520.result @@ -0,0 +1,72 @@ +# +# Start of 10.8 tests +# +SET NAMES utf8mb4 COLLATE utf8mb4_bin; +CREATE TABLE allchars AS SELECT 1 AS code, ' ' AS str LIMIT 0; +SHOW CREATE TABLE allchars; +Table Create Table +allchars CREATE TABLE `allchars` ( + `code` int(1) NOT NULL, + `str` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +CREATE TABLE t1tmp (a INT NOT NULL); +FOR i IN 0..0xFFF +DO +INSERT INTO t1tmp VALUES (i); +END FOR; +$$ +INSERT INTO allchars SELECT +t1.a*0x1000+t2.a, +CHAR(t1.a*0x1000+t2.a USING utf32) +FROM t1tmp t1, t1tmp t2 +WHERE t1.a BETWEEN 0 AND 0x10F; +DROP TABLE t1tmp; +SELECT COUNT(*) FROM allchars; +COUNT(*) +1114112 +CREATE TABLE allkeys_txt (a TEXT, b TEXT, c TEXT) ENGINE=MyISAM; +LOAD DATA INFILE '../../std_data/unicode/allkeys520.txt' +INTO TABLE allkeys_txt FIELDS TERMINATED BY ';' (@a,@b,@qq) +SET a=TRIM(@a), b=TRIM(REGEXP_SUBSTR(@b,'^[^#]*')), c=TRIM(REGEXP_SUBSTR(@b, '#.*$')); +CREATE TABLE allkeys AS +SELECT +a, +CONVERT(CAST(UNHEX(regexp_replace(regexp_replace(regexp_replace(a,'(\\b[0-9A-Z]{4}\\b)','-0000\\1-'),'(\\b[0-9A-Z]{5}\\b)','-000\\1-'),'[ -]','')) AS CHAR CHARACTER SET utf32) USING utf8mb4) COLLATE utf8mb4_bin AS str, +HEX(WEIGHT_STRING(CONVERT(CAST(UNHEX(regexp_replace(regexp_replace(regexp_replace(a,'(\\b[0-9A-Z]{4}\\b)','-0000\\1-'),'(\\b[0-9A-Z]{5}\\b)','-000\\1-'),'[ -]','')) AS CHAR CHARACTER SET utf32) USING utf8mb4) COLLATE utf8mb4_unicode_520_ci)) as ws, +REPLACE(REPLACE(REGEXP_REPLACE(b,'[[][.*](....)[.]....[.]....[.].{4,5}]','-\\1-'),'-0000-',''),'-','') AS wd, +c +FROM allkeys_txt +WHERE a RLIKE '^[0-9A-Z]'; +ALTER TABLE allkeys ADD KEY(str(3)); +SELECT COUNT(*), SUM(ws<>wd) FROM allkeys WHERE a NOT LIKE '% %'; +COUNT(*) SUM(ws<>wd) +21807 1 +SELECT a, ws, wd FROM allkeys WHERE ws<>wd AND a NOT LIKE '% %'; +a ws wd +FDFA 18FC192B194F020A18AD192B192B193D 18FC192B194F020A18AD192B192B193D020A1904192B1950193D020A194318F1192B1931 +SELECT +HEX(code), +HEX(WEIGHT_STRING(str COLLATE utf8mb4_unicode_520_ci)) AS ws, +CASE +WHEN code >= 0x3400 AND code <= 0x4DB5 THEN +CONCAT(LPAD(HEX(0xFB80 + (code >> 15)),4,'0'), +LPAD(HEX(0x8000 | (code & 0x7FFF)),4,'0')) +WHEN code >= 0x4E00 AND code <= 0x9FA5 THEN +CONCAT(LPAD(HEX(0xFB40 + (code >> 15)),4,'0'), +LPAD(HEX(0x8000 | (code & 0x7FFF)),4,'0')) +ELSE +CONCAT(LPAD(HEX(0xFBC0 + (code >> 15)),4,'0'), +LPAD(HEX(0x8000 | (code & 0x7FFF)),4,'0')) +END AS wd +FROM allchars +LEFT OUTER JOIN allkeys USING (str) +WHERE allkeys.str IS NULL +HAVING ws<>wd +ORDER BY HEX(str); +HEX(code) ws wd +DROP TABLE allkeys_txt; +DROP TABLE allkeys; +DROP TABLE allchars; +# +# End of 10.8 tests +# diff --git a/mysql-test/main/ctype_utf8mb4_uca_allkeys520.test b/mysql-test/main/ctype_utf8mb4_uca_allkeys520.test new file mode 100644 index 00000000000..f58f2a466c5 --- /dev/null +++ b/mysql-test/main/ctype_utf8mb4_uca_allkeys520.test @@ -0,0 +1,75 @@ +--source include/have_utf32.inc +--source include/have_utf8mb4.inc + +--echo # +--echo # Start of 10.8 tests +--echo # + + +SET NAMES utf8mb4 COLLATE utf8mb4_bin; +--source include/ctype_unicode_allchars.inc + +# +# Load allkeys.txt from Unicode-5.2.0 +# +# The 5.2.0 file has four weight levels and an optional extra field +# after the character name, e.g. "; QQK" +#00A0 ; [*020A.0020.001B.00A0] # NO-BREAK SPACE; QQK +# + +CREATE TABLE allkeys_txt (a TEXT, b TEXT, c TEXT) ENGINE=MyISAM; +LOAD DATA INFILE '../../std_data/unicode/allkeys520.txt' +INTO TABLE allkeys_txt FIELDS TERMINATED BY ';' (@a,@b,@qq) +SET a=TRIM(@a), b=TRIM(REGEXP_SUBSTR(@b,'^[^#]*')), c=TRIM(REGEXP_SUBSTR(@b, '#.*$')); +CREATE TABLE allkeys AS +SELECT + a, + CONVERT(CAST(UNHEX(regexp_replace(regexp_replace(regexp_replace(a,'(\\b[0-9A-Z]{4}\\b)','-0000\\1-'),'(\\b[0-9A-Z]{5}\\b)','-000\\1-'),'[ -]','')) AS CHAR CHARACTER SET utf32) USING utf8mb4) COLLATE utf8mb4_bin AS str, + HEX(WEIGHT_STRING(CONVERT(CAST(UNHEX(regexp_replace(regexp_replace(regexp_replace(a,'(\\b[0-9A-Z]{4}\\b)','-0000\\1-'),'(\\b[0-9A-Z]{5}\\b)','-000\\1-'),'[ -]','')) AS CHAR CHARACTER SET utf32) USING utf8mb4) COLLATE utf8mb4_unicode_520_ci)) as ws, + REPLACE(REPLACE(REGEXP_REPLACE(b,'[[][.*](....)[.]....[.]....[.].{4,5}]','-\\1-'),'-0000-',''),'-','') AS wd, + c +FROM allkeys_txt +WHERE a RLIKE '^[0-9A-Z]'; +ALTER TABLE allkeys ADD KEY(str(3)); + +# +# Test explicit weights +# Built-in default contractions are not supported. +# The (NOT LIKE '% %') part of the condition filters out contractions. + +SELECT COUNT(*), SUM(ws<>wd) FROM allkeys WHERE a NOT LIKE '% %'; +SELECT a, ws, wd FROM allkeys WHERE ws<>wd AND a NOT LIKE '% %'; + + +# +# Test implicit weights +# Non-BMP characters all have the same weight FFFD. +# + +SELECT + HEX(code), + HEX(WEIGHT_STRING(str COLLATE utf8mb4_unicode_520_ci)) AS ws, + CASE + WHEN code >= 0x3400 AND code <= 0x4DB5 THEN + CONCAT(LPAD(HEX(0xFB80 + (code >> 15)),4,'0'), + LPAD(HEX(0x8000 | (code & 0x7FFF)),4,'0')) + WHEN code >= 0x4E00 AND code <= 0x9FA5 THEN + CONCAT(LPAD(HEX(0xFB40 + (code >> 15)),4,'0'), + LPAD(HEX(0x8000 | (code & 0x7FFF)),4,'0')) + ELSE + CONCAT(LPAD(HEX(0xFBC0 + (code >> 15)),4,'0'), + LPAD(HEX(0x8000 | (code & 0x7FFF)),4,'0')) + END AS wd +FROM allchars +LEFT OUTER JOIN allkeys USING (str) +WHERE allkeys.str IS NULL +HAVING ws<>wd +ORDER BY HEX(str); + +DROP TABLE allkeys_txt; +DROP TABLE allkeys; +DROP TABLE allchars; + +--echo # +--echo # End of 10.8 tests +--echo # diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index f47920c0e33..8c936f3374a 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -122,42 +122,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.max_c > 214" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "t2.a > v1.a", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and max_c > 214", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.max_c > 214" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "t2.a > v1.a", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and max_c > 214", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from @@ -198,42 +208,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.max_c > 300", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and max_c > 300", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.max_c > 300", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and max_c > 300", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } # extracted or formula : pushing into HAVING @@ -277,42 +297,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.max_c > 400 or v1.max_c < 135" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.max_c > 400 and t2.a > v1.a or v1.max_c < 135 and t2.a < v1.a", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and (max_c > 400 or max_c < 135)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.max_c > 400 or v1.max_c < 135" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.max_c > 400 and t2.a > v1.a or v1.max_c < 135 and t2.a < v1.a", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and (max_c > 400 or max_c < 135)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where @@ -345,42 +375,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.max_c > 300 or v1.max_c < 135" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.b = t2.b and v1.max_c > 300 and v1.avg_c > t2.d or v1.a = t2.a and v1.max_c < 135 and v1.max_c < t2.c", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and (max_c > 300 or max_c < 135)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.max_c > 300 or v1.max_c < 135" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.b = t2.b and v1.max_c > 300 and v1.avg_c > t2.d or v1.a = t2.a and v1.max_c < 135 and v1.max_c < t2.c", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and (max_c > 300 or max_c < 135)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE @@ -402,43 +442,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a > 6" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "t2.b > v1.b", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 6" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a > 6" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "t2.b > v1.b", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 6" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v2,t2 where (v2.b>25) and (t2.a<v2.a); @@ -469,43 +519,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v2.b > 25" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "t2.a < v2.a", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5 and t1.b > 25" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v2.b > 25" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "t2.a < v2.a", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5 and t1.b > 25" + } + } + ] + } } } } } } - } + ] } } # extracted or formula : pushing into WHERE @@ -557,43 +617,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a > 7 or v1.a < 2" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.a > 7 and t2.c < v1.max_c or v1.a < 2 and t2.b < v1.b", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 7 or t1.a < 2" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a > 7 or v1.a < 2" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.a > 7 and t2.c < v1.max_c or v1.a < 2 and t2.b < v1.b", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 7 or t1.a < 2" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v2,t2 where @@ -638,43 +708,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v2.a > 7 or v2.a > 5" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v2.a > 7 and t2.c < v2.max_c or v2.a > 5 and t2.b < v2.b", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5 and (t1.a > 7 or t1.a > 5)" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v2.a > 7 or v2.a > 5" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v2.a > 7 and t2.c < v2.max_c or v2.a > 5 and t2.b < v2.b", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5 and (t1.a > 7 or t1.a > 5)" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where @@ -705,43 +785,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a > 4 or v1.a < 2" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.a > 4 and v1.b > t2.b and v1.max_c = t2.d or v1.a < 2 and v1.max_c < t2.c and v1.max_c = t2.d", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 4 or t1.a < 2" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a > 4 or v1.a < 2" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.a > 4 and v1.b > t2.b and v1.max_c = t2.d or v1.a < 2 and v1.max_c < t2.c and v1.max_c = t2.d", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 4 or t1.a < 2" + } + } + ] + } } } } } } - } + ] } } # conjunctive subformulas : pushing into HAVING and WHERE @@ -765,43 +855,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a < 2 and v1.max_c > 400" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "t2.b > v1.b", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and max_c > 400", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 2" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a < 2 and v1.max_c > 400" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "t2.b > v1.b", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and max_c > 400", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 2" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v_double as v,t2_double as t where @@ -836,43 +936,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v.avg_a > 0.45 and v.b > 10", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "avg_a < 22.333 and avg_a > 0.45", - "filesort": { - "sort_key": "t1_double.b, t1_double.c", - "temporary_table": { - "table": { - "table_name": "t1_double", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t1_double.b > 12.2 and t1_double.b > 10" + "nested_loop": [ + { + "table": { + "table_name": "t", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v.avg_a > 0.45 and v.b > 10", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "avg_a < 22.333 and avg_a > 0.45", + "filesort": { + "sort_key": "t1_double.b, t1_double.c", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1_double", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t1_double.b > 12.2 and t1_double.b > 10" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v_decimal as v,t2_decimal as t where @@ -895,43 +1005,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "3", - "used_key_parts": ["a"], - "ref": ["test.t.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v.avg_c > 15 and v.b > 1", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "avg_c > 12 and avg_c > 15", - "filesort": { - "sort_key": "t1_decimal.a, t1_decimal.b", - "temporary_table": { - "table": { - "table_name": "t1_decimal", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t1_decimal.b > 1" + "nested_loop": [ + { + "table": { + "table_name": "t", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "3", + "used_key_parts": ["a"], + "ref": ["test.t.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v.avg_c > 15 and v.b > 1", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "avg_c > 12 and avg_c > 15", + "filesort": { + "sort_key": "t1_decimal.a, t1_decimal.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1_decimal", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t1_decimal.b > 1" + } + } + ] + } } } } } } - } + ] } } # extracted or formula : pushing into HAVING and WHERE @@ -977,43 +1097,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a > 7 and v1.max_c > 300 or v1.a < 4 and v1.max_c < 500" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.a > 7 and v1.max_c > 300 and t2.c < v1.max_c or v1.a < 4 and v1.max_c < 500 and t2.b < v1.b", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and (t1.a > 7 and max_c > 300 or t1.a < 4 and max_c < 500)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 7 or t1.a < 4" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a > 7 and v1.max_c > 300 or v1.a < 4 and v1.max_c < 500" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.a > 7 and v1.max_c > 300 and t2.c < v1.max_c or v1.a < 4 and v1.max_c < 500 and t2.b < v1.b", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and (t1.a > 7 and max_c > 300 or t1.a < 4 and max_c < 500)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 7 or t1.a < 4" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where ((v1.a<2) and (v1.max_c>120)) or (v1.a>7); @@ -1066,43 +1196,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a < 2 and v1.max_c > 120 or v1.a > 7" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.a < 2 and v1.max_c > 120 or v1.a > 7", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and (t1.a < 2 and max_c > 120 or t1.a > 7)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 2 or t1.a > 7" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a < 2 and v1.max_c > 120 or v1.a > 7" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.a < 2 and v1.max_c > 120 or v1.a > 7", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and (t1.a < 2 and max_c > 120 or t1.a > 7)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 2 or t1.a > 7" + } + } + ] + } } } } } } - } + ] } } # extracted or formulas : pushing into WHERE and HAVING @@ -1144,43 +1284,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a < 2 and v1.max_c > 120 or v1.a > 7" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.b = t2.b and v1.a < 2 and v1.max_c > 120 or v1.a > 7", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and (t1.a < 2 and max_c > 120 or t1.a > 7)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 2 or t1.a > 7" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a < 2 and v1.max_c > 120 or v1.a > 7" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.b = t2.b and v1.a < 2 and v1.max_c > 120 or v1.a > 7", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and (t1.a < 2 and max_c > 120 or t1.a > 7)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 2 or t1.a > 7" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where @@ -1211,43 +1361,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a < 2 and v1.max_c < 200 or v1.a > 4" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.a < 2 and v1.max_c < 200 and t2.c > v1.max_c and v1.max_c = t2.d or v1.max_c = t2.c and v1.a > 4 and t2.c < 500 and t2.b < v1.b", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and (t1.a < 2 and max_c < 200 or t1.a > 4 and max_c < 500)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 2 or t1.a > 4" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a < 2 and v1.max_c < 200 or v1.a > 4" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.a < 2 and v1.max_c < 200 and t2.c > v1.max_c and v1.max_c = t2.d or v1.max_c = t2.c and v1.a > 4 and t2.c < 500 and t2.b < v1.b", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and (t1.a < 2 and max_c < 200 or t1.a > 4 and max_c < 500)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 2 or t1.a > 4" + } + } + ] + } } } } } } - } + ] } } # prepare of a query containing extracted or formula @@ -1288,42 +1448,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.max_c > 400 or v1.max_c < 135" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.max_c > 400 and t2.a > v1.a or v1.max_c < 135 and t2.a < v1.a", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and (max_c > 400 or max_c < 135)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.max_c > 400 or v1.max_c < 135" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.max_c > 400 and t2.a > v1.a or v1.max_c < 135 and t2.a < v1.a", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and (max_c > 400 or max_c < 135)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } execute stmt; @@ -1331,42 +1501,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.max_c > 400 or v1.max_c < 135" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.max_c > 400 and t2.a > v1.a or v1.max_c < 135 and t2.a < v1.a", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and (max_c > 400 or max_c < 135)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.max_c > 400 or v1.max_c < 135" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.max_c > 400 and t2.a > v1.a or v1.max_c < 135 and t2.a < v1.a", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and (max_c > 400 or max_c < 135)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } deallocate prepare stmt; @@ -1390,43 +1570,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a = 1 and t2.b is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["test.t2.b"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.a = 1", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a = 1" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a = 1 and t2.b is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t2.b"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.a = 1", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a = 1" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where (v1.a=5) and (v1.max_c=t2.d); @@ -1445,43 +1635,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.d is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["max_c"], - "ref": ["test.t2.d"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.a = 5 and v1.max_c = t2.d", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a = 5" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.d is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["max_c"], + "ref": ["test.t2.d"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.a = 5 and v1.max_c = t2.d", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a = 5" + } + } + ] + } } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE using equalities @@ -1507,42 +1707,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a < 5 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 5" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a < 5 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 5" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where (v1.a=v1.b) and (v1.a=t2.a); @@ -1559,42 +1769,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "10", - "used_key_parts": ["a", "b"], - "ref": ["test.t2.a", "test.t2.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b = t1.a" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "10", + "used_key_parts": ["a", "b"], + "ref": ["test.t2.a", "test.t2.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b = t1.a" + } + } + ] + } } } } } } - } + ] } } # conjunctive subformula : pushing into HAVING using equalities @@ -1616,41 +1836,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.c > 150 and t2.c is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["max_c"], - "ref": ["test.t2.c"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and max_c > 150", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.c > 150 and t2.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["max_c"], + "ref": ["test.t2.c"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and max_c > 150", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } # extracted and formula : pushing into WHERE @@ -1669,38 +1899,48 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a = 3" - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a = 3 and v1.b = 3" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a = 3" + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", + { + "block-nl-join": { "table": { - "table_name": "t1", + "table_name": "<derived2>", "access_type": "ALL", "rows": 20, "filtered": 100, - "attached_condition": "t1.a = 3 and t1.b = 3" + "attached_condition": "v1.a = 3 and v1.b = 3" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a = 3 and t1.b = 3" + } + } + ] + } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where (v1.a=1) and (v1.b=21) and (t2.a=2); @@ -1719,38 +1959,48 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a = 2" - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a = 1 and v1.b = 21" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a = 2" + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", + { + "block-nl-join": { "table": { - "table_name": "t1", + "table_name": "<derived2>", "access_type": "ALL", "rows": 20, "filtered": 100, - "attached_condition": "t1.a = 1 and t1.b = 21" + "attached_condition": "v1.a = 1 and v1.b = 21" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.b = 21" + } + } + ] + } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v_char as v,t2_char as t where @@ -1775,43 +2025,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "v.a = 'c' and v.b < 'Hermes'", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 9", - "filesort": { - "sort_key": "t1_char.b", - "temporary_table": { - "table": { - "table_name": "t1_char", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t1_char.a = 'c' and t1_char.b < 'Hermes'" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "v.a = 'c' and v.b < 'Hermes'", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 9", + "filesort": { + "sort_key": "t1_char.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1_char", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t1_char.a = 'c' and t1_char.b < 'Hermes'" + } + } + ] + } } } } } - } - }, - "block-nl-join": { - "table": { - "table_name": "t", - "access_type": "ALL", - "rows": 12, - "filtered": 100 }, - "buffer_type": "flat", - "buffer_size": "220", - "join_type": "BNL", - "attached_condition": "t.b = v.b or v.max_c > 20" - } + { + "block-nl-join": { + "table": { + "table_name": "t", + "access_type": "ALL", + "rows": 12, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "220", + "join_type": "BNL", + "attached_condition": "t.b = v.b or v.max_c > 20" + } + } + ] } } # extracted and formula : pushing into WHERE using equalities @@ -1848,42 +2108,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "(t.b > 1 or t.b = 1) and t.b is not null and t.b is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "6", - "used_key_parts": ["a", "b"], - "ref": ["test.t.b", "test.t.b"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "avg_c > 12", - "filesort": { - "sort_key": "t1_decimal.a, t1_decimal.b", - "temporary_table": { - "table": { - "table_name": "t1_decimal", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t1_decimal.b = t1_decimal.a and (t1_decimal.a > 1 or t1_decimal.a = 1)" + "nested_loop": [ + { + "table": { + "table_name": "t", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "(t.b > 1 or t.b = 1) and t.b is not null and t.b is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "6", + "used_key_parts": ["a", "b"], + "ref": ["test.t.b", "test.t.b"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "avg_c > 12", + "filesort": { + "sort_key": "t1_decimal.a, t1_decimal.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1_decimal", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t1_decimal.b = t1_decimal.a and (t1_decimal.a > 1 or t1_decimal.a = 1)" + } + } + ] + } } } } } } - } + ] } } # extracted or formula : pushing into HAVING using equalities @@ -1917,42 +2187,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a < 4 or t2.c > 150" - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a < 4 or t2.c > 150" + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.a = t2.a and t2.a < 4 or v1.max_c = t2.c and t2.c > 150", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and (t1.a < 4 or max_c > 150)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.a = t2.a and t2.a < 4 or v1.max_c = t2.c and t2.c > 150", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and (t1.a < 4 or max_c > 150)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } # conjunctive subformulas : pushing into WHERE and HAVING using equalities @@ -1976,42 +2256,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a > 5 and t2.c > 250 and t2.a is not null and t2.c is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "10", - "used_key_parts": ["a", "max_c"], - "ref": ["test.t2.a", "test.t2.c"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and max_c > 250", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a > 5 and t2.c > 250 and t2.a is not null and t2.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "10", + "used_key_parts": ["a", "max_c"], + "ref": ["test.t2.a", "test.t2.c"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and max_c > 250", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5" + } + } + ] + } } } } } } - } + ] } } # conjunctive subformulas : pushing into WHERE and HAVING @@ -2046,43 +2336,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a = 8" - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a = 8 and v1.max_c = 404" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a = 8" + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c = 404", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a = 8" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a = 8 and v1.max_c = 404" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c = 404", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a = 8" + } + } + ] + } } } } } } - } + ] } } # conjunctive subformulas : pushing into WHERE and HAVING @@ -2106,43 +2406,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.d is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["max_c"], - "ref": ["test.t2.d"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.a > 3 and v1.max_c > 200 and t2.b < v1.b and t2.d = v1.max_c", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and max_c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 3" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.d is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["max_c"], + "ref": ["test.t2.d"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.a > 3 and v1.max_c > 200 and t2.b < v1.b and t2.d = v1.max_c", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and max_c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 3" + } + } + ] + } } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE @@ -2166,43 +2476,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t.c is not null and t.c is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "18", - "used_key_parts": ["b", "c"], - "ref": ["test.t.c", "test.t.c"], - "rows": 2, - "filtered": 100, - "attached_condition": "t.c > 10 or v.a = 1", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "avg_a < 22.333 and (t1_double.b > 10 or t1_double.a = 1)", - "filesort": { - "sort_key": "t1_double.b, t1_double.c", - "temporary_table": { - "table": { - "table_name": "t1_double", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t1_double.c = t1_double.b and t1_double.b > 12.2" + "nested_loop": [ + { + "table": { + "table_name": "t", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t.c is not null and t.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "18", + "used_key_parts": ["b", "c"], + "ref": ["test.t.c", "test.t.c"], + "rows": 2, + "filtered": 100, + "attached_condition": "t.c > 10 or v.a = 1", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "avg_a < 22.333 and (t1_double.b > 10 or t1_double.a = 1)", + "filesort": { + "sort_key": "t1_double.b, t1_double.c", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1_double", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t1_double.c = t1_double.b and t1_double.b > 12.2" + } + } + ] + } } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE @@ -2231,43 +2551,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t.c > 18 and t.c is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "9", - "used_key_parts": ["c"], - "ref": ["test.t.c"], - "rows": 2, - "filtered": 100, - "attached_condition": "v.a > 0.2 or v.b < 17 or t.c > 17", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "avg_a < 22.333 and (t1_double.a > 0.2 or t1_double.b < 17 or t1_double.c > 17)", - "filesort": { - "sort_key": "t1_double.b, t1_double.c", - "temporary_table": { - "table": { - "table_name": "t1_double", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t1_double.b > 12.2 and t1_double.c > 18" + "nested_loop": [ + { + "table": { + "table_name": "t", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t.c > 18 and t.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "9", + "used_key_parts": ["c"], + "ref": ["test.t.c"], + "rows": 2, + "filtered": 100, + "attached_condition": "v.a > 0.2 or v.b < 17 or t.c > 17", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "avg_a < 22.333 and (t1_double.a > 0.2 or t1_double.b < 17 or t1_double.c > 17)", + "filesort": { + "sort_key": "t1_double.b, t1_double.c", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1_double", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t1_double.b > 12.2 and t1_double.c > 18" + } + } + ] + } } } } } } - } + ] } } # extracted or formula : pushing into WHERE @@ -2327,42 +2657,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "(v.a > 4 or v.a = 2 or v.b > 3) and v.avg_c = 13", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "avg_c > 12 and avg_c = 13", - "filesort": { - "sort_key": "t1_decimal.a, t1_decimal.b", - "temporary_table": { - "table": { - "table_name": "t1_decimal", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t1_decimal.a > 4 or t1_decimal.a = 2 or t1_decimal.b > 3" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "(v.a > 4 or v.a = 2 or v.b > 3) and v.avg_c = 13", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "avg_c > 12 and avg_c = 13", + "filesort": { + "sort_key": "t1_decimal.a, t1_decimal.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1_decimal", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t1_decimal.a > 4 or t1_decimal.a = 2 or t1_decimal.b > 3" + } + } + ] + } } } } } - } - }, - "block-nl-join": { - "table": { - "table_name": "t", - "access_type": "ALL", - "rows": 9, - "filtered": 100 }, - "buffer_type": "flat", - "buffer_size": "162", - "join_type": "BNL" - } + { + "block-nl-join": { + "table": { + "table_name": "t", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "162", + "join_type": "BNL" + } + } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from @@ -2391,43 +2731,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "10", - "used_key_parts": ["a", "b"], - "ref": ["test.t2.a", "test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.max_c > 300", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and max_c > 300", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b = t1.a and t1.a > 5" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "10", + "used_key_parts": ["a", "b"], + "ref": ["test.t2.a", "test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.max_c > 300", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and max_c > 300", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b = t1.a and t1.a > 5" + } + } + ] + } } } } } } - } + ] } } # nothing to push @@ -2457,41 +2807,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a < 2 and t2.c > 900" - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a < 2 and t2.c > 900" + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where (v1.a=t2.a) and (v1.b=t2.b); @@ -2514,41 +2874,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null and t2.b is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "10", - "used_key_parts": ["a", "b"], - "ref": ["test.t2.a", "test.t2.b"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null and t2.b is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "10", + "used_key_parts": ["a", "b"], + "ref": ["test.t2.a", "test.t2.b"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where @@ -2585,41 +2955,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.a = t2.a or v1.b = t2.b and (v1.a = 1 or v1.a = 6)", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.a = t2.a or v1.b = t2.b and (v1.a = 1 or v1.a = 6)", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where (v1.a=1) or (v1.b=21) or (t2.a=2); @@ -2680,41 +3060,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.a = 1 or v1.b = 21 or t2.a = 2", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.a = 1 or v1.b = 21 or t2.a = 2", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where @@ -2747,42 +3137,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a < 2 and t2.c > 900" - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a < 2 and t2.c > 900" + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.a < t2.a or t2.a < 11", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.a < t2.a or t2.a < 11", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } # using several derived tables : nothing to push @@ -2814,71 +3214,87 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key1"], - "key": "key1", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key1"], + "key": "key1", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } - } - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v2.b < 50", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5 and t1.b < 50" + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v2.b < 50", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5 and t1.b < 50" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,v2,t2 where @@ -2929,72 +3345,88 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.b < 50" - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b < 50" + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.b is not null", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.b is not null", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } - } - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["v1.b"], - "rows": 2, - "filtered": 100, - "attached_condition": "v2.a = v1.a or v1.a = t2.a", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5" + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["v1.b"], + "rows": 2, + "filtered": 100, + "attached_condition": "v2.a = v1.a or v1.a = t2.a", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,v2,t2 where @@ -3025,71 +3457,87 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.a = t2.a or t2.c < 115", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.a = t2.a or t2.c < 115", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } - } - }, - "block-nl-join": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100 }, - "buffer_type": "incremental", - "buffer_size": "4Kb", - "join_type": "BNL", - "attached_condition": "v1.a = t2.a and v2.a = t2.a or v2.b > 13 and t2.c < 115", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5" + { + "block-nl-join": { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + }, + "buffer_type": "incremental", + "buffer_size": "4Kb", + "join_type": "BNL", + "attached_condition": "v1.a = t2.a and v2.a = t2.a or v2.b > 13 and t2.c < 115", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5" + } + } + ] + } } } } } } - } + ] } } # using several derived tables : pushing in all tables @@ -3124,72 +3572,88 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.max_c < 300" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and max_c < 300", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.max_c < 300" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and max_c < 300", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } - } - }, - "block-nl-join": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v2.b < 50 or v2.b = 19" }, - "buffer_type": "incremental", - "buffer_size": "4Kb", - "join_type": "BNL", - "attached_condition": "(v2.a = v1.a or v1.a = t2.a) and (v2.b < 50 or v2.b = 19)", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5 and (t1.b < 50 or t1.b = 19)" + { + "block-nl-join": { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v2.b < 50 or v2.b = 19" + }, + "buffer_type": "incremental", + "buffer_size": "4Kb", + "join_type": "BNL", + "attached_condition": "(v2.a = v1.a or v1.a = t2.a) and (v2.b < 50 or v2.b = 19)", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5 and (t1.b < 50 or t1.b = 19)" + } + } + ] + } } } } } } - } + ] } } # using several derived tables : pushing only in one table @@ -3215,72 +3679,88 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null and t2.a is not null and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key1"], - "key": "key1", - "key_length": "10", - "used_key_parts": ["a", "b"], - "ref": ["test.t2.a", "test.t2.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b = t1.a" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null and t2.a is not null and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key1"], + "key": "key1", + "key_length": "10", + "used_key_parts": ["a", "b"], + "ref": ["test.t2.a", "test.t2.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b = t1.a" + } + } + ] + } } } } } - } - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v2.max_c < 300", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707 and max_c < 300", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5" + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v2.max_c < 300", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707 and max_c < 300", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5" + } + } + ] + } } } } } } - } + ] } } # using several derived tables : pushing only in one table @@ -3303,72 +3783,88 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a = 1 and v1.b > 10" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.b is not null", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.b > 10" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a = 1 and v1.b > 10" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.b is not null", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.b > 10" + } + } + ] + } } } } } - } - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["v1.b"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5 and t1.b > 10" + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["v1.b"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5 and t1.b > 10" + } + } + ] + } } } } } } - } + ] } } # extracted or formula : pushing into WHERE @@ -3402,43 +3898,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "v.a = 'b' and (v.b = 'Vika' or v.b = 'Ali')", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 9", - "filesort": { - "sort_key": "t1_char.b", - "temporary_table": { - "table": { - "table_name": "t1_char", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t1_char.a = 'b' and (t1_char.b = 'Vika' or t1_char.b = 'Ali')" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "v.a = 'b' and (v.b = 'Vika' or v.b = 'Ali')", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 9", + "filesort": { + "sort_key": "t1_char.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1_char", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t1_char.a = 'b' and (t1_char.b = 'Vika' or t1_char.b = 'Ali')" + } + } + ] + } } } } } - } - }, - "block-nl-join": { - "table": { - "table_name": "t", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t.a = 'b'" }, - "buffer_type": "flat", - "buffer_size": "220", - "join_type": "BNL" - } + { + "block-nl-join": { + "table": { + "table_name": "t", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t.a = 'b'" + }, + "buffer_type": "flat", + "buffer_size": "220", + "join_type": "BNL" + } + } + ] } } # using several derived tables : pushing in all tables @@ -3499,103 +4005,125 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived4>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v3.b < 50 or v3.b = 33", - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "min_c > 109", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 10 and (t1.b < 50 or t1.b = 33)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived4>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v3.b < 50 or v3.b = 33", + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "min_c > 109", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 10 and (t1.b < 50 or t1.b = 33)" + } + } + ] + } } } } } - } - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.max_c < 500" }, - "buffer_type": "flat", - "buffer_size": "715", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and max_c < 500", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.max_c < 500" + }, + "buffer_type": "flat", + "buffer_size": "715", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and max_c < 500", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } - } - }, - "block-nl-join": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v2.max_c > 300" }, - "buffer_type": "incremental", - "buffer_size": "9Kb", - "join_type": "BNL", - "attached_condition": "v2.a = v1.a or v1.a = t2.a", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707 and max_c > 300", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5" + { + "block-nl-join": { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v2.max_c > 300" + }, + "buffer_type": "incremental", + "buffer_size": "9Kb", + "join_type": "BNL", + "attached_condition": "v2.a = v1.a or v1.a = t2.a", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707 and max_c > 300", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5" + } + } + ] + } } } } } } - } + ] } } # using several derived tables : pushing in all tables @@ -3636,73 +4164,89 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.b is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key1"], - "key": "key1", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["test.t2.b"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.max_c > 130 and v1.a is not null", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and max_c > 130", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key1"], + "key": "key1", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t2.b"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.max_c > 130 and v1.a is not null", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and max_c > 130", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5" + } + } + ] + } } } } } - } - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["v1.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v2.min_c < 130", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "min_c < 707 and min_c < 130", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5" + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["v1.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v2.min_c < 130", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "min_c < 707 and min_c < 130", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5" + } + } + ] + } } } } } } - } + ] } } # using several derived tables : pushing in all tables @@ -3776,103 +4320,125 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.avg_c < 400 or v1.a > 1" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "(v1.avg_c < 400 or v1.a > 1) and v1.a is not null and v1.b is not null", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and (avg_c < 400 or t1.a > 1)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.avg_c < 400 or v1.a > 1" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "(v1.avg_c < 400 or v1.a > 1) and v1.a is not null and v1.b is not null", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and (avg_c < 400 or t1.a > 1)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5" + } + } + ] + } } } } } - } - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["v1.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v2.min_c < 200", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "min_c < 707 and min_c < 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5" + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["v1.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v2.min_c < 200", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "min_c < 707 and min_c < 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5" + } + } + ] + } } } } } - } - }, - "table": { - "table_name": "<derived4>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["v1.b"], - "rows": 2, - "filtered": 100, - "attached_condition": "v3.avg_c > 170 or v3.a < 5", - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "avg_c > 170 or t1.a < 5", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 8" + }, + { + "table": { + "table_name": "<derived4>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["v1.b"], + "rows": 2, + "filtered": 100, + "attached_condition": "v3.avg_c > 170 or v3.a < 5", + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "avg_c > 170 or t1.a < 5", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 8" + } + } + ] + } } } } } } - } + ] } } # extracted or formula : pushing into HAVING @@ -3921,43 +4487,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "(v1.a = 1 or v1.max_c < 300) and v1.b > 25" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.a = 1 or v1.max_c < 300", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and (t1.a = 1 or max_c < 300)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b > 25" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "(v1.a = 1 or v1.max_c < 300) and v1.b > 25" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.a = 1 or v1.max_c < 300", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and (t1.a = 1 or max_c < 300)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b > 25" + } + } + ] + } } } } } } - } + ] } } # extracted and formula : pushing into WHERE @@ -3992,43 +4568,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.max_c > 300 and v1.b < 30", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 707 and max_c > 300", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5 and t1.b < 30" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.max_c > 300 and v1.b < 30", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 707 and max_c > 300", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5 and t1.b < 30" + } + } + ] + } } } } } } - } + ] } } # using query with union @@ -4070,86 +4656,106 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.c > 800 and t2.b is not null" - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["test.t2.b"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.a < 5", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 5" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.c > 800 and t2.b is not null" + } + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t2.b"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.a < 5", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 5" + } + } + ] + } } } } } } - } + ] } }, { "query_block": { "select_id": 2, "operation": "UNION", - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.d > 800" - }, - "block-nl-join": { - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.max_c > 100 and v1.a > 7" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.d > 800" + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707 and max_c > 100", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 7" + { + "block-nl-join": { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.max_c > 100 and v1.a > 7" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707 and max_c > 100", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 7" + } + } + ] + } } } } } } - } + ] } } ] @@ -4214,85 +4820,105 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.b = 19" - }, - "block-nl-join": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.b = 19 and v1.a < 5" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b = 19" + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b = 19 and t1.a < 5" + { + "block-nl-join": { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.b = 19 and v1.a < 5" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b = 19 and t1.a < 5" + } + } + ] + } } } } } } - } + ] } }, { "query_block": { "select_id": 2, "operation": "UNION", - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.max_c > 400 or v1.avg_c > 270" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "(v1.max_c > 400 or v1.avg_c > 270) and v1.a < t2.a", - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707 and (max_c > 400 or avg_c > 270)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.max_c > 400 or v1.avg_c > 270" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "(v1.max_c > 400 or v1.avg_c > 270) and v1.a < t2.a", + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707 and (max_c > 400 or avg_c > 270)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } ] @@ -4369,85 +4995,105 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a = 1 or v1.a = 6" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "(v1.a = t2.a or v1.b = t2.b) and (v1.a = 1 or v1.a = 6)", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a = 1 or t1.a = 6" + { + "block-nl-join": { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a = 1 or v1.a = 6" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "(v1.a = t2.a or v1.b = t2.b) and (v1.a = 1 or v1.a = 6)", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a = 1 or t1.a = 6" + } + } + ] + } } } } } } - } + ] } }, { "query_block": { "select_id": 2, "operation": "UNION", - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a > 3 and v1.b > 27 or v1.max_c > 550" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.a > 3 and v1.b > 27 or v1.max_c > 550", - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707 and (t1.a > 3 and t1.b > 27 or max_c > 550)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a > 3 and v1.b > 27 or v1.max_c > 550" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.a > 3 and v1.b > 27 or v1.max_c > 550", + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707 and (t1.a > 3 and t1.b > 27 or max_c > 550)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } ] @@ -4525,131 +5171,161 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a = 1" - }, - "block-nl-join": { - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a = 1 and (v1.max_c < 500 or v1.avg_c > 500)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a = 1" + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v1.max_c < 500 or v1.avg_c > 500", - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707 and (max_c < 500 or avg_c > 500)", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a = 1" + { + "block-nl-join": { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a = 1 and (v1.max_c < 500 or v1.avg_c > 500)" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v1.max_c < 500 or v1.avg_c > 500", + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707 and (max_c < 500 or avg_c > 500)", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a = 1" + } + } + ] + } } } } } } - } + ] } }, { "query_block": { "select_id": 2, "operation": "UNION", - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a < 2" - }, - "block-nl-join": { - "table": { - "table_name": "<derived5>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v2.b > 10" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a < 2" + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v2.a < t2.b or v2.max_c > 200", - "materialized": { - "query_block": { - "select_id": 5, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5 and t1.b > 10" + { + "block-nl-join": { + "table": { + "table_name": "<derived5>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v2.b > 10" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v2.a < t2.b or v2.max_c > 200", + "materialized": { + "query_block": { + "select_id": 5, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5 and t1.b > 10" + } + } + ] + } } } } } } - } + ] } }, { "query_block": { "select_id": 3, "operation": "UNION", - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.c is not null" - }, - "table": { - "table_name": "<derived6>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["max_c"], - "ref": ["test.t2.c"], - "rows": 2, - "filtered": 100, - "attached_condition": "v2.b < 10", - "materialized": { - "query_block": { - "select_id": 6, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5 and t1.b < 10" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.c is not null" + } + }, + { + "table": { + "table_name": "<derived6>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["max_c"], + "ref": ["test.t2.c"], + "rows": 2, + "filtered": 100, + "attached_condition": "v2.b < 10", + "materialized": { + "query_block": { + "select_id": 6, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5 and t1.b < 10" + } + } + ] + } } } } } } - } + ] } } ] @@ -4692,71 +5368,85 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 40, - "filtered": 100, - "attached_condition": "v_union.a < 3 and v_union.c > 100" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3>", + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 109 and c > 100", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 10 and t1.a < 3" + "rows": 40, + "filtered": 100, + "attached_condition": "v_union.a < 3 and v_union.c > 100" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 109 and c > 100", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 10 and t1.a < 3" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "having_condition": "c < 300 and c > 100", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a < 3" + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "having_condition": "c < 300 and c > 100", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a < 3" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using derived table with union @@ -4800,72 +5490,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 40, - "filtered": 100, - "attached_condition": "(v_union.a < 2 or v_union.c > 800) and v_union.b > 12" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "v_union.a < 2 or v_union.c > 800", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3>", + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 109 and (t1.a < 2 or c > 800)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 10 and t1.b > 12" + "rows": 40, + "filtered": 100, + "attached_condition": "(v_union.a < 2 or v_union.c > 800) and v_union.b > 12" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "v_union.a < 2 or v_union.c > 800", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 109 and (t1.a < 2 or c > 800)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 10 and t1.b > 12" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "having_condition": "c < 300 and (t1.a < 2 or c > 800)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.b > 12" + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "having_condition": "c < 300 and (t1.a < 2 or c > 800)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.b > 12" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using derived table with union @@ -4896,72 +5600,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a = 1" - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 40, - "filtered": 100, - "attached_condition": "v_union.a = 1 and v_union.c < 200" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a = 1" + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3>", + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 109 and c < 200", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a = 1" + "rows": 40, + "filtered": 100, + "attached_condition": "v_union.a = 1 and v_union.c < 200" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 109 and c < 200", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a = 1" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "having_condition": "c < 300 and c < 200", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.b > 10" + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "having_condition": "c < 300 and c < 200", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.b > 10" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v_char as v,t2_char as t where @@ -4990,43 +5708,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "2", - "used_key_parts": ["a"], - "ref": ["test.t.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v.b = 'Vika' and v.max_c > 2", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 9 and max_c > 2", - "filesort": { - "sort_key": "t1_char.a", - "temporary_table": { - "table": { - "table_name": "t1_char", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t1_char.b = 'Vika'" + "nested_loop": [ + { + "table": { + "table_name": "t", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "2", + "used_key_parts": ["a"], + "ref": ["test.t.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v.b = 'Vika' and v.max_c > 2", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 9 and max_c > 2", + "filesort": { + "sort_key": "t1_char.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1_char", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t1_char.b = 'Vika'" + } + } + ] + } } } } } } - } + ] } } # using derived table with union @@ -5063,68 +5791,37 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a = 1" - }, - "block-nl-join": { - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a = 1" - }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a = 1" - } - } - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a = 1" } - } - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 40, - "filtered": 100, - "attached_condition": "v_union.a = 1" }, - "buffer_type": "incremental", - "buffer_size": "4Kb", - "join_type": "BNL", - "attached_condition": "v_union.c > 800 or v1.max_c > 200", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3>", + { + "block-nl-join": { + "table": { + "table_name": "<derived4>", "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 109", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a = 1" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { "table": { "table_name": "t1", "access_type": "ALL", @@ -5133,33 +5830,84 @@ EXPLAIN "attached_condition": "t1.a = 1" } } - } + ] } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "having_condition": "c < 300", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.b > 10" + } + } + } + } + }, + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 40, + "filtered": 100, + "attached_condition": "v_union.a = 1" + }, + "buffer_type": "incremental", + "buffer_size": "4Kb", + "join_type": "BNL", + "attached_condition": "v_union.c > 800 or v1.max_c > 200", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 109", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a = 1" + } + } + ] + } + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "having_condition": "c < 300", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.b > 10" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using derived table with union @@ -5199,91 +5947,109 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "(t2.a = 6 or t2.a = 8) and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 6, - "filtered": 100, - "attached_condition": "v.c > 200", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3,4>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 109 and c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 10 and (t1.a = 6 or t1.a = 8)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "(t2.a = 6 or t2.a = 8) and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 6, + "filtered": 100, + "attached_condition": "v.c > 200", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3,4>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 109 and c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 10 and (t1.a = 6 or t1.a = 8)" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "having_condition": "c < 300 and c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b > 10 and (t1.a = 6 or t1.a = 8)" + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "having_condition": "c < 300 and c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b > 10 and (t1.a = 6 or t1.a = 8)" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 4, - "operation": "UNION", - "having_condition": "c < 707 and c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.c > 300 and (t1.a = 6 or t1.a = 8)" + }, + { + "query_block": { + "select_id": 4, + "operation": "UNION", + "having_condition": "c < 707 and c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.c > 300 and (t1.a = 6 or t1.a = 8)" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using derived table with union of selects without aggregation @@ -5368,60 +6134,74 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 4, - "filtered": 100, - "attached_condition": "v.c > 6", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 10 and t1.a + 1 > 6" - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.c > 100 and t1.c > 6" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 4, + "filtered": 100, + "attached_condition": "v.c > 6", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 10 and t1.a + 1 > 6" + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.c > 100 and t1.c > 6" + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } # using derived table with union of selects without aggregation @@ -5486,60 +6266,74 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 4, - "filtered": 100, - "attached_condition": "t2.a > 1 or v.b < 20", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 10 and (t1.a > 1 or t1.b < 20)" - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.c > 100 and (t1.a > 1 or t1.b < 20)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 4, + "filtered": 100, + "attached_condition": "t2.a > 1 or v.b < 20", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 10 and (t1.a > 1 or t1.b < 20)" + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.c > 100 and (t1.a > 1 or t1.b < 20)" + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } # using derived table with union of selects without aggregation @@ -5572,60 +6366,74 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 4, - "filtered": 100, - "attached_condition": "(v.b = 19 or v.b = 21) and (v.c < 3 or v.c > 600)", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 10 and (t1.b = 19 or t1.b = 21) and (t1.a + 1 < 3 or t1.a + 1 > 600)" - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.c > 100 and (t1.b = 19 or t1.b = 21) and (t1.c < 3 or t1.c > 600)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 4, + "filtered": 100, + "attached_condition": "(v.b = 19 or v.b = 21) and (v.c < 3 or v.c > 600)", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 10 and (t1.b = 19 or t1.b = 21) and (t1.a + 1 < 3 or t1.a + 1 > 600)" + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.c > 100 and (t1.b = 19 or t1.b = 21) and (t1.c < 3 or t1.c > 600)" + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } # using derived table with union of @@ -5655,66 +6463,80 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 4, - "filtered": 100, - "attached_condition": "v.b < 20", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 109", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 10 and t1.b < 20" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 4, + "filtered": 100, + "attached_condition": "v.b < 20", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 109", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 10 and t1.b < 20" + } + } + ] + } } } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.b < 20" + } + } + ] + } } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.b < 20" - } - } + ] } - ] + } } } } - } + ] } } # using derived table with union of @@ -5763,66 +6585,80 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 4, - "filtered": 100, - "attached_condition": "(t2.a < 3 or v.b < 40) and v.c > 500", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 109 and c > 500", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 10 and (t1.a < 3 or t1.b < 40)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 4, + "filtered": 100, + "attached_condition": "(t2.a < 3 or v.b < 40) and v.c > 500", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 109 and c > 500", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 10 and (t1.a < 3 or t1.b < 40)" + } + } + ] + } } } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b > 10 and (t1.a < 3 or t1.b < 40) and t1.c + 100 > 500" + } + } + ] + } } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b > 10 and (t1.a < 3 or t1.b < 40) and t1.c + 100 > 500" - } - } + ] } - ] + } } } } - } + ] } } # using embedded derived table : pushing the same conditions @@ -5873,78 +6709,96 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v4.a < 13", - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "v1.a, v1.b", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a < 15 and v1.a < 13", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 15 and t1.a < 13" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v4.a < 13", + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "v1.a, v1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a < 15 and v1.a < 13", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 15 and t1.a < 13" + } + } + ] + } + } + } } } } - } + ] } } } } } - } - }, - "block-nl-join": { - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a > 5 and v1.b > 12" }, - "buffer_type": "flat", - "buffer_size": "333", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5 and t1.b > 12" + { + "block-nl-join": { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a > 5 and v1.b > 12" + }, + "buffer_type": "flat", + "buffer_size": "333", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5 and t1.b > 12" + } + } + ] + } } } } } } - } + ] } } # using embedded view : nothing to push @@ -5975,89 +6829,109 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key1"], - "key": "key1", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "v1.a, v1.b", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a < 15", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 15" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key1"], + "key": "key1", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "v1.a, v1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a < 15", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 15" + } + } + ] + } + } + } } } } - } + ] } } } } } - } - }, - "table": { - "table_name": "<derived4>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.b > 30", - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b > 30" + }, + { + "table": { + "table_name": "<derived4>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.b > 30", + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b > 30" + } + } + ] + } } } } } } - } + ] } } # using embedded view : pushing different conditions @@ -6090,91 +6964,111 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a > 1 and t2.a is not null and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key1"], - "key": "key1", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v4.min_c > 100", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "min_c > 100", - "filesort": { - "sort_key": "v1.a, v1.b", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a < 15 and v1.a > 1", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 15 and t1.a > 1" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a > 1 and t2.a is not null and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key1"], + "key": "key1", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v4.min_c > 100", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "min_c > 100", + "filesort": { + "sort_key": "v1.a, v1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a < 15 and v1.a > 1", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 15 and t1.a > 1" + } + } + ] + } + } + } } } } - } + ] } } } } } - } - }, - "table": { - "table_name": "<derived4>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.b < 30", - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.b < 30" + }, + { + "table": { + "table_name": "<derived4>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.b < 30", + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.b < 30" + } + } + ] + } } } } } } - } + ] } } # using embedded view : pushing different conditions @@ -6292,89 +7186,109 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v4.b > 10 and v4.a > 1 or v4.b < 20" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "238", - "join_type": "BNL", - "attached_condition": "(v4.b > 10 and v4.a > 1 or v4.b < 20) and v4.a is not null", - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "v1.a, v1.b", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a < 15 and (v1.b > 10 and v1.a > 1 or v1.b < 20)", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 15 and (t1.b > 10 and t1.a > 1 or t1.b < 20)" + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v4.b > 10 and v4.a > 1 or v4.b < 20" + }, + "buffer_type": "flat", + "buffer_size": "238", + "join_type": "BNL", + "attached_condition": "(v4.b > 10 and v4.a > 1 or v4.b < 20) and v4.a is not null", + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "v1.a, v1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a < 15 and (v1.b > 10 and v1.a > 1 or v1.b < 20)", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 15 and (t1.b > 10 and t1.a > 1 or t1.b < 20)" + } + } + ] + } + } + } } } } - } + ] } } } } } - } - }, - "table": { - "table_name": "<derived4>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["v4.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.max_c > 200", - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707 and max_c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100 + }, + { + "table": { + "table_name": "<derived4>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["v4.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.max_c > 200", + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707 and max_c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } # using embedded view : pushing different conditions @@ -6401,78 +7315,96 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v4.a > 12 and v4.min_c < 300 and v4.b > 13 or v4.a < 1", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "v1.a > 12 and min_c < 300 and v1.b > 13 or v1.a < 1", - "filesort": { - "sort_key": "v1.a, v1.b", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a < 15 and (v1.a > 12 and v1.b > 13 or v1.a < 1)", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 15 and (t1.a > 12 and t1.b > 13 or t1.a < 1)" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v4.a > 12 and v4.min_c < 300 and v4.b > 13 or v4.a < 1", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "v1.a > 12 and min_c < 300 and v1.b > 13 or v1.a < 1", + "filesort": { + "sort_key": "v1.a, v1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a < 15 and (v1.a > 12 and v1.b > 13 or v1.a < 1)", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 15 and (t1.a > 12 and t1.b > 13 or t1.a < 1)" + } + } + ] + } + } + } } } } - } + ] } } } } } - } - }, - "block-nl-join": { - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 20, - "filtered": 100 }, - "buffer_type": "flat", - "buffer_size": "333", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5" + { + "block-nl-join": { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "333", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5" + } + } + ] + } } } } } } - } + ] } } # using embedded view : pushing different conditions @@ -6500,78 +7432,96 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v4.b = v4.a and v4.min_c < 100 and v4.a is not null", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "min_c < 100", - "filesort": { - "sort_key": "v1.a, v1.b", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.b = v1.a and v1.a < 15", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b = t1.a and t1.a < 15" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v4.b = v4.a and v4.min_c < 100 and v4.a is not null", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "min_c < 100", + "filesort": { + "sort_key": "v1.a, v1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.b = v1.a and v1.a < 15", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b = t1.a and t1.a < 15" + } + } + ] + } + } + } } } } - } + ] } } } } } - } - }, - "table": { - "table_name": "<derived4>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["v4.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5" + }, + { + "table": { + "table_name": "<derived4>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["v4.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5" + } + } + ] + } } } } } } - } + ] } } # using embedded view : pushing the same conditions @@ -6599,77 +7549,95 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v4.b = v4.a and v4.a < 30 and v4.a is not null", - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "v1.a, v1.b", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.b = v1.a and v1.a < 15 and v1.a < 30", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b = t1.a and t1.a < 15 and t1.a < 30" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v4.b = v4.a and v4.a < 30 and v4.a is not null", + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "v1.a, v1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.b = v1.a and v1.a < 15 and v1.a < 30", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b = t1.a and t1.a < 15 and t1.a < 30" + } + } + ] + } + } + } } } } - } + ] } } } } } - } - }, - "table": { - "table_name": "<derived4>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["v4.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5 and t1.b < 30" + }, + { + "table": { + "table_name": "<derived4>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["v4.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5 and t1.b < 30" + } + } + ] + } } } } } } - } + ] } } # using embedded view : pushing the same conditions @@ -6697,77 +7665,95 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v4.b = v4.a and (v4.a < 30 or v4.a > 2) and v4.a is not null", - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "v1.a, v1.b", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.b = v1.a and v1.a < 15 and (v1.a < 30 or v1.a > 2)", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.b = t1.a and t1.a < 15 and (t1.a < 30 or t1.a > 2)" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v4.b = v4.a and (v4.a < 30 or v4.a > 2) and v4.a is not null", + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "v1.a, v1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.b = v1.a and v1.a < 15 and (v1.a < 30 or v1.a > 2)", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.b = t1.a and t1.a < 15 and (t1.a < 30 or t1.a > 2)" + } + } + ] + } + } + } } } } - } + ] } } } } } - } - }, - "table": { - "table_name": "<derived4>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["v4.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5 and (t1.b < 30 or t1.b > 2)" + }, + { + "table": { + "table_name": "<derived4>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["v4.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5 and (t1.b < 30 or t1.b > 2)" + } + } + ] + } } } } } } - } + ] } } # using embedded view : pushing the same conditions @@ -6803,78 +7789,96 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "(v4.a < 12 and v4.b > 13 or v4.a > 10) and v4.min_c > 100 and v4.min_c is not null", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "min_c > 100", - "filesort": { - "sort_key": "v1.a, v1.b", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a < 15 and (v1.a < 12 and v1.b > 13 or v1.a > 10)", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 15 and (t1.a < 12 and t1.b > 13 or t1.a > 10)" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "(v4.a < 12 and v4.b > 13 or v4.a > 10) and v4.min_c > 100 and v4.min_c is not null", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "min_c > 100", + "filesort": { + "sort_key": "v1.a, v1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a < 15 and (v1.a < 12 and v1.b > 13 or v1.a > 10)", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 15 and (t1.a < 12 and t1.b > 13 or t1.a > 10)" + } + } + ] + } + } + } } } } - } + ] } } } } } - } - }, - "table": { - "table_name": "<derived4>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["max_c"], - "ref": ["v4.min_c"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707 and max_c > 100", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5" + }, + { + "table": { + "table_name": "<derived4>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["max_c"], + "ref": ["v4.min_c"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707 and max_c > 100", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5" + } + } + ] + } } } } } } - } + ] } } # using embedded view : pushing the same conditions @@ -6909,90 +7913,110 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.c > 100 and t2.c is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["min_c"], - "ref": ["test.t2.c"], - "rows": 2, - "filtered": 100, - "attached_condition": "v4.a < 12 and t2.b > 13 or v4.a > 10", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "min_c > 100", - "filesort": { - "sort_key": "v1.a, v1.b", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "v1.a < 15 and (v1.a < 12 or v1.a > 10)", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a < 15 and (t1.a < 12 or t1.a > 10)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.c > 100 and t2.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["min_c"], + "ref": ["test.t2.c"], + "rows": 2, + "filtered": 100, + "attached_condition": "v4.a < 12 and t2.b > 13 or v4.a > 10", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "min_c > 100", + "filesort": { + "sort_key": "v1.a, v1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "v1.a < 15 and (v1.a < 12 or v1.a > 10)", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a < 15 and (t1.a < 12 or t1.a > 10)" + } + } + ] + } + } + } } } } - } + ] } } } } } - } - }, - "block-nl-join": { - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 20, - "filtered": 100 }, - "buffer_type": "flat", - "buffer_size": "715", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 4, - "having_condition": "max_c < 707", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t1.a > 5" + { + "block-nl-join": { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 20, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "715", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 4, + "having_condition": "max_c < 707", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t1.a > 5" + } + } + ] + } } } } } } - } + ] } } drop view v1,v2,v3,v4; @@ -7136,47 +8160,61 @@ EXPLAIN "query_block": { "select_id": 1, "const_condition": "0 or <in_optimizer>(2,<exists>(subquery#3))", - "table": { - "table_name": "t1", - "access_type": "system", - "rows": 1, - "filtered": 100 - }, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t2.b = 2", - "first_match": "t1" - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "system", + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t2.b = 2", + "first_match": "t1" + } + } + ], "subqueries": [ { "query_block": { "select_id": 3, - "table": { - "table_name": "<derived5>", - "access_type": "index_subquery", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["c"], - "ref": ["func"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 5, - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 4, - "filtered": 100, - "attached_condition": "t3.c = 2" + "nested_loop": [ + { + "table": { + "table_name": "<derived5>", + "access_type": "index_subquery", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["c"], + "ref": ["func"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 5, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 4, + "filtered": 100, + "attached_condition": "t3.c = 2" + } + } + ] + } } } } - } + ] } } ] @@ -7220,52 +8258,66 @@ EXPLAIN "query_block": { "select_id": 1, "const_condition": "0 or <in_optimizer>(2,<exists>(subquery#3))", - "table": { - "table_name": "t1", - "access_type": "system", - "rows": 1, - "filtered": 100 - }, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t2.b = 2", - "first_match": "t1" - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "system", + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t2.b = 2", + "first_match": "t1" + } + } + ], "subqueries": [ { "query_block": { "select_id": 3, - "table": { - "table_name": "<derived5>", - "access_type": "index_subquery", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["d"], - "ref": ["func"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 5, - "having_condition": "s > 2", - "filesort": { - "sort_key": "t4.d", - "temporary_table": { - "table": { - "table_name": "t4", - "access_type": "ALL", - "rows": 5, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived5>", + "access_type": "index_subquery", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["d"], + "ref": ["func"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 5, + "having_condition": "s > 2", + "filesort": { + "sort_key": "t4.d", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } ] @@ -7295,35 +8347,47 @@ EXPLAIN "query_block": { "select_id": 1, "const_condition": "<in_optimizer>(1,exists(subquery#3))", - "table": { - "table_name": "t1", - "access_type": "system", - "rows": 1, - "filtered": 100 - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "system", + "rows": 1, + "filtered": 100 + } + } + ], "subqueries": [ { "query_block": { "select_id": 3, - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "v2.b = 1", - "materialized": { - "query_block": { - "select_id": 4, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t2.b = 1" + "nested_loop": [ + { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "v2.b = 1", + "materialized": { + "query_block": { + "select_id": 4, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t2.b = 1" + } + } + ] + } } } } - } + ] } } ] @@ -7352,35 +8416,45 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100 - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["test.t1.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "trigcond(v2.b is null) and trigcond(trigcond(t1.a is not null))", - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 2, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t1.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "trigcond(v2.b is null) and trigcond(trigcond(t1.a is not null))", + "materialized": { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } + } + ] + } } } } - } + ] } } DROP VIEW v2; @@ -7397,25 +8471,33 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "<nop>(v1.i <= 3)", - "materialized": { - "query_block": { - "select_id": 3, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "<nop>(t1.i <= 3)" + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "<nop>(v1.i <= 3)", + "materialized": { + "query_block": { + "select_id": 3, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "<nop>(t1.i <= 3)" + } + } + ] + } } } } - } + ] } } Warnings: @@ -7450,39 +8532,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "<in_optimizer>(t1.b,<exists>(subquery#2)) or t1.b = 100" - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "<in_optimizer>(t1.b,<exists>(subquery#2)) or t1.b = 100" + } + } + ], "subqueries": [ { "query_block": { "select_id": 2, - "table": { - "table_name": "<derived4>", - "access_type": "index_subquery", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "4", - "used_key_parts": ["pk2"], - "ref": ["func"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 4, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived4>", + "access_type": "index_subquery", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "4", + "used_key_parts": ["pk2"], + "ref": ["func"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 4, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] + } } } } - } + ] } } ] @@ -7500,39 +8594,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "<in_optimizer>(t1.b,<exists>(subquery#3)) or t1.b = 100" - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "<in_optimizer>(t1.b,<exists>(subquery#3)) or t1.b = 100" + } + } + ], "subqueries": [ { "query_block": { "select_id": 3, - "table": { - "table_name": "<derived4>", - "access_type": "index_subquery", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "4", - "used_key_parts": ["pk2"], - "ref": ["func"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 4, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived4>", + "access_type": "index_subquery", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "4", + "used_key_parts": ["pk2"], + "ref": ["func"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 4, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] + } } } } - } + ] } } ] @@ -7558,35 +8664,47 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "system", - "rows": 1, - "filtered": 100 - }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "system", + "rows": 1, + "filtered": 100 + } + } + ], "subqueries": [ { "query_block": { "select_id": 2, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "v1.a = 50", - "materialized": { - "query_block": { - "select_id": 3, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t1.a = 50" + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "v1.a = 50", + "materialized": { + "query_block": { + "select_id": 3, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.a = 50" + } + } + ] + } } } } - } + ] } } ] @@ -7604,40 +8722,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "system", - "rows": 1, - "filtered": 100 - }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "system", + "rows": 1, + "filtered": 100 + } + } + ], "subqueries": [ { "query_block": { "select_id": 2, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "v2.s < 50", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "s < 50", - "filesort": { - "sort_key": "t3.a", - "temporary_table": { - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 5, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "v2.s < 50", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "s < 50", + "filesort": { + "sort_key": "t3.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } ] @@ -7664,45 +8794,55 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<subquery2>", - "access_type": "system", - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "table": { - "message": "Select tables optimized away" - } - } - } - }, - "read_sorted_file": { - "filesort": { - "sort_key": "v1.a", + "nested_loop": [ + { "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 2, + "table_name": "<subquery2>", + "access_type": "system", + "rows": 1, "filtered": 100, - "attached_condition": "v1.b = 2", "materialized": { + "unique": 1, "query_block": { - "select_id": 3, + "select_id": 2, "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t1.b = 2" + "message": "Select tables optimized away" + } + } + } + } + }, + { + "read_sorted_file": { + "filesort": { + "sort_key": "v1.a", + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "v1.b = 2", + "materialized": { + "query_block": { + "select_id": 3, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.b = 2" + } + } + ] + } } } } } } - } + ] } } DROP VIEW v1; @@ -7724,68 +8864,84 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<subquery2>", - "access_type": "system", - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "table": { - "message": "Select tables optimized away" + "nested_loop": [ + { + "table": { + "table_name": "<subquery2>", + "access_type": "system", + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "table": { + "message": "Select tables optimized away" + } + } } } - } - }, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "v1.f = 2", - "materialized": { - "query_block": { - "select_id": 3, - "table": { - "table_name": "t", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t.f = 2" + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "v1.f = 2", + "materialized": { + "query_block": { + "select_id": 3, + "nested_loop": [ + { + "table": { + "table_name": "t", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t.f = 2" + } + } + ] + } } } - } - }, - "block-nl-join": { - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "v2.pk > 2" }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 4, + { + "block-nl-join": { "table": { - "table_name": "t", - "access_type": "range", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["pk"], - "rows": 1, + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 2, "filtered": 100, - "index_condition": "t.pk > 2" + "attached_condition": "v2.pk > 2" + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 4, + "nested_loop": [ + { + "table": { + "table_name": "t", + "access_type": "range", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["pk"], + "rows": 1, + "filtered": 100, + "index_condition": "t.pk > 2" + } + } + ] + } } } } - } + ] } } DROP VIEW v; @@ -7808,40 +8964,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<subquery3>", - "access_type": "system", - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 3, - "table": { - "message": "Select tables optimized away" + "nested_loop": [ + { + "table": { + "table_name": "<subquery3>", + "access_type": "system", + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 3, + "table": { + "message": "Select tables optimized away" + } + } } } - } - }, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "sq.i = 3", - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t1.i = 3" + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "sq.i = 3", + "materialized": { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.i = 3" + } + } + ] + } } } } - } + ] } } UPDATE t2 SET j = 2 WHERE j = 3; @@ -7865,40 +9031,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<subquery3>", - "access_type": "system", - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 3, - "table": { - "message": "Select tables optimized away" + "nested_loop": [ + { + "table": { + "table_name": "<subquery3>", + "access_type": "system", + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 3, + "table": { + "message": "Select tables optimized away" + } + } } } - } - }, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "sq.i = 2.71", - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t1.i = 2.7100000381469727" + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "sq.i = 2.71", + "materialized": { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.i = 2.7100000381469727" + } + } + ] + } } } } - } + ] } } DROP TABLE t1,t2; @@ -7917,40 +9093,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<subquery3>", - "access_type": "system", - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 3, - "table": { - "message": "Select tables optimized away" + "nested_loop": [ + { + "table": { + "table_name": "<subquery3>", + "access_type": "system", + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 3, + "table": { + "message": "Select tables optimized away" + } + } } } - } - }, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "sq.i = 3.21", - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t1.i = 3.21" + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "sq.i = 3.21", + "materialized": { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.i = 3.21" + } + } + ] + } } } } - } + ] } } DROP TABLE t1,t2; @@ -7969,40 +9155,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<subquery3>", - "access_type": "system", - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 3, - "table": { - "message": "Select tables optimized away" + "nested_loop": [ + { + "table": { + "table_name": "<subquery3>", + "access_type": "system", + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 3, + "table": { + "message": "Select tables optimized away" + } + } } } - } - }, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "sq.i = 'aa'", - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t1.i = 'aa'" + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "sq.i = 'aa'", + "materialized": { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.i = 'aa'" + } + } + ] + } } } } - } + ] } } DROP TABLE t1,t2; @@ -8023,40 +9219,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<subquery3>", - "access_type": "system", - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 3, - "table": { - "message": "Select tables optimized away" + "nested_loop": [ + { + "table": { + "table_name": "<subquery3>", + "access_type": "system", + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 3, + "table": { + "message": "Select tables optimized away" + } + } } } - } - }, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "sq.i = '2007-05-28 00:00:00'", - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t1.i = TIMESTAMP'2007-05-28 00:00:00'" + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "sq.i = '2007-05-28 00:00:00'", + "materialized": { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.i = TIMESTAMP'2007-05-28 00:00:00'" + } + } + ] + } } } } - } + ] } } DROP TABLE t1,t2; @@ -8075,40 +9281,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<subquery3>", - "access_type": "system", - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 3, - "table": { - "message": "Select tables optimized away" + "nested_loop": [ + { + "table": { + "table_name": "<subquery3>", + "access_type": "system", + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 3, + "table": { + "message": "Select tables optimized away" + } + } } } - } - }, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "sq.i = '2007-05-28'", - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t1.i = DATE'2007-05-28'" + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "sq.i = '2007-05-28'", + "materialized": { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.i = DATE'2007-05-28'" + } + } + ] + } } } } - } + ] } } DROP TABLE t1,t2; @@ -8127,40 +9343,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<subquery3>", - "access_type": "system", - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 3, - "table": { - "message": "Select tables optimized away" + "nested_loop": [ + { + "table": { + "table_name": "<subquery3>", + "access_type": "system", + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 3, + "table": { + "message": "Select tables optimized away" + } + } } } - } - }, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "sq.i = '10:00:02'", - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t1.i = TIME'10:00:02'" + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "sq.i = '10:00:02'", + "materialized": { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.i = TIME'10:00:02'" + } + } + ] + } } } } - } + ] } } DROP TABLE t1,t2; @@ -8179,25 +9405,33 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "nullif(1,v1.i)", - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "nullif(1,t1.i)" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "nullif(1,v1.i)", + "materialized": { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "nullif(1,t1.i)" + } + } + ] + } } } } - } + ] } } DROP VIEW v1; @@ -8266,36 +9500,48 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "v1.c = 'foo'", - "materialized": { - "query_block": { - "select_id": 3, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t1.c = 'foo'" + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "v1.c = 'foo'", + "materialized": { + "query_block": { + "select_id": 3, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.c = 'foo'" + } + } + ] + } } } } - }, + ], "subqueries": [ { "query_block": { "select_id": 2, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "1 = t2.a" - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "1 = t2.a" + } + } + ] } } ] @@ -8315,35 +9561,47 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "<cache>(<in_optimizer>(1,<exists>(subquery#2))) or v1.c = 'foo'", - "materialized": { - "query_block": { - "select_id": 3, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "<cache>(<in_optimizer>(1,<exists>(subquery#2))) or v1.c = 'foo'", + "materialized": { + "query_block": { + "select_id": 3, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } + } + ] + } } } } - }, + ], "subqueries": [ { "query_block": { "select_id": 2, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 128, - "filtered": 100, - "attached_condition": "1 = t2.a" - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 128, + "filtered": 100, + "attached_condition": "1 = t2.a" + } + } + ] } } ] @@ -8479,41 +9737,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 7, - "filtered": 100, - "attached_condition": "t1.a > 2 and t1.a is not null" - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["test.t1.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 3, - "filesort": { - "sort_key": "t2.b", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.b > 2" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t1.a > 2 and t1.a is not null" + } + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t1.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 3, + "filesort": { + "sort_key": "t2.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b > 2" + } + } + ] + } } } } } } - } + ] } } select a @@ -8529,41 +9797,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 7, - "filtered": 100, - "attached_condition": "t1.a > 2 and t1.a is not null" - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["test.t1.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 3, - "filesort": { - "sort_key": "t2.b", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.b > 2" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t1.a > 2 and t1.a is not null" + } + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t1.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 3, + "filesort": { + "sort_key": "t2.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b > 2" + } + } + ] + } } } } } } - } + ] } } select a @@ -8582,38 +9860,48 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 7, - "filtered": 100, - "attached_condition": "t1.a > 2 and t1.a is not null" - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["test.t1.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 3, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.b > 2" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t1.a > 2 and t1.a is not null" + } + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t1.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 3, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b > 2" + } + } + ] + } } } } } - } + ] } } select a @@ -8629,41 +9917,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 7, - "filtered": 100, - "attached_condition": "t1.a > 2 and t1.a is not null" - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["m"], - "ref": ["test.t1.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "m > 2", - "filesort": { - "sort_key": "t2.b", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t1.a > 2 and t1.a is not null" + } + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["m"], + "ref": ["test.t1.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "m > 2", + "filesort": { + "sort_key": "t2.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } drop view v1,v2,v3; @@ -8682,25 +9980,33 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "v1.f > 0", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "f > 0", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "v1.f > 0", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "f > 0", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } + } + ] + } } } } - } + ] } } DROP VIEW v1; @@ -8722,42 +10028,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["i1"], - "key": "i1", - "key_length": "5", - "used_key_parts": ["i1"], - "ref": ["const"], - "rows": 1, - "filtered": 100, - "using_index": true - }, - "block-nl-join": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "v2.i2 = 1" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["i1"], + "key": "i1", + "key_length": "5", + "used_key_parts": ["i1"], + "ref": ["const"], + "rows": 1, + "filtered": 100, + "using_index": true + } }, - "buffer_type": "flat", - "buffer_size": "65", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 3, + { + "block-nl-join": { "table": { - "table_name": "t2", + "table_name": "<derived3>", "access_type": "ALL", "rows": 2, "filtered": 100, - "attached_condition": "t2.i2 = 1" + "attached_condition": "v2.i2 = 1" + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 3, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t2.i2 = 1" + } + } + ] + } } } } - } + ] } } DROP VIEW v2; @@ -8780,26 +10096,34 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t.f = 'a' or t.f = 'b'", - "materialized": { - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t.f = 'a' or t.f = 'b'", + "materialized": { + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] + } } } } } - } + ] } } drop table t1; @@ -8827,42 +10151,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 4, - "filtered": 100, - "attached_condition": "t1.id2 is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["id2"], - "ref": ["test.t1.id2"], - "rows": 2, - "filtered": 100, - "attached_condition": "vc.ct > 0", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "ct > 0", - "filesort": { - "sort_key": "t2.id2", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 4, + "filtered": 100, + "attached_condition": "t1.id2 is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["id2"], + "ref": ["test.t1.id2"], + "rows": 2, + "filtered": 100, + "attached_condition": "vc.ct > 0", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "ct > 0", + "filesort": { + "sort_key": "t2.id2", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } DROP TABLE t1,t2; @@ -8916,38 +10250,48 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t2.x = 1" - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "v1.a = 1 and v1.b = 1 and v1.max_c > 30" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t2.x = 1" + } }, - "buffer_type": "flat", - "buffer_size": "173", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c > 37 and max_c > 30", + { + "block-nl-join": { "table": { - "table_name": "t1", + "table_name": "<derived2>", "access_type": "ALL", "rows": 3, "filtered": 100, - "attached_condition": "t1.a = 1 and t1.b = 1" + "attached_condition": "v1.a = 1 and v1.b = 1 and v1.max_c > 30" + }, + "buffer_type": "flat", + "buffer_size": "173", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c > 37 and max_c > 30", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.b = 1" + } + } + ] + } } } } - } + ] } } SELECT * @@ -8991,38 +10335,48 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t2.x = 1" - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "v1.a = 1 and v1.b = 1 and v1.d = 1 and v1.max_c > 30" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t2.x = 1" + } }, - "buffer_type": "flat", - "buffer_size": "173", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c > 37 and max_c > 30", + { + "block-nl-join": { "table": { - "table_name": "t1", + "table_name": "<derived2>", "access_type": "ALL", "rows": 3, "filtered": 100, - "attached_condition": "t1.a = 1 and t1.b = 1 and t1.d = 1" + "attached_condition": "v1.a = 1 and v1.b = 1 and v1.d = 1 and v1.max_c > 30" + }, + "buffer_type": "flat", + "buffer_size": "173", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c > 37 and max_c > 30", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.b = 1 and t1.d = 1" + } + } + ] + } } } } - } + ] } } DROP TABLE t1,t2; @@ -9098,43 +10452,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null" - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "10", - "used_key_parts": ["e", "max_f"], - "ref": ["test.t1.a", "test.t1.b"], - "rows": 2, - "filtered": 100, - "first_match": "t1", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_f > 18", - "filesort": { - "sort_key": "t2.e", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t2.e > 1" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null" + } + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "10", + "used_key_parts": ["e", "max_f"], + "ref": ["test.t1.a", "test.t1.b"], + "rows": 2, + "filtered": 100, + "first_match": "t1", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_f > 18", + "filesort": { + "sort_key": "t2.e", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t2.e > 1" + } + } + ] + } } } } } } - } + ] } } SELECT * FROM t1 @@ -9187,42 +10551,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.b < 25 and t1.a is not null and t1.b is not null" - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "10", - "used_key_parts": ["e", "max_f"], - "ref": ["test.t1.a", "test.t1.b"], - "rows": 2, - "filtered": 100, - "first_match": "t1", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_f > 18 and max_f < 25", - "filesort": { - "sort_key": "t2.e", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 5, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.b < 25 and t1.a is not null and t1.b is not null" + } + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "10", + "used_key_parts": ["e", "max_f"], + "ref": ["test.t1.a", "test.t1.b"], + "rows": 2, + "filtered": 100, + "first_match": "t1", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_f > 18 and max_f < 25", + "filesort": { + "sort_key": "t2.e", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } SELECT * FROM t1 @@ -9275,56 +10649,70 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a is not null and t1.b is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "max_f"], - "ref": ["test.t1.a", "test.t1.b"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "d_tab.e > 1", - "materialized": { - "query_block": { - "select_id": 3, - "filesort": { - "sort_key": "t2.e", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t2.e > 1" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a is not null and t1.b is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "max_f"], + "ref": ["test.t1.a", "test.t1.b"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "d_tab.e > 1", + "materialized": { + "query_block": { + "select_id": 3, + "filesort": { + "sort_key": "t2.e", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t2.e > 1" + } + } + ] + } + } + } } } } - } + ] } } } } } - } + ] } } SELECT * FROM t1 @@ -9377,56 +10765,70 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a is not null and t1.b is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "max_f"], - "ref": ["test.t1.a", "test.t1.b"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "d_tab.max_f > 20", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_f > 20", - "filesort": { - "sort_key": "t2.e", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 5, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a is not null and t1.b is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "max_f"], + "ref": ["test.t1.a", "test.t1.b"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "d_tab.max_f > 20", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_f > 20", + "filesort": { + "sort_key": "t2.e", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + ] + } + } + } } } } - } + ] } } } } } - } + ] } } DROP TABLE t1,t2; @@ -9471,30 +10873,38 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "dt.a = 2", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "a = 2", - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "dt.a = 2", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "a = 2", + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } SELECT * FROM @@ -9520,31 +10930,39 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "dt.a > 1", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "a > 1", - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t1.a < 3" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "dt.a > 1", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "a > 1", + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.a < 3" + } + } + ] + } } } } } } - } + ] } } SELECT * FROM @@ -9569,29 +10987,37 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "dt.a = 'ab'", - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "dt.a = 'ab'", + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } SELECT * FROM @@ -9616,29 +11042,37 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "dt.a = 1", - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "dt.a = 1", + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } DROP TABLE t1; @@ -9683,41 +11117,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "1 in (0,t1.a) and t1.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t1.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "1 in (0,t1.a) and 1 in (0,t1.a)" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "1 in (0,t1.a) and t1.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t1.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "1 in (0,t1.a) and 1 in (0,t1.a)" + } + } + ] + } } } } } } - } + ] } } SELECT * FROM @@ -9741,41 +11185,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t1.a in (1,t1.a) and t1.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t1.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t1.a in (1,t1.a)" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.a in (1,t1.a) and t1.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t1.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.a in (1,t1.a)" + } + } + ] + } } } } } } - } + ] } } DROP TABLE t1; @@ -9862,30 +11316,38 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 7, - "filtered": 100, - "attached_condition": "t.a <= 2", - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 7, - "filtered": 100, - "attached_condition": "t1.a <= 2" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t.a <= 2", + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t1.a <= 2" + } + } + ] + } } } } } } - } + ] } } INSERT INTO t3 @@ -9900,42 +11362,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "8", - "used_key_parts": ["c"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "t2.a = t.c and t.a >= 3", - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 7, - "filtered": 100, - "attached_condition": "t1.a >= 3" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "8", + "used_key_parts": ["c"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "t2.a = t.c and t.a >= 3", + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t1.a >= 3" + } + } + ] + } } } } } } - } + ] } } UPDATE t2, (SELECT a, count(*) as c FROM t1 GROUP BY a) t SET t2.a=t.c+10 @@ -9953,31 +11425,41 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 5, - "filtered": 100 - }, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 7, - "filtered": 100, - "attached_condition": "t.a = 2 and t2.a = t.c + 9", - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 7, - "filtered": 100, - "attached_condition": "t1.a = 2" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t.a = 2 and t2.a = t.c + 9", + "materialized": { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t1.a = 2" + } + } + ] + } } } } - } + ] } } DELETE t2 FROM t2, (SELECT a, count(*) as c FROM t1 GROUP BY a) t @@ -10017,30 +11499,38 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "case when tab2.max_a = 1 or tab2.max_a = 2 then 1 else 0 end = 1", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "case when max_a = 1 or max_a = 2 then 1 else 0 end = 1", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "case when tab2.max_a = 1 or tab2.max_a = 2 then 1 else 0 end = 1", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "case when max_a = 1 or max_a = 2 then 1 else 0 end = 1", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } SELECT * @@ -10066,30 +11556,38 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "case when tab2.max_a = 1 or tab2.max_a > 2 and tab2.max_a < 4 then 1 else 0 end = 1", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "case when max_a = 1 or max_a > 2 and max_a < 4 then 1 else 0 end = 1", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "case when tab2.max_a = 1 or tab2.max_a > 2 and tab2.max_a < 4 then 1 else 0 end = 1", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "case when max_a = 1 or max_a > 2 and max_a < 4 then 1 else 0 end = 1", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } SELECT * @@ -10115,30 +11613,38 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "case when tab2.max_a > 1 and (tab2.max_a = 2 or tab2.max_a > 2) then 1 else 0 end = 1", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "case when max_a > 1 and (max_a = 2 or max_a > 2) then 1 else 0 end = 1", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "case when tab2.max_a > 1 and (tab2.max_a = 2 or tab2.max_a > 2) then 1 else 0 end = 1", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "case when max_a > 1 and (max_a = 2 or max_a > 2) then 1 else 0 end = 1", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } SELECT * @@ -10164,30 +11670,38 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "case when tab2.b = 2 or tab2.b = 4 then 1 else 0 end = 1", - "materialized": { - "query_block": { - "select_id": 3, - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "case when t1.b = 2 or t1.b = 4 then 1 else 0 end = 1" + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "case when tab2.b = 2 or tab2.b = 4 then 1 else 0 end = 1", + "materialized": { + "query_block": { + "select_id": 3, + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "case when t1.b = 2 or t1.b = 4 then 1 else 0 end = 1" + } + } + ] + } } } } } } - } + ] } } DROP TABLE t1; @@ -10233,47 +11747,61 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 144, - "filtered": 100, - "attached_condition": "t.f is not null", - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 4, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 12, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 144, + "filtered": 100, + "attached_condition": "t.f is not null", + "materialized": { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 4, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 12, + "filtered": 100 + } + } + ] + } + } + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t1.f is not null" + }, + "buffer_type": "flat", + "buffer_size": "64", + "join_type": "BNL" + } } - } + ] } - }, - "block-nl-join": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t1.f is not null" - }, - "buffer_type": "flat", - "buffer_size": "64", - "join_type": "BNL" } } } - } + ] } } SELECT * FROM t1; @@ -10302,48 +11830,62 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t.f is not null", - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 8, - "filtered": 100, - "attached_condition": "t1.f is not null" - }, - "table": { - "table_name": "<derived4>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "4", - "used_key_parts": ["f"], - "ref": ["test.t1.f"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 4, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 8, - "filtered": 100, - "attached_condition": "t1.f is not null" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t.f is not null", + "materialized": { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 8, + "filtered": 100, + "attached_condition": "t1.f is not null" + } + }, + { + "table": { + "table_name": "<derived4>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "4", + "used_key_parts": ["f"], + "ref": ["test.t1.f"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 4, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 8, + "filtered": 100, + "attached_condition": "t1.f is not null" + } + } + ] + } + } + } } - } + ] } } } } - } + ] } } SELECT * FROM t1; @@ -10373,36 +11915,46 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t1.f2 < 2 and t1.f2 is not null" - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["f2"], - "ref": ["test.t1.f2"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 3, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t1.f2 < 2" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.f2 < 2 and t1.f2 is not null" + } + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["f2"], + "ref": ["test.t1.f2"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 3, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.f2 < 2" + } + } + ] + } } } } - } + ] } } SELECT * FROM t1; @@ -10418,38 +11970,48 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t1.f2 < 2 and t1.f2 is not null" - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["f2"], - "ref": ["test.t1.f2"], - "rows": 1, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 3, - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t1.f2 < 2" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.f2 < 2 and t1.f2 is not null" + } + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["f2"], + "ref": ["test.t1.f2"], + "rows": 1, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 3, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.f2 < 2" + } + } + ] + } } } } } - } + ] } } DROP VIEW v1,v2; @@ -10488,39 +12050,43 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "table": { - "message": "no matching row in const table" - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "table": { - "message": "no matching row in const table" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "table": { + "message": "no matching row in const table" + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "table": { + "message": "no matching row in const table" + } + } } - } + ] } - ] + } } } } - } + ] } } DROP TABLE t1; @@ -10690,54 +12256,66 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "v3.col1 = 123 and v3.col2 = 321", - "materialized": { - "query_block": { - "union_result": { - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["const"], - "rows": 1, - "filtered": 100 - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["const"], - "rows": 1, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "v3.col1 = 123 and v3.col2 = 321", + "materialized": { + "query_block": { + "union_result": { + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["const"], + "rows": 1, + "filtered": 100 + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["const"], + "rows": 1, + "filtered": 100 + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } drop function f1; @@ -10762,31 +12340,39 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "v2.s + 1 > 10 and v2.a > 1 and v2.a2 > 123", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "s + 1 > 10 and a2 > 123", - "filesort": { - "sort_key": "t1.a, f1(t1.a)", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t1.a > 1" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "v2.s + 1 > 10 and v2.a > 1 and v2.a2 > 123", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "s + 1 > 10 and a2 > 123", + "filesort": { + "sort_key": "t1.a, f1(t1.a)", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] + } } } } } } - } + ] } } # Extra test for 10.4+: Check that this works for pushdown into IN @@ -10807,41 +12393,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t4", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t4.a + 1 > 10 and t4.b > 1 and t4.c > 123 and t4.a is not null and t4.b is not null and t4.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "23", - "used_key_parts": ["a", "f1(a)", "sum(b)"], - "ref": ["test.t4.a", "test.t4.b", "test.t4.c"], - "rows": 1, - "filtered": 100, - "attached_condition": "t4.c = `<subquery2>`.`sum(b)`", - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "`f1(a)` > 1 and `sum(b)` > 123", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t1.a + 1 > 10" + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t4.a + 1 > 10 and t4.b > 1 and t4.c > 123 and t4.a is not null and t4.b is not null and t4.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "23", + "used_key_parts": ["a", "f1(a)", "sum(b)"], + "ref": ["test.t4.a", "test.t4.b", "test.t4.c"], + "rows": 1, + "filtered": 100, + "attached_condition": "t4.c = `<subquery2>`.`sum(b)`", + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "`f1(a)` > 1 and `sum(b)` > 123", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.a + 1 > 10" + } + } + ] + } } } } } - } + ] } } drop view v2; @@ -10894,71 +12490,85 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a < 5 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c < 300", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a < 5" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a < 5 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c < 300", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a < 5" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "having_condition": "c > 100", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a < 5" + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "having_condition": "c > 100", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a < 5" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using intersect in view definition @@ -10982,72 +12592,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a = 8" - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "v1.a = 8" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a = 8" + } }, - "buffer_type": "flat", - "buffer_size": "173", - "join_type": "BNL", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3>", + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c < 300", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a = 8" + "rows": 18, + "filtered": 100, + "attached_condition": "v1.a = 8" + }, + "buffer_type": "flat", + "buffer_size": "173", + "join_type": "BNL", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c < 300", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a = 8" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "having_condition": "c > 100", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a = 8 and t1.b > 10" + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "having_condition": "c > 100", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a = 8 and t1.b > 10" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using intersect in view definition @@ -11070,72 +12694,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a = 8" - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "v1.a = 8" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a = 8" + } }, - "buffer_type": "flat", - "buffer_size": "173", - "join_type": "BNL", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3>", + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c < 300", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a = 8" + "rows": 18, + "filtered": 100, + "attached_condition": "v1.a = 8" + }, + "buffer_type": "flat", + "buffer_size": "173", + "join_type": "BNL", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c < 300", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a = 8" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "having_condition": "c > 100", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a = 8 and t1.b > 10" + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "having_condition": "c > 100", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a = 8 and t1.b > 10" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using intersect in view definition @@ -11160,72 +12798,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.c > 200", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c < 300 and c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.c > 200", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c < 300 and c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "having_condition": "c > 100 and c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10" + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "having_condition": "c > 100 and c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using intersect in view definition @@ -11251,72 +12903,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a < 5 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.c > 110", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c < 300 and c > 110", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a < 5" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a < 5 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.c > 110", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c < 300 and c > 110", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a < 5" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "having_condition": "c > 100 and c > 110", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a < 5" + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "having_condition": "c > 100 and c > 110", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a < 5" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using intersect in view definition @@ -11343,72 +13009,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.b > 27 or v1.b < 19", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c < 300", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and (t1.b > 27 or t1.b < 19)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.b > 27 or v1.b < 19", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c < 300", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and (t1.b > 27 or t1.b < 19)" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "having_condition": "c > 100", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and (t1.b > 27 or t1.b < 19)" + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "having_condition": "c > 100", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and (t1.b > 27 or t1.b < 19)" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using intersect in view definition @@ -11441,72 +13121,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.c > 200 or v1.c < 105", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c < 300 and (c > 200 or c < 105)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.c > 200 or v1.c < 105", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c < 300 and (c > 200 or c < 105)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "having_condition": "c > 100 and (c > 200 or c < 105)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10" + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "having_condition": "c > 100 and (c > 200 or c < 105)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using intersect in view definition @@ -11561,72 +13255,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "v1.a > 3 or v1.a = 1 and v1.c < 110" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "173", - "join_type": "BNL", - "attached_condition": "v1.c = t2.c and v1.a > 3 and t2.c > 110 or v1.a = 1 and v1.c < 110", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3>", + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c < 300 and (t1.a > 3 and c > 110 or t1.a = 1 and c < 110)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and (t1.a > 3 or t1.a = 1)" + "rows": 18, + "filtered": 100, + "attached_condition": "v1.a > 3 or v1.a = 1 and v1.c < 110" + }, + "buffer_type": "flat", + "buffer_size": "173", + "join_type": "BNL", + "attached_condition": "v1.c = t2.c and v1.a > 3 and t2.c > 110 or v1.a = 1 and v1.c < 110", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c < 300 and (t1.a > 3 and c > 110 or t1.a = 1 and c < 110)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and (t1.a > 3 or t1.a = 1)" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "having_condition": "c > 100 and (t1.a > 3 and c > 110 or t1.a = 1 and c < 110)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and (t1.a > 3 or t1.a = 1)" + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "having_condition": "c > 100 and (t1.a > 3 and c > 110 or t1.a = 1 and c < 110)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and (t1.a > 3 or t1.a = 1)" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using intersect in view definition @@ -11710,72 +13418,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.b is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["test.t2.b"], - "rows": 2, - "filtered": 100, - "attached_condition": "t2.c = 909 and t2.b > 13 or d1.a < 4 and d1.c < 200", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c < 300 and (t1.b > 13 or t1.a < 4 and c < 200)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and (t1.b > 13 or t1.a < 4)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t2.b"], + "rows": 2, + "filtered": 100, + "attached_condition": "t2.c = 909 and t2.b > 13 or d1.a < 4 and d1.c < 200", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c < 300 and (t1.b > 13 or t1.a < 4 and c < 200)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and (t1.b > 13 or t1.a < 4)" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "having_condition": "c > 100 and (t1.b > 13 or t1.a < 4 and c < 200)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and (t1.b > 13 or t1.a < 4)" + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "having_condition": "c > 100 and (t1.b > 13 or t1.a < 4 and c < 200)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and (t1.b > 13 or t1.a < 4)" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -11811,71 +13533,85 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a < 5 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a < 5" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a < 5 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a < 5" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "having_condition": "c < 300", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a < 5" + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "having_condition": "c < 300", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a < 5" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using except in view definition @@ -11901,72 +13637,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a = 6" - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "v1.a = 6" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a = 6" + } }, - "buffer_type": "flat", - "buffer_size": "173", - "join_type": "BNL", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 200", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a = 6" + "rows": 18, + "filtered": 100, + "attached_condition": "v1.a = 6" + }, + "buffer_type": "flat", + "buffer_size": "173", + "join_type": "BNL", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 200", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a = 6" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "having_condition": "c < 300", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a = 6 and t1.b > 10" + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "having_condition": "c < 300", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a = 6 and t1.b > 10" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using except in view definition @@ -11991,72 +13741,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a = 6" - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "v1.a = 6" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a = 6" + } }, - "buffer_type": "flat", - "buffer_size": "173", - "join_type": "BNL", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 200", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a = 6" + "rows": 18, + "filtered": 100, + "attached_condition": "v1.a = 6" + }, + "buffer_type": "flat", + "buffer_size": "173", + "join_type": "BNL", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 200", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a = 6" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "having_condition": "c < 300", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a = 6 and t1.b > 10" + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "having_condition": "c < 300", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a = 6 and t1.b > 10" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using except in view definition @@ -12085,72 +13849,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.c > 500", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 200 and c > 500", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.c > 500", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 200 and c > 500", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "having_condition": "c < 300 and c > 500", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10" + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "having_condition": "c < 300 and c > 500", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using except in view definition @@ -12176,72 +13954,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a < 5 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.c > 500", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 200 and c > 500", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a < 5" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a < 5 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.c > 500", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 200 and c > 500", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a < 5" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "having_condition": "c < 300 and c > 500", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a < 5" + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "having_condition": "c < 300 and c > 500", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a < 5" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using except in view definition @@ -12270,72 +14062,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.b > 27 or v1.b < 19", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and (t1.b > 27 or t1.b < 19)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.b > 27 or v1.b < 19", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and (t1.b > 27 or t1.b < 19)" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "having_condition": "c < 300", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and (t1.b > 27 or t1.b < 19)" + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "having_condition": "c < 300", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and (t1.b > 27 or t1.b < 19)" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using except in view definition @@ -12368,72 +14174,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.c < 400 or v1.c > 800", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 200 and (c < 400 or c > 800)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.c < 400 or v1.c > 800", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 200 and (c < 400 or c > 800)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "having_condition": "c < 300 and (c < 400 or c > 800)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10" + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "having_condition": "c < 300 and (c < 400 or c > 800)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using except in view definition @@ -12486,72 +14306,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "v1.a > 1 or v1.a = 1 and v1.c > 500" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "173", - "join_type": "BNL", - "attached_condition": "v1.c = t2.c and v1.a > 1 and t2.c < 500 or v1.a = 1 and v1.c > 500", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", + { + "block-nl-join": { + "table": { + "table_name": "<derived2>", "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 200 and (t1.a > 1 and c < 500 or t1.a = 1 and c > 500)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and (t1.a > 1 or t1.a = 1)" + "rows": 18, + "filtered": 100, + "attached_condition": "v1.a > 1 or v1.a = 1 and v1.c > 500" + }, + "buffer_type": "flat", + "buffer_size": "173", + "join_type": "BNL", + "attached_condition": "v1.c = t2.c and v1.a > 1 and t2.c < 500 or v1.a = 1 and v1.c > 500", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 200 and (t1.a > 1 and c < 500 or t1.a = 1 and c > 500)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and (t1.a > 1 or t1.a = 1)" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "having_condition": "c < 300 and (t1.a > 1 and c < 500 or t1.a = 1 and c > 500)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and (t1.a > 1 or t1.a = 1)" + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "having_condition": "c < 300 and (t1.a > 1 and c < 500 or t1.a = 1 and c > 500)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and (t1.a > 1 or t1.a = 1)" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } # using except in view definition @@ -12631,72 +14465,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.b is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["test.t2.b"], - "rows": 2, - "filtered": 100, - "attached_condition": "t2.c = 988 and t2.b > 13 or d1.a > 4 and d1.c > 500", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 200 and (t1.b > 13 or t1.a > 4 and c > 500)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and (t1.b > 13 or t1.a > 4)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t2.b"], + "rows": 2, + "filtered": 100, + "attached_condition": "t2.c = 988 and t2.b > 13 or d1.a > 4 and d1.c > 500", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 200 and (t1.b > 13 or t1.a > 4 and c > 500)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and (t1.b > 13 or t1.a > 4)" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "having_condition": "c < 300 and (t1.b > 13 or t1.a > 4 and c > 500)", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and (t1.b > 13 or t1.a > 4)" + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "having_condition": "c < 300 and (t1.b > 13 or t1.a > 4 and c > 500)", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and (t1.b > 13 or t1.a > 4)" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -12734,113 +14582,135 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a > 5 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 3, - "filtered": 100, - "attached_condition": "v1.c > 200", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 200 and c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a > 5" - } - } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "__5.a > 5 and __5.c > 200", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect4,5>", - "access_type": "ALL", - "query_specifications": [ + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a > 5 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 3, + "filtered": 100, + "attached_condition": "v1.c > 200", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 200 and c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ { - "query_block": { - "select_id": 4, - "having_condition": "c < 300 and c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a > 5" - } - } - } + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a > 5" } - }, - { + } + ] + } + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "nested_loop": [ + { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "__5.a > 5 and __5.c > 200", + "materialized": { "query_block": { - "select_id": 5, - "operation": "INTERSECT", - "having_condition": "c < 530 and c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a > 3 and t1.a > 5" + "union_result": { + "table_name": "<intersect4,5>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 4, + "having_condition": "c < 300 and c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a > 5" + } + } + ] + } + } + } + }, + { + "query_block": { + "select_id": 5, + "operation": "INTERSECT", + "having_condition": "c < 530 and c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a > 3 and t1.a > 5" + } + } + ] + } + } + } } - } + ] } } } - ] + } } - } + ] } } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -12878,91 +14748,109 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a > 4 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 3, - "filtered": 100, - "attached_condition": "v1.c < 200", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<unit2,3,4>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 200 and c < 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a > 4" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a > 4 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 3, + "filtered": 100, + "attached_condition": "v1.c < 200", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<unit2,3,4>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 200 and c < 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a > 4" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "having_condition": "c < 500 and c < 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a > 3 and t1.a > 4" + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "having_condition": "c < 500 and c < 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a > 3 and t1.a > 4" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 4, - "operation": "UNION", - "having_condition": "c < 300 and c < 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a > 4" + }, + { + "query_block": { + "select_id": 4, + "operation": "UNION", + "having_condition": "c < 300 and c < 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a > 4" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -12998,91 +14886,109 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a > 5 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 3, - "filtered": 100, - "attached_condition": "v1.c > 200", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<unit2,3,4>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 200 and c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a > 5" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a > 5 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 3, + "filtered": 100, + "attached_condition": "v1.c > 200", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<unit2,3,4>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 200 and c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a > 5" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "having_condition": "c < 300 and c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a > 5" + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "having_condition": "c < 300 and c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a > 5" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 4, - "operation": "EXCEPT", - "having_condition": "c < 530 and c > 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a > 3 and t1.a > 5" + }, + { + "query_block": { + "select_id": 4, + "operation": "EXCEPT", + "having_condition": "c < 530 and c > 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a > 3 and t1.a > 5" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -13120,91 +15026,109 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a > 4 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 3, - "filtered": 100, - "attached_condition": "v1.c < 200", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<unit2,3,4>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 200 and c < 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a > 4" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a > 4 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 3, + "filtered": 100, + "attached_condition": "v1.c < 200", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<unit2,3,4>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 200 and c < 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a > 4" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "having_condition": "c < 500 and c < 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a > 3 and t1.a > 4" + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "having_condition": "c < 500 and c < 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a > 3 and t1.a > 4" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 4, - "operation": "UNION", - "having_condition": "c < 300 and c < 200", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a > 4" + }, + { + "query_block": { + "select_id": 4, + "operation": "UNION", + "having_condition": "c < 300 and c < 200", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a > 4" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -13240,91 +15164,109 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a > 4 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.c < 150", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<unit2,3,4>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c < 300 and c < 150", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a > 4" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a > 4 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.c < 150", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<unit2,3,4>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c < 300 and c < 150", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a > 4" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "having_condition": "c < 500 and c < 150", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 7 and t1.a > 4" + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "having_condition": "c < 500 and c < 150", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 7 and t1.a > 4" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 4, - "operation": "EXCEPT", - "having_condition": "c > 150 and c < 150", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a > 4" + }, + { + "query_block": { + "select_id": 4, + "operation": "EXCEPT", + "having_condition": "c > 150 and c < 150", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a > 4" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -13360,113 +15302,135 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a > 4 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.c < 130", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c < 300 and c < 130", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a > 4" - } - } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "__5.a > 4 and __5.c < 130", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect4,5>", - "access_type": "ALL", - "query_specifications": [ + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a > 4 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.c < 130", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c < 300 and c < 130", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ { - "query_block": { - "select_id": 4, - "having_condition": "c > 150 and c < 130", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a > 4" - } - } - } + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a > 4" } - }, - { + } + ] + } + } + } + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "nested_loop": [ + { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "__5.a > 4 and __5.c < 130", + "materialized": { "query_block": { - "select_id": 5, - "operation": "INTERSECT", - "having_condition": "c < 500 and c < 130", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 7 and t1.a > 4" + "union_result": { + "table_name": "<intersect4,5>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 4, + "having_condition": "c > 150 and c < 130", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a > 4" + } + } + ] + } + } + } + }, + { + "query_block": { + "select_id": 5, + "operation": "INTERSECT", + "having_condition": "c < 500 and c < 130", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 7 and t1.a > 4" + } + } + ] + } + } + } } - } + ] } } } - ] + } } - } + ] } } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -13506,99 +15470,144 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a > 4 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 3, - "filtered": 100, - "attached_condition": "v1.c < 130", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<unit2,3,6>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c < 300 and c < 130", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a > 4" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a > 4 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 3, + "filtered": 100, + "attached_condition": "v1.c < 130", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<unit2,3,6>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c < 300 and c < 130", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a > 4" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "table": { - "table_name": "<derived4>", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "__6.a > 4 and __6.c < 130", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect4,5>", - "access_type": "ALL", - "query_specifications": [ - { + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "nested_loop": [ + { + "table": { + "table_name": "<derived4>", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "__6.a > 4 and __6.c < 130", + "materialized": { "query_block": { - "select_id": 4, - "having_condition": "c > 150 and c < 130", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a > 4" + "union_result": { + "table_name": "<intersect4,5>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 4, + "having_condition": "c > 150 and c < 130", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a > 4" + } + } + ] + } + } + } + }, + { + "query_block": { + "select_id": 5, + "operation": "INTERSECT", + "having_condition": "c < 500 and c < 130", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 7 and t1.a > 4" + } + } + ] + } + } + } } - } + ] } } - }, + } + } + } + ] + } + }, + { + "query_block": { + "select_id": 6, + "operation": "UNION", + "having_condition": "c < 120 and c < 130", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ { - "query_block": { - "select_id": 5, - "operation": "INTERSECT", - "having_condition": "c < 500 and c < 130", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 7 and t1.a > 4" - } - } - } + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 7 and t1.a > 4" } } ] @@ -13606,32 +15615,13 @@ EXPLAIN } } } - } - }, - { - "query_block": { - "select_id": 6, - "operation": "UNION", - "having_condition": "c < 120 and c < 130", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 7 and t1.a > 4" - } - } - } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -13668,90 +15658,108 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a > 4 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v2.c < 150", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "c < 150", - "filesort": { - "sort_key": "v1.a, v1.b", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "v1.a < 7 and v1.a > 4", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect3,4>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 3, - "having_condition": "c < 300", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a < 7 and t1.a > 4" - } - } - } - } - }, - { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a > 4 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v2.c < 150", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "c < 150", + "filesort": { + "sort_key": "v1.a, v1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "v1.a < 7 and v1.a > 4", + "materialized": { "query_block": { - "select_id": 4, - "operation": "INTERSECT", - "having_condition": "c > 120", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a < 7 and t1.a > 4" + "union_result": { + "table_name": "<intersect3,4>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 3, + "having_condition": "c < 300", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a < 7 and t1.a > 4" + } + } + ] + } + } + } + }, + { + "query_block": { + "select_id": 4, + "operation": "INTERSECT", + "having_condition": "c > 120", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a < 7 and t1.a > 4" + } + } + ] + } + } + } } - } + ] } } } - ] + } } - } + ] } } } } } } - } + ] } } drop view v1,v2; @@ -13788,90 +15796,108 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a > 4 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v2.c < 150", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "c < 150", - "filesort": { - "sort_key": "v1.a, v1.b", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "v1.a < 7 and v1.a > 4", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except3,4>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 3, - "having_condition": "c < 300", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a < 7 and t1.a > 4" - } - } - } - } - }, - { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a > 4 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v2.c < 150", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "c < 150", + "filesort": { + "sort_key": "v1.a, v1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "v1.a < 7 and v1.a > 4", + "materialized": { "query_block": { - "select_id": 4, - "operation": "EXCEPT", - "having_condition": "c > 150", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a < 7 and t1.a > 4" + "union_result": { + "table_name": "<except3,4>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 3, + "having_condition": "c < 300", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a < 7 and t1.a > 4" + } + } + ] + } + } + } + }, + { + "query_block": { + "select_id": 4, + "operation": "EXCEPT", + "having_condition": "c > 150", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a < 7 and t1.a > 4" + } + } + ] + } + } + } } - } + ] } } } - ] + } } - } + ] } } } } } } - } + ] } } drop view v1,v2; @@ -13904,72 +15930,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a > 4 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.b > 12 and v1.c < 450", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 300 and t1.b > 12 and c < 450", - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a > 4" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a > 4 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.b > 12 and v1.c < 450", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 300 and t1.b > 12 and c < 450", + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a > 4" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "having_condition": "c > 200 and t1.a > 4 and c < 450", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b < 21 and t1.b > 12" + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "having_condition": "c > 200 and t1.a > 4 and c < 450", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b < 21 and t1.b > 12" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -14002,72 +16042,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a < 2 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.b < 30 and v1.c > 450", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 300 and t1.b < 30 and c > 450", - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 20 and t1.a < 2" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a < 2 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.b < 30 and v1.c > 450", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 300 and t1.b < 30 and c > 450", + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 20 and t1.a < 2" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "having_condition": "c > 150 and t1.a < 2 and c > 450", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 7 and t1.b < 30" + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "having_condition": "c > 150 and t1.a < 2 and c > 450", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 7 and t1.b < 30" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -14102,72 +16156,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "(t2.a < 2 or t2.a < 5) and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.c > 450", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 300 and c > 450", - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 20 and (t1.a < 2 or t1.a < 5)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "(t2.a < 2 or t2.a < 5) and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.c > 450", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 300 and c > 450", + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 20 and (t1.a < 2 or t1.a < 5)" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "having_condition": "c > 150 and (t1.a < 2 or t1.a < 5) and c > 450", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 7" + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "having_condition": "c > 150 and (t1.a < 2 or t1.a < 5) and c > 450", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 7" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -14204,91 +16272,109 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.a > 1 and t2.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 3, - "filtered": 100, - "attached_condition": "v1.b > 12 and v1.c > 400", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<unit2,3,4>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "having_condition": "c > 100 and t1.b > 12 and c > 400", - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a < 9 and t1.a > 1" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.a > 1 and t2.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 3, + "filtered": 100, + "attached_condition": "v1.b > 12 and v1.c > 400", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<unit2,3,4>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "having_condition": "c > 100 and t1.b > 12 and c > 400", + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a < 9 and t1.a > 1" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "having_condition": "c < 800 and t1.a > 1 and c > 400", - "filesort": { - "sort_key": "t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.a > 3 and t1.b > 12" + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "having_condition": "c < 800 and t1.a > 1 and c > 400", + "filesort": { + "sort_key": "t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.a > 3 and t1.b > 12" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 4, - "operation": "UNION", - "having_condition": "c > 300 and c > 400", - "filesort": { - "sort_key": "t1.a, t1.b", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 18, - "filtered": 100, - "attached_condition": "t1.b > 10 and t1.a > 1 and t1.b > 12" + }, + { + "query_block": { + "select_id": 4, + "operation": "UNION", + "having_condition": "c > 300 and c > 400", + "filesort": { + "sort_key": "t1.a, t1.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 100, + "attached_condition": "t1.b > 10 and t1.a > 1 and t1.b > 12" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -14330,41 +16416,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.b is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["test.t2.b"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.a < 5", - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t3", - "access_type": "range", - "possible_keys": ["i1"], - "key": "i1", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 5, - "filtered": 100, - "index_condition": "t3.a > 0 and t3.a < 5" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t2.b"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.a < 5", + "materialized": { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "range", + "possible_keys": ["i1"], + "key": "i1", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 5, + "filtered": 100, + "index_condition": "t3.a > 0 and t3.a < 5" + } + } + ] + } } } } - } + ] } } drop view v1; @@ -14399,68 +16495,82 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.b is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["test.t2.b"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.a < 4", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t3", - "access_type": "range", - "possible_keys": ["i1"], - "key": "i1", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 2, - "filtered": 100, - "index_condition": "t3.a > 1 and t3.a < 4" - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "table": { - "table_name": "t3", - "access_type": "range", - "possible_keys": ["i1"], - "key": "i1", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 1, - "filtered": 100, - "index_condition": "t3.a > 2 and t3.a < 4" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t2.b"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.a < 4", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "range", + "possible_keys": ["i1"], + "key": "i1", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 2, + "filtered": 100, + "index_condition": "t3.a > 1 and t3.a < 4" + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "range", + "possible_keys": ["i1"], + "key": "i1", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 1, + "filtered": 100, + "index_condition": "t3.a > 2 and t3.a < 4" + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -14495,70 +16605,84 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "attached_condition": "t2.b is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["b"], - "ref": ["test.t2.b"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.a < 3", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t3", - "access_type": "range", - "possible_keys": ["i1"], - "key": "i1", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 1, - "filtered": 100, - "index_condition": "t3.a > 1 and t3.a < 3" - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "having_condition": "t3.a < 3", - "filesort": { - "sort_key": "t3.b", - "temporary_table": { - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t3.b < 21" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t2.b"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.a < 3", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "range", + "possible_keys": ["i1"], + "key": "i1", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 1, + "filtered": 100, + "index_condition": "t3.a > 1 and t3.a < 3" + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "having_condition": "t3.a < 3", + "filesort": { + "sort_key": "t3.b", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t3.b < 21" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } drop view v1; @@ -14614,35 +16738,45 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", - "materialized": { - "query_block": { - "select_id": 2, - "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t2.a, t2.c" - } - }, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "possible_keys": ["idx"], - "rows": 20, - "filtered": 80, - "attached_condition": "t2.a > 2 and t2.c in ('aa','bb','cc')" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", + "materialized": { + "query_block": { + "select_id": 2, + "window_functions_computation": { + "sorts": [ + { + "filesort": { + "sort_key": "t2.a, t2.c" + } + } + ], + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": ["idx"], + "rows": 20, + "filtered": 80, + "attached_condition": "t2.a > 2 and t2.c in ('aa','bb','cc')" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from @@ -14719,66 +16853,82 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 32, - "filtered": 100, - "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", - "materialized": { - "query_block": { - "union_result": { - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t2.a, t2.c" - } - }, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "possible_keys": ["idx"], - "rows": 20, - "filtered": 80, - "attached_condition": "t2.a > 2 and t2.c in ('aa','bb','cc')" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 32, + "filtered": 100, + "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", + "materialized": { + "query_block": { + "union_result": { + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "window_functions_computation": { + "sorts": [ + { + "filesort": { + "sort_key": "t2.a, t2.c" + } + } + ], + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": ["idx"], + "rows": 20, + "filtered": 80, + "attached_condition": "t2.a > 2 and t2.c in ('aa','bb','cc')" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t2.a" - } - }, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "possible_keys": ["idx"], - "rows": 20, - "filtered": 80, - "attached_condition": "t2.a > 2" + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "window_functions_computation": { + "sorts": [ + { + "filesort": { + "sort_key": "t2.a" + } + } + ], + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": ["idx"], + "rows": 20, + "filtered": 80, + "attached_condition": "t2.a > 2" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * @@ -14811,45 +16961,57 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 8, - "filtered": 100, - "attached_condition": "t1.c in ('aa','bb','cc') and t1.a is not null and t1.c is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "24", - "used_key_parts": ["a", "c"], - "ref": ["test.t1.a", "test.t1.c"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t2.a, t2.c" - } - }, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t2.c in ('aa','bb','cc')" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 8, + "filtered": 100, + "attached_condition": "t1.c in ('aa','bb','cc') and t1.a is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "24", + "used_key_parts": ["a", "c"], + "ref": ["test.t1.a", "test.t1.c"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "window_functions_computation": { + "sorts": [ + { + "filesort": { + "sort_key": "t2.a, t2.c" + } + } + ], + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t2.c in ('aa','bb','cc')" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from @@ -14939,86 +17101,106 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 48, - "filtered": 100, - "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", - "materialized": { - "query_block": { - "union_result": { - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t2.a, t2.c" - } - }, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "possible_keys": ["idx"], - "rows": 20, - "filtered": 80, - "attached_condition": "t2.a > 2 and t2.c in ('aa','bb','cc')" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 48, + "filtered": 100, + "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", + "materialized": { + "query_block": { + "union_result": { + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "window_functions_computation": { + "sorts": [ + { + "filesort": { + "sort_key": "t2.a, t2.c" + } + } + ], + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": ["idx"], + "rows": 20, + "filtered": 80, + "attached_condition": "t2.a > 2 and t2.c in ('aa','bb','cc')" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t2.a" - } - }, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "possible_keys": ["idx"], - "rows": 20, - "filtered": 80, - "attached_condition": "t2.a > 2" + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "window_functions_computation": { + "sorts": [ + { + "filesort": { + "sort_key": "t2.a" + } + } + ], + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": ["idx"], + "rows": 20, + "filtered": 80, + "attached_condition": "t2.a > 2" + } + } + ] + } } } - } - } - }, - { - "query_block": { - "select_id": 4, - "operation": "UNION", - "having_condition": "t2.c in ('aa','bb','cc')", - "filesort": { - "sort_key": "t2.a", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "possible_keys": ["idx"], - "rows": 20, - "filtered": 80, - "attached_condition": "t2.a > 2" + }, + { + "query_block": { + "select_id": 4, + "operation": "UNION", + "having_condition": "t2.c in ('aa','bb','cc')", + "filesort": { + "sort_key": "t2.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": ["idx"], + "rows": 20, + "filtered": 80, + "attached_condition": "t2.a > 2" + } + } + ] + } } } } - } + ] } - ] + } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from (select a, c, @@ -15068,35 +17250,45 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", - "materialized": { - "query_block": { - "select_id": 2, - "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t2.a, t2.c" - } - }, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "possible_keys": ["idx"], - "rows": 20, - "filtered": 80, - "attached_condition": "t2.a > 2 and t2.c in ('aa','bb','cc')" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", + "materialized": { + "query_block": { + "select_id": 2, + "window_functions_computation": { + "sorts": [ + { + "filesort": { + "sort_key": "t2.a, t2.c" + } + } + ], + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": ["idx"], + "rows": 20, + "filtered": 80, + "attached_condition": "t2.a > 2 and t2.c in ('aa','bb','cc')" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from (select a, c, @@ -15146,35 +17338,45 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", - "materialized": { - "query_block": { - "select_id": 2, - "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t2.a, t2.c" - } - }, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "possible_keys": ["idx"], - "rows": 20, - "filtered": 80, - "attached_condition": "t2.a > 2" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", + "materialized": { + "query_block": { + "select_id": 2, + "window_functions_computation": { + "sorts": [ + { + "filesort": { + "sort_key": "t2.a, t2.c" + } + } + ], + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": ["idx"], + "rows": 20, + "filtered": 80, + "attached_condition": "t2.a > 2" + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from (select a, c, @@ -15224,37 +17426,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", - "materialized": { - "query_block": { - "select_id": 2, - "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t2.a, t2.c" - }, - "filesort": { - "sort_key": "t2.c" - } - }, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 20, - "filtered": 100, - "attached_condition": "t2.c in ('aa','bb','cc')" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t.a > 2 and t.c in ('aa','bb','cc')", + "materialized": { + "query_block": { + "select_id": 2, + "window_functions_computation": { + "sorts": [ + { + "filesort": { + "sort_key": "t2.a, t2.c" + } + }, + { + "filesort": { + "sort_key": "t2.c" + } + } + ], + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 20, + "filtered": 100, + "attached_condition": "t2.c in ('aa','bb','cc')" + } + } + ] + } } } } } } - } + ] } } drop table t1,t2; @@ -15327,47 +17541,57 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx_b"], - "key": "idx_b", - "key_length": "5", - "used_key_parts": ["b"], - "rows": 4, - "filtered": 100, - "index_condition": "t1.b < 3", - "attached_condition": "t1.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t1.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "lateral": 1, - "query_block": { - "select_id": 2, - "outer_ref_condition": "t1.a is not null", - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["idx_a"], - "key": "idx_a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t1.a"], - "rows": 1, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx_b"], + "key": "idx_b", + "key_length": "5", + "used_key_parts": ["b"], + "rows": 4, + "filtered": 100, + "index_condition": "t1.b < 3", + "attached_condition": "t1.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t1.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "lateral": 1, + "query_block": { + "select_id": 2, + "outer_ref_condition": "t1.a is not null", + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["idx_a"], + "key": "idx_a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t1.a"], + "rows": 1, + "filtered": 100 + } + } + ] + } } } } - } + ] } } prepare stmt from "select t1.a,t.s,t.m @@ -15438,43 +17662,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "possible_keys": ["idx_b"], - "rows": 12, - "filtered": 83.33333588, - "attached_condition": "t1.b <= 5 and t1.a is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t1.a"], - "rows": 2, - "filtered": 100, - "materialized": { - "lateral": 1, - "query_block": { - "select_id": 2, - "outer_ref_condition": "t1.a is not null", - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["idx_a"], - "key": "idx_a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t1.a"], - "rows": 1, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": ["idx_b"], + "rows": 12, + "filtered": 83.33333588, + "attached_condition": "t1.b <= 5 and t1.a is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t1.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "lateral": 1, + "query_block": { + "select_id": 2, + "outer_ref_condition": "t1.a is not null", + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["idx_a"], + "key": "idx_a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t1.a"], + "rows": 1, + "filtered": 100 + } + } + ] + } } } } - } + ] } } prepare stmt from "select t1.a,t.s,t.m @@ -15543,41 +17777,51 @@ EXPLAIN "query_block": { "select_id": 1, "const_condition": "1", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 12, - "filtered": 100 - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t1.a"], - "rows": 9, - "filtered": 100, - "attached_condition": "trigcond(trigcond(t1.a is not null))", - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "t2.a", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "possible_keys": ["idx_a"], - "rows": 90, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 12, + "filtered": 100 + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t1.a"], + "rows": 9, + "filtered": 100, + "attached_condition": "trigcond(trigcond(t1.a is not null))", + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "t2.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": ["idx_a"], + "rows": 90, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } create table t3 (a int, b int, c char(127), index idx_b(b)) engine=myisam; @@ -15634,47 +17878,57 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "range", - "possible_keys": ["idx_b"], - "key": "idx_b", - "key_length": "5", - "used_key_parts": ["b"], - "rows": 2, - "filtered": 100, - "index_condition": "t3.b > 15", - "attached_condition": "t3.a is not null and t3.c is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "133", - "used_key_parts": ["a", "c"], - "ref": ["test.t3.a", "test.t3.c"], - "rows": 2, - "filtered": 100, - "materialized": { - "lateral": 1, - "query_block": { - "select_id": 2, - "outer_ref_condition": "t3.a is not null and t3.c is not null", - "table": { - "table_name": "t4", - "access_type": "ref", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "133", - "used_key_parts": ["a", "c"], - "ref": ["test.t3.a", "test.t3.c"], - "rows": 1, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "range", + "possible_keys": ["idx_b"], + "key": "idx_b", + "key_length": "5", + "used_key_parts": ["b"], + "rows": 2, + "filtered": 100, + "index_condition": "t3.b > 15", + "attached_condition": "t3.a is not null and t3.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "133", + "used_key_parts": ["a", "c"], + "ref": ["test.t3.a", "test.t3.c"], + "rows": 2, + "filtered": 100, + "materialized": { + "lateral": 1, + "query_block": { + "select_id": 2, + "outer_ref_condition": "t3.a is not null and t3.c is not null", + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "ref", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "133", + "used_key_parts": ["a", "c"], + "ref": ["test.t3.a", "test.t3.c"], + "rows": 1, + "filtered": 100 + } + } + ] + } } } } - } + ] } } set statement optimizer_switch='split_materialized=off' for select t3.a,t3.c,t.max,t.min @@ -15713,42 +17967,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "ALL", - "possible_keys": ["idx_b"], - "rows": 12, - "filtered": 83.33333588, - "attached_condition": "t3.b <= 15 and t3.a is not null and t3.c is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "133", - "used_key_parts": ["a", "c"], - "ref": ["test.t3.a", "test.t3.c"], - "rows": 4, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "t4.a, t4.c", - "temporary_table": { - "table": { - "table_name": "t4", - "access_type": "ALL", - "possible_keys": ["idx"], - "rows": 40, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "possible_keys": ["idx_b"], + "rows": 12, + "filtered": 83.33333588, + "attached_condition": "t3.b <= 15 and t3.a is not null and t3.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "133", + "used_key_parts": ["a", "c"], + "ref": ["test.t3.a", "test.t3.c"], + "rows": 4, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "t4.a, t4.c", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "ALL", + "possible_keys": ["idx"], + "rows": 40, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='split_materialized=off' for select t3.a,t3.c,t.max,t.min @@ -15787,47 +18051,57 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "range", - "possible_keys": ["idx_b"], - "key": "idx_b", - "key_length": "5", - "used_key_parts": ["b"], - "rows": 2, - "filtered": 100, - "index_condition": "t3.b > 15", - "attached_condition": "t3.a is not null and t3.c is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "133", - "used_key_parts": ["a", "c"], - "ref": ["test.t3.a", "test.t3.c"], - "rows": 2, - "filtered": 100, - "materialized": { - "lateral": 1, - "query_block": { - "select_id": 2, - "outer_ref_condition": "t3.a is not null and t3.c is not null", - "table": { - "table_name": "t4", - "access_type": "ref", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "133", - "used_key_parts": ["a", "c"], - "ref": ["test.t3.a", "test.t3.c"], - "rows": 1, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "range", + "possible_keys": ["idx_b"], + "key": "idx_b", + "key_length": "5", + "used_key_parts": ["b"], + "rows": 2, + "filtered": 100, + "index_condition": "t3.b > 15", + "attached_condition": "t3.a is not null and t3.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "133", + "used_key_parts": ["a", "c"], + "ref": ["test.t3.a", "test.t3.c"], + "rows": 2, + "filtered": 100, + "materialized": { + "lateral": 1, + "query_block": { + "select_id": 2, + "outer_ref_condition": "t3.a is not null and t3.c is not null", + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "ref", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "133", + "used_key_parts": ["a", "c"], + "ref": ["test.t3.a", "test.t3.c"], + "rows": 1, + "filtered": 100 + } + } + ] + } } } } - } + ] } } set statement optimizer_switch='split_materialized=off' for select t3.a,t3.c,t.max,t.min @@ -15866,42 +18140,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "ALL", - "possible_keys": ["idx_b"], - "rows": 12, - "filtered": 83.33333588, - "attached_condition": "t3.b <= 15 and t3.a is not null and t3.c is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "133", - "used_key_parts": ["a", "c"], - "ref": ["test.t3.a", "test.t3.c"], - "rows": 4, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "t4.c, t4.a", - "temporary_table": { - "table": { - "table_name": "t4", - "access_type": "ALL", - "possible_keys": ["idx"], - "rows": 40, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "possible_keys": ["idx_b"], + "rows": 12, + "filtered": 83.33333588, + "attached_condition": "t3.b <= 15 and t3.a is not null and t3.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "133", + "used_key_parts": ["a", "c"], + "ref": ["test.t3.a", "test.t3.c"], + "rows": 4, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "t4.c, t4.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "ALL", + "possible_keys": ["idx"], + "rows": 40, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } drop index idx_a on t2; @@ -15951,59 +18235,71 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "133", - "used_key_parts": ["c", "b"], - "rows": 2, - "filtered": 100, - "index_condition": "t2.b between 80 and 85 and t2.c in ('y','z')", - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "t3", - "access_type": "ref", - "possible_keys": ["idx_a"], - "key": "idx_a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 1, - "filtered": 100, - "attached_condition": "t3.c is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "128", - "used_key_parts": ["c"], - "ref": ["test.t3.c"], - "rows": 2, - "filtered": 100, - "materialized": { - "lateral": 1, - "query_block": { - "select_id": 2, - "outer_ref_condition": "t3.c is not null", - "table": { - "table_name": "t4", - "access_type": "ref", - "possible_keys": ["idx_c"], - "key": "idx_c", - "key_length": "128", - "used_key_parts": ["c"], - "ref": ["test.t3.c"], - "rows": 2, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "133", + "used_key_parts": ["c", "b"], + "rows": 2, + "filtered": 100, + "index_condition": "t2.b between 80 and 85 and t2.c in ('y','z')", + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": ["idx_a"], + "key": "idx_a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 1, + "filtered": 100, + "attached_condition": "t3.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "128", + "used_key_parts": ["c"], + "ref": ["test.t3.c"], + "rows": 2, + "filtered": 100, + "materialized": { + "lateral": 1, + "query_block": { + "select_id": 2, + "outer_ref_condition": "t3.c is not null", + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "ref", + "possible_keys": ["idx_c"], + "key": "idx_c", + "key_length": "128", + "used_key_parts": ["c"], + "ref": ["test.t3.c"], + "rows": 2, + "filtered": 100 + } + } + ] + } } } } - } + ] } } set statement optimizer_switch='split_materialized=off' for select t2.a,t2.b,t2.c,t.c as t_c,t.max,t.min @@ -16086,7 +18382,7 @@ explain extended select t2.a,t2.b,t2.c,t.c as t_c,t.max,t.min from t2, t3, (select c, max(b) max, min(b) min from t4 group by c) t where t2.b < 40 and t2.a=t3.a and t3.c=t.c; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 90 63.28 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 90 60.00 Using where 1 PRIMARY t3 ref idx_a idx_a 5 test.t2.a 1 100.00 Using where 1 PRIMARY <derived2> ref key0 key0 128 test.t3.c 10 100.00 2 DERIVED t4 ALL idx_c NULL NULL NULL 160 100.00 Using temporary; Using filesort @@ -16099,53 +18395,65 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 90, - "filtered": 63.28125, - "attached_condition": "t2.b < 40 and t2.a is not null" - }, - "table": { - "table_name": "t3", - "access_type": "ref", - "possible_keys": ["idx_a"], - "key": "idx_a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 1, - "filtered": 100, - "attached_condition": "t3.c is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "128", - "used_key_parts": ["c"], - "ref": ["test.t3.c"], - "rows": 10, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "t4.c", - "temporary_table": { - "table": { - "table_name": "t4", - "access_type": "ALL", - "possible_keys": ["idx_c"], - "rows": 160, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 90, + "filtered": 60, + "attached_condition": "t2.b < 40 and t2.a is not null" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": ["idx_a"], + "key": "idx_a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 1, + "filtered": 100, + "attached_condition": "t3.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "128", + "used_key_parts": ["c"], + "ref": ["test.t3.c"], + "rows": 10, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "t4.c", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "ALL", + "possible_keys": ["idx_c"], + "rows": 160, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='split_materialized=off' for select * @@ -16199,68 +18507,82 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "133", - "used_key_parts": ["c", "b"], - "rows": 2, - "filtered": 100, - "index_condition": "t2.b between 80 and 85 and t2.c in ('y','z')", - "attached_condition": "t2.a is not null" - }, - "table": { - "table_name": "t3", - "access_type": "ref", - "possible_keys": ["idx_a"], - "key": "idx_a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 1, - "filtered": 100, - "attached_condition": "t3.c is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "128", - "used_key_parts": ["c"], - "ref": ["test.t3.c"], - "rows": 2, - "filtered": 100, - "materialized": { - "lateral": 1, - "query_block": { - "select_id": 2, - "outer_ref_condition": "t3.c is not null", - "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t4.c" - } - }, - "temporary_table": { - "table": { - "table_name": "t4", - "access_type": "ref", - "possible_keys": ["idx_c"], - "key": "idx_c", - "key_length": "128", - "used_key_parts": ["c"], - "ref": ["test.t3.c"], - "rows": 2, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "133", + "used_key_parts": ["c", "b"], + "rows": 2, + "filtered": 100, + "index_condition": "t2.b between 80 and 85 and t2.c in ('y','z')", + "attached_condition": "t2.a is not null" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": ["idx_a"], + "key": "idx_a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 1, + "filtered": 100, + "attached_condition": "t3.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "128", + "used_key_parts": ["c"], + "ref": ["test.t3.c"], + "rows": 2, + "filtered": 100, + "materialized": { + "lateral": 1, + "query_block": { + "select_id": 2, + "outer_ref_condition": "t3.c is not null", + "window_functions_computation": { + "sorts": [ + { + "filesort": { + "sort_key": "t4.c" + } + } + ], + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "ref", + "possible_keys": ["idx_c"], + "key": "idx_c", + "key_length": "128", + "used_key_parts": ["c"], + "ref": ["test.t3.c"], + "rows": 2, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } set statement optimizer_switch='split_materialized=off' for select * @@ -16583,7 +18905,7 @@ explain extended select * from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t where t2.b < 40 and t2.a=t3.a and t3.c=t.c; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 90 63.28 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 90 60.00 Using where 1 PRIMARY t3 ref idx_a idx_a 5 test.t2.a 1 100.00 Using where 1 PRIMARY <derived2> ref key0 key0 128 test.t3.c 10 100.00 2 DERIVED t4 ALL idx_c NULL NULL NULL 160 100.00 Using temporary @@ -16596,57 +18918,71 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 90, - "filtered": 63.28125, - "attached_condition": "t2.b < 40 and t2.a is not null" - }, - "table": { - "table_name": "t3", - "access_type": "ref", - "possible_keys": ["idx_a"], - "key": "idx_a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 1, - "filtered": 100, - "attached_condition": "t3.c is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "128", - "used_key_parts": ["c"], - "ref": ["test.t3.c"], - "rows": 10, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t4.c" - } - }, - "temporary_table": { - "table": { - "table_name": "t4", - "access_type": "ALL", - "possible_keys": ["idx_c"], - "rows": 160, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 90, + "filtered": 60, + "attached_condition": "t2.b < 40 and t2.a is not null" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": ["idx_a"], + "key": "idx_a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 1, + "filtered": 100, + "attached_condition": "t3.c is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "128", + "used_key_parts": ["c"], + "ref": ["test.t3.c"], + "rows": 10, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "window_functions_computation": { + "sorts": [ + { + "filesort": { + "sort_key": "t4.c" + } + } + ], + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "ALL", + "possible_keys": ["idx_c"], + "rows": 160, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } drop table t1,t2,t3,t4; @@ -16699,84 +19035,102 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t4", - "access_type": "range", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 1, - "filtered": 100, - "index_condition": "t4.a < 2", - "attached_condition": "t4.c is not null" - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "128", - "used_key_parts": ["c"], - "ref": ["test.t4.c"], - "rows": 2, - "filtered": 100, - "first_match": "t4", - "materialized": { - "lateral": 1, - "query_block": { - "select_id": 3, - "const_condition": "1", - "outer_ref_condition": "t4.c is not null", - "table": { - "table_name": "t3", - "access_type": "ref", - "possible_keys": ["c"], - "key": "c", - "key_length": "128", - "used_key_parts": ["c"], - "ref": ["test.t4.c"], - "rows": 2, - "filtered": 100 - }, - "table": { - "table_name": "<subquery4>", - "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": 4, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - }, - "block-nl-join": { + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "range", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 1, + "filtered": 100, + "index_condition": "t4.a < 2", + "attached_condition": "t4.c is not null" + } + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "128", + "used_key_parts": ["c"], + "ref": ["test.t4.c"], + "rows": 2, + "filtered": 100, + "first_match": "t4", + "materialized": { + "lateral": 1, + "query_block": { + "select_id": 3, + "const_condition": "1", + "outer_ref_condition": "t4.c is not null", + "nested_loop": [ + { "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 4, + "table_name": "t3", + "access_type": "ref", + "possible_keys": ["c"], + "key": "c", + "key_length": "128", + "used_key_parts": ["c"], + "ref": ["test.t4.c"], + "rows": 2, "filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "65", - "join_type": "BNL", - "attached_condition": "t2.i = t1.i and t2.i = t1.i" + } + }, + { + "table": { + "table_name": "<subquery4>", + "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": 4, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 4, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL", + "attached_condition": "t2.i = t1.i and t2.i = t1.i" + } + } + ] + } + } + } } - } + ] } } } } - } + ] } } DROP VIEW v1; @@ -16851,43 +19205,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "possible_keys": ["PRIMARY"], - "rows": 2, - "filtered": 100, - "attached_condition": "t1.f <> 5" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "4", - "used_key_parts": ["pk2"], - "ref": ["test.t1.pk1"], - "rows": 2, - "filtered": 100, - "materialized": { - "lateral": 1, - "query_block": { - "select_id": 2, - "table": { - "table_name": "t2", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["pk2"], - "ref": ["test.t1.pk1"], - "rows": 1, - "filtered": 100, - "using_index": true + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": ["PRIMARY"], + "rows": 2, + "filtered": 100, + "attached_condition": "t1.f <> 5" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "4", + "used_key_parts": ["pk2"], + "ref": ["test.t1.pk1"], + "rows": 2, + "filtered": 100, + "materialized": { + "lateral": 1, + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["pk2"], + "ref": ["test.t1.pk1"], + "rows": 1, + "filtered": 100, + "using_index": true + } + } + ] + } } } } - } + ] } } DROP VIEW v2; @@ -17283,58 +19647,66 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "r_loops": 1, - "rows": 4, - "r_rows": 2, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 50, - "attached_condition": "v1.a = 3", - "materialized": { - "query_block": { - "union_result": { - "table_name": "<union2,3>", - "access_type": "ALL", - "r_loops": 1, - "r_rows": 2, - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "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": 50, - "attached_condition": "t1.a = 3" - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "UNION", - "table": { - "message": "No tables used" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 50, + "attached_condition": "v1.a = 3", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 2, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "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": 50, + "attached_condition": "t1.a = 3" + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } } - } + ] } - ] + } } } } - } + ] } } SELECT * from v1 WHERE a=3; @@ -17381,73 +19753,91 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t3.`id` is not null and t3.`id` is not null" - }, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t3.id"], - "rows": 1, - "filtered": 100 - }, - "table": { - "table_name": "<subquery3>", - "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": 3, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t3.`id` is not null and t3.`id` is not null" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t3.id"], + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "<subquery3>", + "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": 3, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] + } } } - } - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t3.id"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "table_name": "cp2", - "access_type": "range", - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 8, - "filtered": 100, - "using_index_for_group_by": true + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t3.id"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "cp2", + "access_type": "range", + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 8, + "filtered": 100, + "using_index_for_group_by": true + } + } + ] + } } } } - } + ] } } set optimizer_switch="split_materialized=default"; @@ -17471,78 +19861,96 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t3.`id` is not null and t3.`id` is not null" - }, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t3.id"], - "rows": 1, - "filtered": 100 - }, - "table": { - "table_name": "<subquery3>", - "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": 3, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t3.`id` is not null and t3.`id` is not null" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t3.id"], + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "<subquery3>", + "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": 3, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] + } } } - } - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t3.id"], - "rows": 2, - "filtered": 100, - "materialized": { - "lateral": 1, - "query_block": { - "select_id": 2, - "outer_ref_condition": "t1.a is not null", - "table": { - "table_name": "cp2", - "access_type": "ref", - "possible_keys": ["a"], - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t1.a"], - "rows": 1, - "filtered": 100, - "attached_condition": "cp2.a = t3.`id`", - "using_index": true + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t3.id"], + "rows": 2, + "filtered": 100, + "materialized": { + "lateral": 1, + "query_block": { + "select_id": 2, + "outer_ref_condition": "t1.a is not null", + "nested_loop": [ + { + "table": { + "table_name": "cp2", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t1.a"], + "rows": 1, + "filtered": 100, + "attached_condition": "cp2.a = t3.`id`", + "using_index": true + } + } + ] + } } } } - } + ] } } prepare stmt from "select * from t1, (select a from t1 cp2 group by a) dt, t3 @@ -17664,60 +20072,72 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "range", - "possible_keys": ["t1_id"], - "key": "t1_id", - "key_length": "5", - "used_key_parts": ["t1_id"], - "rows": 47, - "filtered": 100, - "attached_condition": "t3.t1_id between 200 and 100000 and t3.t1_id is not null", - "using_index": true - }, - "table": { - "table_name": "t1", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["id"], - "ref": ["test.t3.t1_id"], - "rows": 1, - "filtered": 100, - "using_index": true - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["t1_id"], - "ref": ["test.t3.t1_id"], - "rows": 2, - "filtered": 100, - "materialized": { - "lateral": 1, - "query_block": { - "select_id": 2, - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["t1_id"], - "key": "t1_id", - "key_length": "5", - "used_key_parts": ["t1_id"], - "ref": ["test.t1.id"], - "rows": 3, - "filtered": 58.59375, - "index_condition": "t2.t1_id between 200 and 100000 and t2.t1_id = t3.t1_id", - "attached_condition": "t2.reporting_person = 1" + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "range", + "possible_keys": ["t1_id"], + "key": "t1_id", + "key_length": "5", + "used_key_parts": ["t1_id"], + "rows": 47, + "filtered": 100, + "attached_condition": "t3.t1_id between 200 and 100000 and t3.t1_id is not null", + "using_index": true + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["id"], + "ref": ["test.t3.t1_id"], + "rows": 1, + "filtered": 100, + "using_index": true + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["t1_id"], + "ref": ["test.t3.t1_id"], + "rows": 2, + "filtered": 100, + "materialized": { + "lateral": 1, + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["t1_id"], + "key": "t1_id", + "key_length": "5", + "used_key_parts": ["t1_id"], + "ref": ["test.t1.id"], + "rows": 3, + "filtered": 59.09090805, + "index_condition": "t2.t1_id between 200 and 100000 and t2.t1_id = t3.t1_id", + "attached_condition": "t2.reporting_person = 1" + } + } + ] + } } } } - } + ] } } set optimizer_switch='split_materialized=off'; @@ -17877,54 +20297,70 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "charges", - "access_type": "ALL", - "possible_keys": ["PRIMARY", "fk_charge_from_ledger", "fk_charge_to_ledger"], - "rows": 20, - "filtered": 40, - "attached_condition": "charges.to_ledger_id = 2" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "17", - "used_key_parts": ["ledger_id", "charge_id"], - "ref": ["test.charges.from_ledger_id", "test.charges.id"], - "rows": 2, - "filtered": 100, - "materialized": { - "lateral": 1, - "query_block": { - "select_id": 2, - "table": { - "table_name": "transaction_items", - "access_type": "ref", - "possible_keys": ["fk_items_transaction", "fk_items_charge"], - "key": "fk_items_charge", - "key_length": "9", - "used_key_parts": ["charge_id"], - "ref": ["test.charges.id"], - "rows": 2, - "filtered": 100 - }, - "table": { - "table_name": "transactions", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "fk_transactions_ledger"], - "key": "PRIMARY", - "key_length": "8", - "used_key_parts": ["id"], - "ref": ["test.transaction_items.transaction_id"], - "rows": 1, - "filtered": 100, - "attached_condition": "transactions.ledger_id = charges.from_ledger_id" + "nested_loop": [ + { + "table": { + "table_name": "charges", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY", + "fk_charge_from_ledger", + "fk_charge_to_ledger" + ], + "rows": 20, + "filtered": 40, + "attached_condition": "charges.to_ledger_id = 2" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "17", + "used_key_parts": ["ledger_id", "charge_id"], + "ref": ["test.charges.from_ledger_id", "test.charges.id"], + "rows": 2, + "filtered": 100, + "materialized": { + "lateral": 1, + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "transaction_items", + "access_type": "ref", + "possible_keys": ["fk_items_transaction", "fk_items_charge"], + "key": "fk_items_charge", + "key_length": "9", + "used_key_parts": ["charge_id"], + "ref": ["test.charges.id"], + "rows": 2, + "filtered": 100 + } + }, + { + "table": { + "table_name": "transactions", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "fk_transactions_ledger"], + "key": "PRIMARY", + "key_length": "8", + "used_key_parts": ["id"], + "ref": ["test.transaction_items.transaction_id"], + "rows": 1, + "filtered": 100, + "attached_condition": "transactions.ledger_id = charges.from_ledger_id" + } + } + ] + } } } } - } + ] } } set optimizer_switch='split_materialized=off'; @@ -18055,54 +20491,66 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "charges", - "access_type": "ALL", - "possible_keys": ["fk_charge_to_ledger"], - "rows": 20, - "filtered": 50, - "attached_condition": "charges.to_ledger_id = 2" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "18", - "used_key_parts": ["ledger_id", "charge_id"], - "ref": ["test.charges.from_ledger_id", "test.charges.id"], - "rows": 2, - "filtered": 100, - "materialized": { - "lateral": 1, - "query_block": { - "select_id": 2, - "table": { - "table_name": "transaction_items", - "access_type": "ref", - "possible_keys": ["fk_items_transaction", "fk_items_charge"], - "key": "fk_items_charge", - "key_length": "9", - "used_key_parts": ["charge_id"], - "ref": ["test.charges.id"], - "rows": 2, - "filtered": 100 - }, - "table": { - "table_name": "transactions", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "fk_transactions_ledger"], - "key": "PRIMARY", - "key_length": "8", - "used_key_parts": ["id"], - "ref": ["test.transaction_items.transaction_id"], - "rows": 1, - "filtered": 100, - "attached_condition": "transactions.ledger_id = charges.from_ledger_id" + "nested_loop": [ + { + "table": { + "table_name": "charges", + "access_type": "ALL", + "possible_keys": ["fk_charge_to_ledger"], + "rows": 20, + "filtered": 50, + "attached_condition": "charges.to_ledger_id = 2" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "18", + "used_key_parts": ["ledger_id", "charge_id"], + "ref": ["test.charges.from_ledger_id", "test.charges.id"], + "rows": 2, + "filtered": 100, + "materialized": { + "lateral": 1, + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "transaction_items", + "access_type": "ref", + "possible_keys": ["fk_items_transaction", "fk_items_charge"], + "key": "fk_items_charge", + "key_length": "9", + "used_key_parts": ["charge_id"], + "ref": ["test.charges.id"], + "rows": 2, + "filtered": 100 + } + }, + { + "table": { + "table_name": "transactions", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "fk_transactions_ledger"], + "key": "PRIMARY", + "key_length": "8", + "used_key_parts": ["id"], + "ref": ["test.transaction_items.transaction_id"], + "rows": 1, + "filtered": 100, + "attached_condition": "transactions.ledger_id = charges.from_ledger_id" + } + } + ] + } } } } - } + ] } } set optimizer_switch='split_materialized=off'; diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index 15a7784c890..b86cd1c42cc 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -381,41 +381,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "t2.f2 in (2,3) and t2.f2 is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["f1"], - "ref": ["test.t2.f2"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "t1.f1", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "t1.f1 in (2,3)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "t2.f2 in (2,3) and t2.f2 is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["f1"], + "ref": ["test.t2.f2"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "t1.f1", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "t1.f1 in (2,3)" + } + } + ] + } } } } } } - } + ] } } select * from v1 join v4 on f1=f2; @@ -475,46 +485,58 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "tt.f1", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "tt.f1 > 2", - "materialized": { - "query_block": { - "select_id": 3, - "filesort": { - "sort_key": "t1.f1", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "t1.f1 < 7 and t1.f1 > 2" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "tt.f1", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "tt.f1 > 2", + "materialized": { + "query_block": { + "select_id": 3, + "filesort": { + "sort_key": "t1.f1", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "t1.f1 < 7 and t1.f1 > 2" + } + } + ] + } + } + } } } } - } + ] } } } } } } - } + ] } } select * from (select * from @@ -544,58 +566,72 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "tt.f1 > 2 and tt.f1 > 2 and tt.f1 is not null", - "materialized": { - "query_block": { - "select_id": 3, - "filesort": { - "sort_key": "t1.f1", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "t1.f1 < 7 and t1.f1 > 2 and t1.f1 > 2" + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "tt.f1 > 2 and tt.f1 > 2 and tt.f1 is not null", + "materialized": { + "query_block": { + "select_id": 3, + "filesort": { + "sort_key": "t1.f1", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "t1.f1 < 7 and t1.f1 > 2 and t1.f1 > 2" + } + } + ] + } } } } } - } - }, - "table": { - "table_name": "<derived5>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["f1"], - "ref": ["tt.f1"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 5, - "filesort": { - "sort_key": "t1.f1", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "t1.f1 < 7 and t1.f1 > 2 and t1.f1 > 2" + }, + { + "table": { + "table_name": "<derived5>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["f1"], + "ref": ["tt.f1"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 5, + "filesort": { + "sort_key": "t1.f1", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "t1.f1 < 7 and t1.f1 > 2 and t1.f1 > 2" + } + } + ] + } } } } } } - } + ] } } flush status; @@ -671,92 +707,114 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "x.f1 is not null", - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "tt.f1", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "tt.f1 > 2", - "materialized": { - "query_block": { - "select_id": 3, - "filesort": { - "sort_key": "t1.f1", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "t1.f1 < 7 and t1.f1 > 2" + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "x.f1 is not null", + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "tt.f1", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "tt.f1 > 2", + "materialized": { + "query_block": { + "select_id": 3, + "filesort": { + "sort_key": "t1.f1", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "t1.f1 < 7 and t1.f1 > 2" + } + } + ] + } + } + } } } } - } + ] } } } } } - } - }, - "table": { - "table_name": "<derived4>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["f1"], - "ref": ["x.f1"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 4, - "filesort": { - "sort_key": "tt.f1", - "temporary_table": { - "table": { - "table_name": "<derived5>", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "tt.f1 > 2", - "materialized": { - "query_block": { - "select_id": 5, - "filesort": { - "sort_key": "t1.f1", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "t1.f1 < 7 and t1.f1 > 2" + }, + { + "table": { + "table_name": "<derived4>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["f1"], + "ref": ["x.f1"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 4, + "filesort": { + "sort_key": "tt.f1", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived5>", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "tt.f1 > 2", + "materialized": { + "query_block": { + "select_id": 5, + "filesort": { + "sort_key": "t1.f1", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "t1.f1 < 7 and t1.f1 > 2" + } + } + ] + } + } + } } } } - } + ] } } } } } } - } + ] } } select * from @@ -795,30 +853,38 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "v1.f1 < 7", - "materialized": { - "query_block": { - "select_id": 3, - "filesort": { - "sort_key": "t1.f1", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "t1.f1 < 7" + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "v1.f1 < 7", + "materialized": { + "query_block": { + "select_id": 3, + "filesort": { + "sort_key": "t1.f1", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "t1.f1 < 7" + } + } + ] + } } } } } } - } + ] } } select * from ( select * from v1 where f1 < 7) tt; @@ -873,41 +939,51 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "t2.f2 < 7 and t2.f2 in (2,3) and t2.f2 is not null" - }, - "table": { - "table_name": "<derived5>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["f1"], - "ref": ["test.t2.f2"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 5, - "filesort": { - "sort_key": "t1.f1", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 11, - "filtered": 100, - "attached_condition": "t1.f1 < 7 and t1.f1 in (2,3)" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "t2.f2 < 7 and t2.f2 in (2,3) and t2.f2 is not null" + } + }, + { + "table": { + "table_name": "<derived5>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["f1"], + "ref": ["test.t2.f2"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 5, + "filesort": { + "sort_key": "t1.f1", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 11, + "filtered": 100, + "attached_condition": "t1.f1 < 7 and t1.f1 in (2,3)" + } + } + ] + } } } } } } - } + ] } } select * from v6 join v7 on f2=f1; diff --git a/mysql-test/main/desc_index_range.result b/mysql-test/main/desc_index_range.result new file mode 100644 index 00000000000..6b1f2e31c31 --- /dev/null +++ b/mysql-test/main/desc_index_range.result @@ -0,0 +1,201 @@ +create table t1 ( +a int, +key (a desc) +); +insert into t1 select seq from seq_1_to_1000; +set optimizer_trace=1; +explain select * from t1 force index(a) where a in (2, 4, 6); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 5 NULL 3 Using where; Using index +select json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +from information_schema.optimizer_trace; +json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +[ + [ + "(6) <= (a DESC) <= (6)", + "(4) <= (a DESC) <= (4)", + "(2) <= (a DESC) <= (2)" + ] +] +set optimizer_trace=default; +# These should go in reverse order: +select * from t1 force index(a) where a in (2, 4, 6); +a +6 +4 +2 +drop table t1; +# +# Multi-part key tests +# +create table t1 ( +a int not null, +b int not null, +key ab(a, b desc) +); +insert into t1 select A.seq, B.seq*10 from seq_1_to_10 A, seq_1_to_10 B; +set optimizer_trace=1; +explain select * from t1 force index(ab) where a>=8 and b>=50; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ab ab 4 NULL 51 Using where; Using index +select json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +from information_schema.optimizer_trace; +json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +[ + ["(8) <= (a)"] +] +explain select * from t1 force index(ab) where a>=8 and b<=50; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ab ab 8 NULL 46 Using where; Using index +select json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +from information_schema.optimizer_trace; +json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +[ + ["(8,50) <= (a,b DESC)"] +] +select * from t1 force index(ab) where a>=8 and b<=50; +a b +8 50 +8 40 +8 30 +8 20 +8 10 +9 50 +9 40 +9 30 +9 20 +9 10 +10 50 +10 40 +10 30 +10 20 +10 10 +select * from t1 ignore index(ab) where a>=8 and b<=50 order by a, b desc; +a b +8 50 +8 40 +8 30 +8 20 +8 10 +9 50 +9 40 +9 30 +9 20 +9 10 +10 50 +10 40 +10 30 +10 20 +10 10 +explain +select * from t1 where a between 2 and 4 and b between 50 and 80; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ab ab 8 NULL 17 Using where; Using index +select json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +from information_schema.optimizer_trace; +json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +[ + ["(2,80) <= (a,b DESC) <= (4,50)"] +] +select * from t1 where a between 2 and 4 and b between 50 and 80; +a b +2 80 +2 70 +2 60 +2 50 +3 80 +3 70 +3 60 +3 50 +4 80 +4 70 +4 60 +4 50 +drop table t1; +create table t2 ( +a int not null, +b int not null, +key ab(a desc, b desc) +); +insert into t2 select A.seq, B.seq*10 from seq_1_to_10 A, seq_1_to_10 B; +explain +select * from t2 where a between 2 and 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range ab ab 4 NULL 40 Using where; Using index +select json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +from information_schema.optimizer_trace; +json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +[ + ["(4) <= (a DESC) <= (2)"] +] +explain +select * from t2 where a between 2 and 4 and b between 50 and 80; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range ab ab 8 NULL 31 Using where; Using index +select json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +from information_schema.optimizer_trace; +json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +[ + ["(4,80) <= (a DESC,b DESC) <= (2,50)"] +] +drop table t2; +# +# Check that "Using index for group-by" is disabled (it's not supported, yet) +# +CREATE TABLE t1 (p int NOT NULL, a int NOT NULL, PRIMARY KEY (p,a desc)); +insert into t1 select 2,seq from seq_0_to_1000; +EXPLAIN select MIN(a) from t1 where p = 2 group by p; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref PRIMARY PRIMARY 4 const 1000 Using index +select json_detailed(json_extract(trace, '$**.potential_group_range_indexes')) +from information_schema.optimizer_trace; +json_detailed(json_extract(trace, '$**.potential_group_range_indexes')) +[ + [ + { + "index": "PRIMARY", + "usable": false, + "cause": "Reverse-ordered (not supported yet)" + } + ] +] +drop table t1; +set optimizer_trace=default; +# +# MDEV-27426: Wrong result upon query using index_merge with DESC key +# +CREATE TABLE t1 (pk INT, a INT, b int, KEY(a), PRIMARY KEY(pk DESC)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,4,5),(2,9,6),(3,NULL,7),(4,NULL,8); +SELECT * FROM t1 WHERE pk > 10 OR a > 0; +pk a b +2 9 6 +1 4 5 +DROP TABLE t1; +# +# MDEV-27529: Wrong result upon query using index_merge with DESC key (#2) +# +create table t1 ( +pk int, +a int, +b int, +primary key(pk desc), +key(a), +key(b) +) engine=innodb; +insert into t1 values (0, 111111, 255); +insert into t1 select seq+50000, NULL, seq+1000 from seq_1_to_260; +insert into t1 values (10000, NULL, 255); +insert into t1 select seq+20000, seq+20000, seq+20000 from seq_1_to_1500; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +# Must use ROR-intersect: +explain select * from t1 where b = 255 AND a IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b b,a 5,5 NULL 1 Using intersect(b,a); Using where; Using index +select * from t1 where b = 255 AND a IS NULL; +pk a b +10000 NULL 255 +drop table t1; diff --git a/mysql-test/main/desc_index_range.test b/mysql-test/main/desc_index_range.test new file mode 100644 index 00000000000..ec52e254fe7 --- /dev/null +++ b/mysql-test/main/desc_index_range.test @@ -0,0 +1,143 @@ +# +# Tests for range access and descending indexes +# +--source include/have_sequence.inc +--source include/have_innodb.inc + +# The test uses optimizer trace: +--source include/not_embedded.inc + +create table t1 ( + a int, + key (a desc) +); +insert into t1 select seq from seq_1_to_1000; + +set optimizer_trace=1; +explain select * from t1 force index(a) where a in (2, 4, 6); + +#enable after fix MDEV-27871 +--disable_view_protocol +select json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +from information_schema.optimizer_trace; +--enable_view_protocol +set optimizer_trace=default; + +--echo # These should go in reverse order: +select * from t1 force index(a) where a in (2, 4, 6); +drop table t1; + +--echo # +--echo # Multi-part key tests +--echo # +create table t1 ( + a int not null, + b int not null, + key ab(a, b desc) +); + +insert into t1 select A.seq, B.seq*10 from seq_1_to_10 A, seq_1_to_10 B; + +#enable after fix MDEV-27871 +--disable_view_protocol +set optimizer_trace=1; +explain select * from t1 force index(ab) where a>=8 and b>=50; +select json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +from information_schema.optimizer_trace; + +explain select * from t1 force index(ab) where a>=8 and b<=50; +select json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +from information_schema.optimizer_trace; +--enable_view_protocol + +select * from t1 force index(ab) where a>=8 and b<=50; +select * from t1 ignore index(ab) where a>=8 and b<=50 order by a, b desc; + +#enable after fix MDEV-27871 +--disable_view_protocol +explain +select * from t1 where a between 2 and 4 and b between 50 and 80; +select json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +from information_schema.optimizer_trace; +--enable_view_protocol + +select * from t1 where a between 2 and 4 and b between 50 and 80; + +drop table t1; + +create table t2 ( + a int not null, + b int not null, + key ab(a desc, b desc) +); +insert into t2 select A.seq, B.seq*10 from seq_1_to_10 A, seq_1_to_10 B; + +#enable after fix MDEV-27871 +--disable_view_protocol +explain +select * from t2 where a between 2 and 4; +select json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +from information_schema.optimizer_trace; + +explain +select * from t2 where a between 2 and 4 and b between 50 and 80; +select json_detailed(json_extract(trace, '$**.range_access_plan.ranges')) +from information_schema.optimizer_trace; +--enable_view_protocol + +drop table t2; + +--echo # +--echo # Check that "Using index for group-by" is disabled (it's not supported, yet) +--echo # +CREATE TABLE t1 (p int NOT NULL, a int NOT NULL, PRIMARY KEY (p,a desc)); +insert into t1 select 2,seq from seq_0_to_1000; +EXPLAIN select MIN(a) from t1 where p = 2 group by p; +#enable after fix MDEV-27871 +--disable_view_protocol +select json_detailed(json_extract(trace, '$**.potential_group_range_indexes')) +from information_schema.optimizer_trace; +--enable_view_protocol +drop table t1; + +set optimizer_trace=default; + +--echo # +--echo # MDEV-27426: Wrong result upon query using index_merge with DESC key +--echo # + +CREATE TABLE t1 (pk INT, a INT, b int, KEY(a), PRIMARY KEY(pk DESC)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,4,5),(2,9,6),(3,NULL,7),(4,NULL,8); + +SELECT * FROM t1 WHERE pk > 10 OR a > 0; +DROP TABLE t1; + + +--echo # +--echo # MDEV-27529: Wrong result upon query using index_merge with DESC key (#2) +--echo # + +create table t1 ( + pk int, + a int, + b int, + primary key(pk desc), + key(a), + key(b) +) engine=innodb; + +insert into t1 values (0, 111111, 255); + +insert into t1 select seq+50000, NULL, seq+1000 from seq_1_to_260; + +insert into t1 values (10000, NULL, 255); +insert into t1 select seq+20000, seq+20000, seq+20000 from seq_1_to_1500; + +analyze table t1; + +--echo # Must use ROR-intersect: +explain select * from t1 where b = 255 AND a IS NULL; +select * from t1 where b = 255 AND a IS NULL; + +drop table t1; diff --git a/mysql-test/main/drop_table_force.result b/mysql-test/main/drop_table_force.result index 404d8be8b21..1dd0f1f9dab 100644 --- a/mysql-test/main/drop_table_force.result +++ b/mysql-test/main/drop_table_force.result @@ -1,6 +1,4 @@ -CALL mtr.add_suppression("Operating system error number"); -CALL mtr.add_suppression("The error means the system cannot"); -CALL mtr.add_suppression("returned OS error 71"); +CALL mtr.add_suppression("InnoDB: File .*test/t1\\.ibd was not found"); #Test1: table with missing .ibd can be dropped directly create table t1(a int)engine=innodb; drop table t1; diff --git a/mysql-test/main/drop_table_force.test b/mysql-test/main/drop_table_force.test index f3073e3b67d..04ebb997b80 100644 --- a/mysql-test/main/drop_table_force.test +++ b/mysql-test/main/drop_table_force.test @@ -10,9 +10,7 @@ # the new one, we have left some references to the original test case # -CALL mtr.add_suppression("Operating system error number"); -CALL mtr.add_suppression("The error means the system cannot"); -CALL mtr.add_suppression("returned OS error 71"); +CALL mtr.add_suppression("InnoDB: File .*test/t1\\.ibd was not found"); let $DATADIR= `select @@datadir`; diff --git a/mysql-test/main/events_1.result b/mysql-test/main/events_1.result index c425f88eab2..2f2a951158c 100644 --- a/mysql-test/main/events_1.result +++ b/mysql-test/main/events_1.result @@ -1,5 +1,6 @@ set sql_mode=""; call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted"); +call mtr.add_suppression("Incorrect definition of table mysql.event:.*"); drop database if exists events_test; drop database if exists db_x; drop database if exists mysqltest_db2; diff --git a/mysql-test/main/events_1.test b/mysql-test/main/events_1.test index 33b82730783..ba8a2059e2d 100644 --- a/mysql-test/main/events_1.test +++ b/mysql-test/main/events_1.test @@ -8,6 +8,7 @@ set sql_mode=""; --source include/default_charset.inc call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted"); +call mtr.add_suppression("Incorrect definition of table mysql.event:.*"); --disable_warnings drop database if exists events_test; diff --git a/mysql-test/main/events_restart.result b/mysql-test/main/events_restart.result index 47092beed0e..58401c7be80 100644 --- a/mysql-test/main/events_restart.result +++ b/mysql-test/main/events_restart.result @@ -21,6 +21,7 @@ insert into event_like select * from mysql.event; alter table mysql.event change column body body longtext character set utf8 collate utf8_bin; "Now we restart the server" +call mtr.add_suppression("Incorrect definition of table mysql.event:.*"); # restart use events_test; select @@event_scheduler; diff --git a/mysql-test/main/events_restart.test b/mysql-test/main/events_restart.test index 624c4188f9a..6f7c01d81c2 100644 --- a/mysql-test/main/events_restart.test +++ b/mysql-test/main/events_restart.test @@ -45,6 +45,7 @@ alter table mysql.event change column body body longtext character set utf8 collate utf8_bin; --echo "Now we restart the server" +call mtr.add_suppression("Incorrect definition of table mysql.event:.*"); --source include/restart_mysqld.inc use events_test; diff --git a/mysql-test/main/except.result b/mysql-test/main/except.result index 72d2a312bd2..3dc4e1c9470 100644 --- a/mysql-test/main/except.result +++ b/mysql-test/main/except.result @@ -37,24 +37,32 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } + } + ] } }, { "query_block": { "select_id": 2, "operation": "EXCEPT", - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 2, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } + } + ] } } ] @@ -76,17 +84,21 @@ 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 - } + "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 + } + } + ] } }, { @@ -95,17 +107,21 @@ ANALYZE "operation": "EXCEPT", "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "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": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } } ] @@ -119,66 +135,78 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "r_loops": 1, - "rows": 2, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "r_loops": 1, - "r_rows": 1, - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "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 - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "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": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 1, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "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 + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t2", + "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 + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } select * from ((select a,b from t1) except (select c,d from t2)) a; @@ -247,46 +275,58 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 2, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL" - } + { + "block-nl-join": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL" + } + } + ] } }, { "query_block": { "select_id": 2, "operation": "EXCEPT", - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 2, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "t4", - "access_type": "ALL", - "rows": 2, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL" - } + { + "block-nl-join": { + "table": { + "table_name": "t4", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL" + } + } + ] } } ] @@ -308,34 +348,40 @@ 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 - }, - "block-nl-join": { - "table": { - "table_name": "t3", - "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": "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 + } }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL", - "r_filtered": 100 - } + { + "block-nl-join": { + "table": { + "table_name": "t3", + "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 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "r_filtered": 100 + } + } + ] } }, { @@ -344,34 +390,40 @@ ANALYZE "operation": "EXCEPT", "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "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 - }, - "block-nl-join": { - "table": { - "table_name": "t4", - "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": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL", - "r_filtered": 100 - } + { + "block-nl-join": { + "table": { + "table_name": "t4", + "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 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "r_filtered": 100 + } + } + ] } } ] @@ -386,100 +438,116 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "r_loops": 1, - "rows": 4, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "r_loops": 1, - "r_rows": 3, - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "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 - }, - "block-nl-join": { - "table": { - "table_name": "t3", - "access_type": "ALL", + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 3, + "query_specifications": [ + { + "query_block": { + "select_id": 2, "r_loops": 1, - "rows": 2, - "r_rows": 2, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL", - "r_filtered": 100 - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "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 + "r_total_time_ms": "REPLACED", + "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 + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t3", + "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 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "r_filtered": 100 + } + } + ] + } }, - "block-nl-join": { - "table": { - "table_name": "t4", - "access_type": "ALL", + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", "r_loops": 1, - "rows": 2, - "r_rows": 2, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL", - "r_filtered": 100 + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t2", + "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 + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t4", + "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 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "r_filtered": 100 + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } select * from ((select a,b,e,f from t1,t3) except (select c,d,g,h from t2,t4)) a; diff --git a/mysql-test/main/except_all.result b/mysql-test/main/except_all.result index befd7e0f15a..ac032221cc5 100644 --- a/mysql-test/main/except_all.result +++ b/mysql-test/main/except_all.result @@ -65,24 +65,32 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 7, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100 + } + } + ] } }, { "query_block": { "select_id": 2, "operation": "EXCEPT", - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 7, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 7, + "filtered": 100 + } + } + ] } } ] @@ -111,66 +119,78 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "r_loops": 1, - "rows": 7, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "r_loops": 1, - "r_rows": 4, - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 7, - "r_rows": 7, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 1, - "rows": 7, - "r_rows": 7, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 4, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } ANALYZE format=json select * from ((select a from t1) except all (select c from t2)) a; @@ -180,66 +200,78 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "r_loops": 1, - "rows": 7, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "r_loops": 1, - "r_rows": 4, - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 7, - "r_rows": 7, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 1, - "rows": 7, - "r_rows": 7, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 4, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } select * from ((select a from t1) except all (select c from t2)) a; @@ -349,67 +381,83 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 9, - "filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL" - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 2, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL" + } + } + ] + } }, - "block-nl-join": { - "table": { - "table_name": "t4", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL" + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t4", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL" + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } ANALYZE format=json (select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4); @@ -427,34 +475,40 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL", - "r_filtered": 100 - } + { + "block-nl-join": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "r_filtered": 100 + } + } + ] } }, { @@ -463,34 +517,40 @@ ANALYZE "operation": "EXCEPT", "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "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 - }, - "block-nl-join": { - "table": { - "table_name": "t4", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "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 + } }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL", - "r_filtered": 100 - } + { + "block-nl-join": { + "table": { + "table_name": "t4", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "r_filtered": 100 + } + } + ] } } ] @@ -504,100 +564,116 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "r_loops": 1, - "rows": 9, - "r_rows": 7, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "table_name": "<except2,3>", - "access_type": "ALL", - "r_loops": 1, - "r_rows": 7, - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "t3", - "access_type": "ALL", + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 9, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<except2,3>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 7, + "query_specifications": [ + { + "query_block": { + "select_id": 2, "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL", - "r_filtered": 100 - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "EXCEPT", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "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 + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "r_filtered": 100 + } + } + ] + } }, - "block-nl-join": { - "table": { - "table_name": "t4", - "access_type": "ALL", + { + "query_block": { + "select_id": 3, + "operation": "EXCEPT", "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL", - "r_filtered": 100 + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t2", + "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 + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t4", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "r_filtered": 100 + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } prepare stmt from "(select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)"; diff --git a/mysql-test/main/explain_json.result b/mysql-test/main/explain_json.result index e93564132b3..cf1aa172146 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 + } + } + ] } } ] @@ -251,24 +307,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 + } + } + ] } } ] @@ -285,25 +349,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" + } + } + ] } } } @@ -317,26 +389,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" + } + } + ] } } } @@ -355,26 +435,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; @@ -452,12 +538,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 + } + } + ] } } ] @@ -476,30 +566,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 @@ -509,41 +607,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 + } + } + ] + } } } } } } - } + ] } } # @@ -555,38 +663,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 + } + } + ] + } } } } } - } + ] } } # @@ -601,46 +719,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" - } + ] } } # @@ -657,25 +787,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" + } + } + ] } } # @@ -694,26 +830,34 @@ 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; @@ -730,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' @@ -752,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; @@ -784,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" + } + } + ] } } ] @@ -850,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" + } + } + ] } } ] @@ -897,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 + } + } + ] } } ] @@ -947,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; @@ -966,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; @@ -1041,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'); @@ -1059,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; @@ -1083,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; @@ -1103,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; @@ -1136,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 + } + } + ] } } } @@ -1155,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 + } + } + ] } } } @@ -1185,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 + } + } + ] } } } @@ -1211,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 @@ -1249,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 @@ -1274,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: @@ -1310,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 @@ -1340,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 @@ -1385,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 + } + } + ] } } } @@ -1417,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 + } + } + ] } } } @@ -1475,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 @@ -1510,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; @@ -1564,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": { @@ -1577,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" + } + } + ] } } } @@ -1601,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; @@ -1619,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 ; @@ -1637,17 +1923,91 @@ EXPLAIN { "query_block": { "select_id": 1, - "read_sorted_file": { - "filesort": { - "sort_key": "t1.a desc, t1.b", + "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; +# +# MDEV-27204: [ERROR] Json_writer: a member name was expected, Assertion `got_name == named_item_expected()' failed +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +explain FORMAT=JSON +SELECT * FROM t1 t0 +WHERE t0.a IN (SELECT t2.a FROM t1 t2 WHERE t0.a IN (SELECT t3.a FROM t1 t3)); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { "table": { - "table_name": "t1", + "table_name": "t0", "access_type": "ALL", - "rows": 3, + "rows": 2, "filtered": 100 } + }, + { + "duplicates_removal": [ + { + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "152", + "join_type": "BNL", + "attached_condition": "t2.a = t0.a" + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + }, + "buffer_type": "incremental", + "buffer_size": "109", + "join_type": "BNL", + "attached_condition": "t3.a = t0.a" + } + } + ] } - } + ] } } -drop table t1; +DROP TABLE t1; +# +# MDEV-27206: [ERROR] Duplicated key: cause, Assertion `is_uniq_key' failed with optimizer trace +# +CREATE TABLE t1 (a INT) ENGINE=MyISAM; +CREATE TABLE t2 (pk TIME, b INT, primary key (pk), key (b)) ENGINE=MyISAM; +INSERT INTO t2 VALUES +('00:13:33',0),('00:13:34',1),('00:13:35',2),('00:13:36',3), +('00:13:37',4),('00:13:38',5),('00:13:39',6),('00:13:40',7), +('00:13:41',8),('00:13:42',9); +SET optimizer_trace = 'enabled=on'; +SELECT * FROM t1 WHERE a IN ( SELECT b FROM t2 INNER JOIN t1 ON (a = pk) ); +a +DROP TABLE t1, t2; diff --git a/mysql-test/main/explain_json.test b/mysql-test/main/explain_json.test index cfbc0cfa10c..07e4ec09ad4 100644 --- a/mysql-test/main/explain_json.test +++ b/mysql-test/main/explain_json.test @@ -419,3 +419,27 @@ explain format=json select * from t1 order by a desc, b desc; explain format=json select * from t1 order by a desc, b ; drop table t1; +--echo # +--echo # MDEV-27204: [ERROR] Json_writer: a member name was expected, Assertion `got_name == named_item_expected()' failed +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +explain FORMAT=JSON +SELECT * FROM t1 t0 +WHERE t0.a IN (SELECT t2.a FROM t1 t2 WHERE t0.a IN (SELECT t3.a FROM t1 t3)); +DROP TABLE t1; + +--echo # +--echo # MDEV-27206: [ERROR] Duplicated key: cause, Assertion `is_uniq_key' failed with optimizer trace +--echo # + +CREATE TABLE t1 (a INT) ENGINE=MyISAM; +CREATE TABLE t2 (pk TIME, b INT, primary key (pk), key (b)) ENGINE=MyISAM; +INSERT INTO t2 VALUES + ('00:13:33',0),('00:13:34',1),('00:13:35',2),('00:13:36',3), + ('00:13:37',4),('00:13:38',5),('00:13:39',6),('00:13:40',7), + ('00:13:41',8),('00:13:42',9); +SET optimizer_trace = 'enabled=on'; +SELECT * FROM t1 WHERE a IN ( SELECT b FROM t2 INNER JOIN t1 ON (a = pk) ); +DROP TABLE t1, t2;
\ No newline at end of file diff --git a/mysql-test/main/explain_json_format_partitions.result b/mysql-test/main/explain_json_format_partitions.result index 0c7d9e93105..f164006d756 100644 --- a/mysql-test/main/explain_json_format_partitions.result +++ b/mysql-test/main/explain_json_format_partitions.result @@ -12,14 +12,18 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "partitions": ["p0"], - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "attached_condition": "t1.a in (2,3,4)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "partitions": ["p0"], + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "attached_condition": "t1.a in (2,3,4)" + } + } + ] } } analyze format=json select * from t1 where a in (2,3,4); @@ -29,19 +33,23 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "partitions": ["p0"], - "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": 30, - "attached_condition": "t1.a in (2,3,4)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "partitions": ["p0"], + "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": 30, + "attached_condition": "t1.a in (2,3,4)" + } + } + ] } } analyze format=json update t1 set a=a+10 where a in (2,3,4); diff --git a/mysql-test/main/explain_json_innodb.result b/mysql-test/main/explain_json_innodb.result index 8cec65642b4..871c0d6a258 100644 --- a/mysql-test/main/explain_json_innodb.result +++ b/mysql-test/main/explain_json_innodb.result @@ -16,39 +16,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100 - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } + } + ], "subqueries": [ { "query_block": { "select_id": 2, - "table": { - "table_name": "tbl_alias1", - "access_type": "ALL", - "rows": 1, - "filtered": 100, - "attached_condition": "tbl_alias1.column_name_2 is not null and tbl_alias1.column_name_1 is not null" - }, - "table": { - "table_name": "tbl_alias2", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "9", - "used_key_parts": ["c", "b"], - "ref": [ - "test.tbl_alias1.column_name_2", - "test.tbl_alias1.column_name_1" - ], - "rows": 1, - "filtered": 100, - "attached_condition": "tbl_alias2.c = tbl_alias1.column_name_2", - "using_index": true - } + "nested_loop": [ + { + "table": { + "table_name": "tbl_alias1", + "access_type": "ALL", + "rows": 1, + "filtered": 100, + "attached_condition": "tbl_alias1.column_name_2 is not null and tbl_alias1.column_name_1 is not null" + } + }, + { + "table": { + "table_name": "tbl_alias2", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "9", + "used_key_parts": ["c", "b"], + "ref": [ + "test.tbl_alias1.column_name_2", + "test.tbl_alias1.column_name_1" + ], + "rows": 1, + "filtered": 100, + "attached_condition": "tbl_alias2.c = tbl_alias1.column_name_2", + "using_index": true + } + } + ] } } ] diff --git a/mysql-test/main/func_group.result b/mysql-test/main/func_group.result index 244fdb2856f..8f9c27eeb86 100644 --- a/mysql-test/main/func_group.result +++ b/mysql-test/main/func_group.result @@ -317,7 +317,7 @@ a3 char(3), a4 real, a5 date, key k1(a2,a3), -key k2(a4 desc,a1), +key k2(a4 /*desc*/,a1), key k3(a5,a1) ); create table t2( diff --git a/mysql-test/main/func_group.test b/mysql-test/main/func_group.test index e17ed45180b..842ca4388ef 100644 --- a/mysql-test/main/func_group.test +++ b/mysql-test/main/func_group.test @@ -202,7 +202,7 @@ create table t1( a4 real, a5 date, key k1(a2,a3), - key k2(a4 desc,a1), + key k2(a4 /*desc*/,a1), key k3(a5,a1) ); create table t2( diff --git a/mysql-test/main/func_math.result b/mysql-test/main/func_math.result index f618ffd89a3..746dd9169ca 100644 --- a/mysql-test/main/func_math.result +++ b/mysql-test/main/func_math.result @@ -1838,24 +1838,118 @@ CRC32(99999999999999999999999999999999) SELECT CRC32(-99999999999999999999999999999999); CRC32(-99999999999999999999999999999999) 1052326872 +SELECT CRC32C(NULL), CRC32C(''), CRC32C('MariaDB'), CRC32C('mariadb'); +CRC32C(NULL) CRC32C('') CRC32C('MariaDB') CRC32C('mariadb') +NULL 0 809606978 1378644259 +SELECT CRC32(NULL,1),CRC32C(NULL,1), CRC32(1,''), CRC32C(1,''); +CRC32(NULL,1) CRC32C(NULL,1) CRC32(1,'') CRC32C(1,'') +NULL NULL 1 1 +SELECT CRC32(42,''),CRC32C(42,''),CRC32('42',''),CRC32C('42',''); +CRC32(42,'') CRC32C(42,'') CRC32('42','') CRC32C('42','') +42 42 42 42 +SELECT CRC32(42,NULL),CRC32C(42,NULL); +CRC32(42,NULL) CRC32C(42,NULL) +NULL NULL +SELECT CRC32 ('5c',''),CRC32 ('5c',0),CRC32 ('5c', '0'),CRC32 ('5c',NULL); +CRC32 ('5c','') CRC32 ('5c',0) CRC32 ('5c', '0') CRC32 ('5c',NULL) +5 2226203566 2226203566 NULL +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '5c' +Warning 1292 Truncated incorrect INTEGER value: '5c' +Warning 1292 Truncated incorrect INTEGER value: '5c' +Warning 1292 Truncated incorrect INTEGER value: '5c' +SELECT CRC32C('5c',''),CRC32C('5c',0),CRC32C('5c', '0'),CRC32C('5c',NULL); +CRC32C('5c','') CRC32C('5c',0) CRC32C('5c', '0') CRC32C('5c',NULL) +5 1466896124 1466896124 NULL +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '5c' +Warning 1292 Truncated incorrect INTEGER value: '5c' +Warning 1292 Truncated incorrect INTEGER value: '5c' +Warning 1292 Truncated incorrect INTEGER value: '5c' +SELECT CRC32('MariaDB',NULL),CRC32C('MariaDB',NULL); +CRC32('MariaDB',NULL) CRC32C('MariaDB',NULL) +NULL NULL +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'MariaDB' +Warning 1292 Truncated incorrect INTEGER value: 'MariaDB' +SELECT CRC32(CRC32('MySQL'),''),CRC32(CRC32('My'),'SQL'),CRC32(0,'MySQL'); +CRC32(CRC32('MySQL'),'') CRC32(CRC32('My'),'SQL') CRC32(0,'MySQL') +3259397556 3259397556 3259397556 +SELECT CRC32C(CRC32C('MariaDB'),''),CRC32C(CRC32C('Maria'),'DB'),CRC32C(0,'MariaDB'); +CRC32C(CRC32C('MariaDB'),'') CRC32C(CRC32C('Maria'),'DB') CRC32C(0,'MariaDB') +809606978 809606978 809606978 +select crc32(0,'My','SQL'); +ERROR 42000: Incorrect parameter count in the call to native function 'crc32' +select crc32c(0,'Maria','DB'); +ERROR 42000: Incorrect parameter count in the call to native function 'crc32c' +select crc32(); +ERROR 42000: Incorrect parameter count in the call to native function 'crc32' +select crc32c(); +ERROR 42000: Incorrect parameter count in the call to native function 'crc32c' +select crc32('' as empty); +ERROR 42000: Incorrect parameters in the call to native function 'crc32' +select crc32c('' as empty); +ERROR 42000: Incorrect parameters in the call to native function 'crc32c' +select crc32(0, '' as empty); +ERROR 42000: Incorrect parameters in the call to native function 'crc32' +select crc32c(0, '' as empty); +ERROR 42000: Incorrect parameters in the call to native function 'crc32c' +select crc32(0 as zero, ''); +ERROR 42000: Incorrect parameters in the call to native function 'crc32' +select crc32c(0 as zero, ''); +ERROR 42000: Incorrect parameters in the call to native function 'crc32c' +CREATE TEMPORARY TABLE t +(a CHAR(2), i INT UNSIGNED, c INT UNSIGNED AS (CRC32C(i,a))); +INSERT INTO t (a,i) VALUES ('DB',CRC32C('Maria')); +SELECT * FROM t; +a i c +DB 1253907744 809606978 +DROP TEMPORARY TABLE t; +select crc32(4294967296,''), hex(char(4294967296)); +crc32(4294967296,'') hex(char(4294967296)) +0 00 +select crc32(1e100,''), hex(char(1e100)); +crc32(1e100,'') hex(char(1e100)) +4294967295 FFFFFFFF +select crc32(10.11,''), hex(char(10.11)); +crc32(10.11,'') hex(char(10.11)) +10 0A +select crc32(-1,''), hex(char(-1)); +crc32(-1,'') hex(char(-1)) +4294967295 FFFFFFFF +select crc32('',''), hex(char('')); +crc32('','') hex(char('')) +0 00 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '' +Warning 1292 Truncated incorrect INTEGER value: '' +select crc32(429496729656755555555555555555555555555555555555555555555555555555555555555555555555555,'a') as x; +x +3310005809 +Warnings: +Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated +Warning 1916 Got overflow when converting '99999999999999999999999999999999999999999999999999999999999999999' to INT. Value truncated +select crc32(429496729656755555555555555555555555555555555555555555555555555555555555555555555555555,'a') as x; +x +3310005809 DROP TABLE IF EXISTS t; Warnings: Note 1051 Unknown table 'test.t' CREATE TABLE t(a INT, b VARCHAR(2)); INSERT INTO t VALUES (1,'a'), (2,'qw'), (1,'t'), (3,'t'); -SELECT crc32(SUM(a)) FROM t; -crc32(SUM(a)) -1790921346 -SELECT crc32(AVG(a)) FROM t GROUP BY b; -crc32(AVG(a)) -768278432 -2875100430 -2875100430 -SELECT crc32(MAX(b)) FROM t GROUP BY a; -crc32(MAX(b)) -2238339752 -3114057431 -2238339752 +SELECT crc32(SUM(a)),crc32c(SUM(a)) FROM t; +crc32(SUM(a)) crc32c(SUM(a)) +1790921346 3058990603 +SELECT crc32(AVG(a)),crc32c(AVG(a)) FROM t GROUP BY b; +crc32(AVG(a)) crc32c(AVG(a)) +768278432 1816172052 +2875100430 1492934094 +2875100430 1492934094 +SELECT crc32(MAX(b)),crc32c(MAX(b)) FROM t GROUP BY a; +crc32(MAX(b)) crc32c(MAX(b)) +2238339752 3833565251 +3114057431 4173859780 +2238339752 3833565251 SELECT a, b, crc32(a) FROM t GROUP BY a,b HAVING crc32(MAX(a))=450215437; a b crc32(a) 2 qw 450215437 diff --git a/mysql-test/main/func_math.test b/mysql-test/main/func_math.test index c865aa88660..02c5b872ea5 100644 --- a/mysql-test/main/func_math.test +++ b/mysql-test/main/func_math.test @@ -870,15 +870,66 @@ SELECT CRC32('01234567'), CRC32('012345678'); SELECT CRC32('~!@$%^*'), CRC32('-0.0001'); SELECT CRC32(99999999999999999999999999999999); SELECT CRC32(-99999999999999999999999999999999); +#enable_after fix MDEV-28535 +--disable_view_protocol +SELECT CRC32C(NULL), CRC32C(''), CRC32C('MariaDB'), CRC32C('mariadb'); +--enable_view_protocol +SELECT CRC32(NULL,1),CRC32C(NULL,1), CRC32(1,''), CRC32C(1,''); +SELECT CRC32(42,''),CRC32C(42,''),CRC32('42',''),CRC32C('42',''); +SELECT CRC32(42,NULL),CRC32C(42,NULL); +SELECT CRC32 ('5c',''),CRC32 ('5c',0),CRC32 ('5c', '0'),CRC32 ('5c',NULL); +SELECT CRC32C('5c',''),CRC32C('5c',0),CRC32C('5c', '0'),CRC32C('5c',NULL); +SELECT CRC32('MariaDB',NULL),CRC32C('MariaDB',NULL); +SELECT CRC32(CRC32('MySQL'),''),CRC32(CRC32('My'),'SQL'),CRC32(0,'MySQL'); +SELECT CRC32C(CRC32C('MariaDB'),''),CRC32C(CRC32C('Maria'),'DB'),CRC32C(0,'MariaDB'); + +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select crc32(0,'My','SQL'); +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select crc32c(0,'Maria','DB'); +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select crc32(); +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select crc32c(); +--error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select crc32('' as empty); +--error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select crc32c('' as empty); +--error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select crc32(0, '' as empty); +--error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select crc32c(0, '' as empty); +--error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select crc32(0 as zero, ''); +--error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select crc32c(0 as zero, ''); + +CREATE TEMPORARY TABLE t +(a CHAR(2), i INT UNSIGNED, c INT UNSIGNED AS (CRC32C(i,a))); +INSERT INTO t (a,i) VALUES ('DB',CRC32C('Maria')); +SELECT * FROM t; +DROP TEMPORARY TABLE t; + +select crc32(4294967296,''), hex(char(4294967296)); +select crc32(1e100,''), hex(char(1e100)); +select crc32(10.11,''), hex(char(10.11)); +select crc32(-1,''), hex(char(-1)); +select crc32('',''), hex(char('')); +--disable_ps_protocol +select crc32(429496729656755555555555555555555555555555555555555555555555555555555555555555555555555,'a') as x; +--enable_ps_protocol +--disable_warnings +select crc32(429496729656755555555555555555555555555555555555555555555555555555555555555555555555555,'a') as x; +--enable_warnings # Test cases for using the function in aggregate functions, group-by, having # and order-by clauses DROP TABLE IF EXISTS t; CREATE TABLE t(a INT, b VARCHAR(2)); INSERT INTO t VALUES (1,'a'), (2,'qw'), (1,'t'), (3,'t'); -SELECT crc32(SUM(a)) FROM t; -SELECT crc32(AVG(a)) FROM t GROUP BY b; -SELECT crc32(MAX(b)) FROM t GROUP BY a; +SELECT crc32(SUM(a)),crc32c(SUM(a)) FROM t; +SELECT crc32(AVG(a)),crc32c(AVG(a)) FROM t GROUP BY b; +SELECT crc32(MAX(b)),crc32c(MAX(b)) FROM t GROUP BY a; SELECT a, b, crc32(a) FROM t GROUP BY a,b HAVING crc32(MAX(a))=450215437; SELECT a,b,concat(a,b),crc32(concat(a,b)) FROM t ORDER BY crc32(concat(a,b)); DROP TABLE t; diff --git a/mysql-test/main/grant_not_windows.result b/mysql-test/main/grant_utf8_cli.result index fedfaf984b2..fedfaf984b2 100644 --- a/mysql-test/main/grant_not_windows.result +++ b/mysql-test/main/grant_utf8_cli.result diff --git a/mysql-test/main/grant_not_windows.test b/mysql-test/main/grant_utf8_cli.test index 55b09232edc..bc811d5298e 100644 --- a/mysql-test/main/grant_not_windows.test +++ b/mysql-test/main/grant_utf8_cli.test @@ -1,6 +1,5 @@ - # UTF8 parameters to mysql client do not work on Windows ---source include/not_windows.inc --source include/not_embedded.inc +--source include/check_utf8_cli.inc # # Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte diff --git a/mysql-test/main/group_min_max.result b/mysql-test/main/group_min_max.result index af9f2767a6c..2b8b10b29b9 100644 --- a/mysql-test/main/group_min_max.result +++ b/mysql-test/main/group_min_max.result @@ -2080,19 +2080,19 @@ id select_type table type possible_keys key key_len ref rows Extra explain extended select a1,a2,min(b),max(b) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 97.06 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 96.30 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2` explain extended select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 39.55 Using where; Using temporary; Using filesort +1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 26.37 Using where; Using temporary; Using filesort Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain extended select a1,a2,b,c from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 39.55 Using where; Using temporary; Using filesort +1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 26.37 Using where; Using temporary; Using filesort Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c` explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1; @@ -2100,7 +2100,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 97.06 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 96.30 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1; diff --git a/mysql-test/main/having_cond_pushdown.result b/mysql-test/main/having_cond_pushdown.result index fea8f83f9a1..59388aa7ca0 100644 --- a/mysql-test/main/having_cond_pushdown.result +++ b/mysql-test/main/having_cond_pushdown.result @@ -37,13 +37,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 2" + } + } + ] } } } @@ -59,13 +63,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 2" + } + } + ] } } } @@ -97,13 +105,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 2" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,MAX(t1.b) @@ -114,13 +126,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 2" + } + } + ] } } # extracted AND formula @@ -155,13 +171,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.a < 4" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.a < 4" + } + } + ] } } } @@ -177,13 +197,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.a < 4" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.a < 4" + } + } + ] } } } @@ -222,13 +246,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1 or t1.a = 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1 or t1.a = 3" + } + } + ] } } } @@ -246,13 +274,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1 or t1.a = 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1 or t1.a = 3" + } + } + ] } } } @@ -291,13 +323,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 2 or t1.a < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 2 or t1.a < 3" + } + } + ] } } } @@ -315,13 +351,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 2 or t1.a < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 2 or t1.a < 3" + } + } + ] } } } @@ -357,13 +397,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] } } } @@ -381,13 +425,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] } } } @@ -422,13 +470,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] } } } @@ -446,13 +498,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] } } } @@ -484,13 +540,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "max(t1.a) = 3", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 3" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,MAX(t1.b) @@ -503,13 +563,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "max(t1.a) = 3", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 3" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for SELECT t1.a,MAX(t1.b) @@ -539,13 +603,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "max(t1.b) > 12", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 2" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,MAX(t1.b) @@ -558,13 +626,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "max(t1.b) > 12", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 2" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for SELECT t1.a,MAX(t1.b) @@ -597,13 +669,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] } } } @@ -621,13 +697,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] } } } @@ -664,13 +744,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] } } } @@ -688,13 +772,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] } } } @@ -726,13 +814,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "max(t1.b) = 13 and min(t1.c) = 2", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 2" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,MIN(t1.c) @@ -745,13 +837,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "max(t1.b) = 13 and min(t1.c) = 2", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 2" + } + } + ] } } # conjunctive subformula : no stored function pushdown @@ -785,13 +881,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] } } } @@ -809,13 +909,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] } } } @@ -858,41 +962,51 @@ EXPLAIN "filesort": { "sort_key": "v1.a", "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 4, - "filtered": 100, - "attached_condition": "t2.x > 1 and t2.x is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.x"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 4, + "filtered": 100, + "attached_condition": "t2.x > 1 and t2.x is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.x"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] + } } } } } } - } + ] } } } @@ -908,41 +1022,51 @@ EXPLAIN "filesort": { "sort_key": "v1.a", "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 4, - "filtered": 100, - "attached_condition": "t2.x > 1 and t2.x is not null" - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.x"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 3, - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1" + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 4, + "filtered": 100, + "attached_condition": "t2.x > 1 and t2.x is not null" + } + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.x"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 3, + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] + } } } } } } - } + ] } } } @@ -985,42 +1109,52 @@ EXPLAIN "filesort": { "sort_key": "v1.c", "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 4, - "filtered": 100, - "attached_condition": "t2.x is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.x"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.c > 2", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "t1.c > 2", - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 4, + "filtered": 100, + "attached_condition": "t2.x is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.x"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.c > 2", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "t1.c > 2", + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } } @@ -1036,42 +1170,52 @@ EXPLAIN "filesort": { "sort_key": "v1.c", "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 4, - "filtered": 100, - "attached_condition": "t2.x is not null" - }, - "table": { - "table_name": "<derived3>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.x"], - "rows": 2, - "filtered": 100, - "attached_condition": "v1.c > 2", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "t1.c > 2", - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 4, + "filtered": 100, + "attached_condition": "t2.x is not null" + } + }, + { + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.x"], + "rows": 2, + "filtered": 100, + "attached_condition": "v1.c > 2", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "t1.c > 2", + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + ] + } } } } } } - } + ] } } } @@ -1115,39 +1259,49 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["x", "MAX(t2.y)"], - "ref": ["test.t1.a", "test.t1.b"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 4, - "filtered": 100, - "attached_condition": "t2.x < 5 and t2.x > 1" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["x", "MAX(t2.y)"], + "ref": ["test.t1.a", "test.t1.b"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 4, + "filtered": 100, + "attached_condition": "t2.x < 5 and t2.x > 1" + } + } + ] + } } } } } - } + ] } } } @@ -1164,39 +1318,49 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null" - }, - "table": { - "table_name": "<subquery3>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["x", "MAX(t2.y)"], - "ref": ["test.t1.a", "test.t1.b"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 3, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 4, - "filtered": 100, - "attached_condition": "t2.x < 5 and t2.x > 1" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null" + } + }, + { + "table": { + "table_name": "<subquery3>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["x", "MAX(t2.y)"], + "ref": ["test.t1.a", "test.t1.b"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 3, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 4, + "filtered": 100, + "attached_condition": "t2.x < 5 and t2.x > 1" + } + } + ] + } } } } } - } + ] } } } @@ -1238,40 +1402,50 @@ EXPLAIN "filesort": { "sort_key": "t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.b < 14 and t1.a is not null and t1.b is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["x", "MAX(t2.y)"], - "ref": ["test.t1.a", "test.t1.b"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "`MAX(t2.y)` < 14", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 4, - "filtered": 100, - "attached_condition": "t2.x < 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.b < 14 and t1.a is not null and t1.b is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["x", "MAX(t2.y)"], + "ref": ["test.t1.a", "test.t1.b"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "`MAX(t2.y)` < 14", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 4, + "filtered": 100, + "attached_condition": "t2.x < 5" + } + } + ] + } } } } } - } + ] } } } @@ -1288,40 +1462,50 @@ EXPLAIN "filesort": { "sort_key": "t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.b < 14 and t1.a is not null and t1.b is not null" - }, - "table": { - "table_name": "<subquery3>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["x", "MAX(t2.y)"], - "ref": ["test.t1.a", "test.t1.b"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 3, - "having_condition": "`MAX(t2.y)` < 14", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 4, - "filtered": 100, - "attached_condition": "t2.x < 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.b < 14 and t1.a is not null and t1.b is not null" + } + }, + { + "table": { + "table_name": "<subquery3>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["x", "MAX(t2.y)"], + "ref": ["test.t1.a", "test.t1.b"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 3, + "having_condition": "`MAX(t2.y)` < 14", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 4, + "filtered": 100, + "attached_condition": "t2.x < 5" + } + } + ] + } } } } } - } + ] } } } @@ -1358,13 +1542,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] } } } @@ -1381,13 +1569,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + ] } } } @@ -1419,13 +1611,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "t1.a = 2 and t1.c = 2", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.b = 13" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.b = 13" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT MAX(t1.a),t1.a,t1.b,t1.c @@ -1438,13 +1634,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "t1.a = 2 and t1.c = 2", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.b = 13" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.b = 13" + } + } + ] } } # extracted AND formula : using equalities @@ -1477,13 +1677,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c = t1.a and t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c = t1.a and t1.a > 1" + } + } + ] } } } @@ -1498,13 +1702,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c = t1.a and t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c = t1.a and t1.a > 1" + } + } + ] } } } @@ -1535,13 +1743,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 2 and t1.c = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 2 and t1.c = 2" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,MAX(t1.b),t1.c @@ -1552,13 +1764,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 2 and t1.c = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 2 and t1.c = 2" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for SELECT t1.a,MAX(t1.b),t1.c @@ -1591,13 +1807,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c = t1.a and t1.a > 1 or t1.a < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c = t1.a and t1.a > 1 or t1.a < 3" + } + } + ] } } } @@ -1615,13 +1835,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c = t1.a and t1.a > 1 or t1.a < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c = t1.a and t1.a > 1 or t1.a < 3" + } + } + ] } } } @@ -1662,13 +1886,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c = t1.a and t1.a < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c = t1.a and t1.a < 3" + } + } + ] } } } @@ -1684,13 +1912,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c = t1.a and t1.a < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c = t1.a and t1.a < 3" + } + } + ] } } } @@ -1729,13 +1961,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c = t1.a and t1.a > 1 and t1.a < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c = t1.a and t1.a > 1 and t1.a < 3" + } + } + ] } } } @@ -1751,13 +1987,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c = t1.a and t1.a > 1 and t1.a < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c = t1.a and t1.a > 1 and t1.a < 3" + } + } + ] } } } @@ -1796,13 +2036,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c = t1.a and (t1.a > 1 or t1.a < 4) and t1.a < 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c = t1.a and (t1.a > 1 or t1.a < 4) and t1.a < 2" + } + } + ] } } } @@ -1820,13 +2064,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c = t1.a and (t1.a > 1 or t1.a < 4) and t1.a < 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c = t1.a and (t1.a > 1 or t1.a < 4) and t1.a < 2" + } + } + ] } } } @@ -1868,13 +2116,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c = t1.a and (t1.a > 1 or t1.a < 4)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c = t1.a and (t1.a > 1 or t1.a < 4)" + } + } + ] } } } @@ -1892,13 +2144,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c = t1.a and (t1.a > 1 or t1.a < 4)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c = t1.a and (t1.a > 1 or t1.a < 4)" + } + } + ] } } } @@ -1956,12 +2212,16 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + ] } } } @@ -1978,12 +2238,16 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + ] } } } @@ -2020,13 +2284,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a = 1 or t1.b > 10) and t1.b < 14" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a = 1 or t1.b > 10) and t1.b < 14" + } + } + ] } } } @@ -2042,13 +2310,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a = 1 or t1.b > 10) and t1.b < 14" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a = 1 or t1.b > 10) and t1.b < 14" + } + } + ] } } } @@ -2086,13 +2358,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a = 1 or t1.b > 10) and (t1.b < 14 or t1.b > 15)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a = 1 or t1.b > 10) and (t1.b < 14 or t1.b > 15)" + } + } + ] } } } @@ -2108,13 +2384,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a = 1 or t1.b > 10) and (t1.b < 14 or t1.b > 15)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a = 1 or t1.b > 10) and (t1.b < 14 or t1.b > 15)" + } + } + ] } } } @@ -2151,13 +2431,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a = 1 or t1.b > 10) and (t1.b < 14 or t1.a = 2 and t1.b > 15)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a = 1 or t1.b > 10) and (t1.b < 14 or t1.a = 2 and t1.b > 15)" + } + } + ] } } } @@ -2173,13 +2457,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a = 1 or t1.b > 10) and (t1.b < 14 or t1.a = 2 and t1.b > 15)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a = 1 or t1.b > 10) and (t1.b < 14 or t1.a = 2 and t1.b > 15)" + } + } + ] } } } @@ -2218,13 +2506,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a < 2 or t1.b = 13 and t1.a > 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a < 2 or t1.b = 13 and t1.a > 2" + } + } + ] } } } @@ -2240,13 +2532,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a < 2 or t1.b = 13 and t1.a > 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a < 2 or t1.b = 13 and t1.a > 2" + } + } + ] } } } @@ -2282,13 +2578,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.b = 14 and t1.a < 2 or t1.b = 13 and t1.a > 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.b = 14 and t1.a < 2 or t1.b = 13 and t1.a > 2" + } + } + ] } } } @@ -2304,13 +2604,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.b = 14 and t1.a < 2 or t1.b = 13 and t1.a > 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.b = 14 and t1.a < 2 or t1.b = 13 and t1.a > 2" + } + } + ] } } } @@ -2348,13 +2652,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.b = 14 and t1.a < 2 or t1.a > 2 and (t1.b = 13 or t1.b = 14)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.b = 14 and t1.a < 2 or t1.a > 2 and (t1.b = 13 or t1.b = 14)" + } + } + ] } } } @@ -2370,13 +2678,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.b = 14 and t1.a < 2 or t1.a > 2 and (t1.b = 13 or t1.b = 14)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.b = 14 and t1.a < 2 or t1.a > 2 and (t1.b = 13 or t1.b = 14)" + } + } + ] } } } @@ -2411,13 +2723,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a < 2 or t1.a = 1 or t1.a = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a < 2 or t1.a = 1 or t1.a = 2" + } + } + ] } } } @@ -2435,13 +2751,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a < 2 or t1.a = 1 or t1.a = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a < 2 or t1.a = 1 or t1.a = 2" + } + } + ] } } } @@ -2478,13 +2798,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 2 or t1.a = 1 or t1.a = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 2 or t1.a = 1 or t1.a = 2" + } + } + ] } } } @@ -2502,13 +2826,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 2 or t1.a = 1 or t1.a = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 2 or t1.a = 1 or t1.a = 2" + } + } + ] } } } @@ -2541,13 +2869,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "max(t1.c) = 3", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,t1.b,MAX(t1.c) @@ -2560,13 +2892,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "max(t1.c) = 3", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1" + } + } + ] } } # conjunctive subformula : equalities pushdown @@ -2597,13 +2933,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "max(t1.b = 14)", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c = 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c = 3" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,t1.b,MAX(t1.c) @@ -2616,13 +2956,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "max(t1.b) = 14", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c = 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c = 3" + } + } + ] } } # conjunctive subformula : multiple equality consists of @@ -2652,13 +2996,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "max(t1.b = 14)", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c = 1" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,t1.b,MAX(t1.c) @@ -2671,13 +3019,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "max(t1.b) = 14", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c = 1" + } + } + ] } } # @@ -2719,13 +3071,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.b > 2 and t1.a < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.b > 2 and t1.a < 3" + } + } + ] } } } @@ -2741,13 +3097,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.b > 2 and t1.a < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.b > 2 and t1.a < 3" + } + } + ] } } } @@ -2783,13 +3143,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 3 and t1.b > 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 3 and t1.b > 2" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,t1.b,MAX(t1.c) @@ -2800,13 +3164,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 3 and t1.b > 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 3 and t1.b > 2" + } + } + ] } } # inequality : equality in WHERE @@ -2843,13 +3211,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.b = 14 and t1.a < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.b = 14 and t1.a < 3" + } + } + ] } } } @@ -2865,13 +3237,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.b = 14 and t1.a < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.b = 14 and t1.a < 3" + } + } + ] } } } @@ -2907,13 +3283,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.b = 14" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.b = 14" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,t1.b,MAX(t1.c) @@ -2924,13 +3304,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.b = 14 and t1.a = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.b = 14 and t1.a = 1" + } + } + ] } } # equality : equality in WHERE, impossible WHERE @@ -3011,13 +3395,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c = 1" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,MAX(t1.b),t1.c @@ -3028,13 +3416,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c = 1 and t1.a = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c = 1 and t1.a = 1" + } + } + ] } } # inequality : AND formula in WHERE @@ -3073,13 +3465,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c > 0 and t1.c < 3 and t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c > 0 and t1.c < 3 and t1.a > 1" + } + } + ] } } } @@ -3095,13 +3491,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.c > 0 and t1.c < 3 and t1.a > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.c > 0 and t1.c < 3 and t1.a > 1" + } + } + ] } } } @@ -3137,13 +3537,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c > 0 and t1.c < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c > 0 and t1.c < 3" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,MAX(t1.b),t1.c @@ -3154,13 +3558,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c > 0 and t1.c < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c > 0 and t1.c < 3" + } + } + ] } } # equality : AND formula in WHERE, impossible WHERE @@ -3195,13 +3603,17 @@ EXPLAIN "query_block": { "select_id": 1, "const_condition": "1", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c < 3" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,MAX(t1.b),t1.c @@ -3212,13 +3624,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c < 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c < 3" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for SELECT t1.a,MAX(t1.b) @@ -3297,13 +3713,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t3.b = 2 and t3.d = 1 and t3.a = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t3.b = 2 and t3.d = 1 and t3.a = 1" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t3.a,t3.b,MAX(t3.c),t3.d @@ -3314,13 +3734,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t3.b = 2 and t3.d = 1 and t3.a = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t3.b = 2 and t3.d = 1 and t3.a = 1" + } + } + ] } } # inequality : OR formula in WHERE @@ -3357,13 +3781,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 2" + } + } + ] } } } @@ -3379,13 +3807,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 2" + } + } + ] } } } @@ -3472,13 +3904,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.a < 4 and t1.a > 0" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.a < 4 and t1.a > 0" + } + } + ] } } } @@ -3494,13 +3930,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.a < 4 and t1.a > 0" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.a < 4 and t1.a > 0" + } + } + ] } } } @@ -3537,13 +3977,17 @@ EXPLAIN "query_block": { "select_id": 1, "const_condition": "1 and 1", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,MAX(t1.b),t1.c @@ -3554,13 +3998,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1" + } + } + ] } } # OR formula : inequality in WHERE @@ -3599,13 +4047,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1 and (t1.a < 4 or t1.a > 0)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1 and (t1.a < 4 or t1.a > 0)" + } + } + ] } } } @@ -3621,13 +4073,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1 and (t1.a < 4 or t1.a > 0)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1 and (t1.a < 4 or t1.a > 0)" + } + } + ] } } } @@ -3664,13 +4120,17 @@ EXPLAIN "query_block": { "select_id": 1, "const_condition": "1", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,MAX(t1.b),t1.c @@ -3681,13 +4141,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1" + } + } + ] } } # AND formula : AND formula in WHERE @@ -3727,13 +4191,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.c < 3 and t1.a < 4" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.c < 3 and t1.a < 4" + } + } + ] } } } @@ -3752,13 +4220,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.c < 3 and t1.a < 4" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.c < 3 and t1.a < 4" + } + } + ] } } } @@ -3795,13 +4267,17 @@ EXPLAIN "filesort": { "sort_key": "t1.c", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c < 3 and t1.c > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c < 3 and t1.c > 1" + } + } + ] } } } @@ -3818,13 +4294,17 @@ EXPLAIN "filesort": { "sort_key": "t1.c", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c < 3 and t1.c > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c < 3 and t1.c > 1" + } + } + ] } } } @@ -3860,13 +4340,17 @@ EXPLAIN "query_block": { "select_id": 1, "const_condition": "1 and 1", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c = 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c = 3" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,MAX(t1.b),t1.c @@ -3878,13 +4362,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c = 3" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c = 3" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for SELECT t3.a,t3.b,MAX(t3.c),t3.d @@ -3918,13 +4406,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "t3.d > 0", - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t3.a = 1 and t3.d = 1 and t3.b = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t3.a = 1 and t3.d = 1 and t3.b = 2" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t3.a,t3.b,MAX(t3.c),t3.d @@ -3938,13 +4430,17 @@ EXPLAIN "query_block": { "select_id": 1, "having_condition": "t3.d > 0", - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t3.a = 1 and t3.d = 1 and t3.b = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t3.a = 1 and t3.d = 1 and t3.b = 2" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for SELECT t3.a,t3.b,MAX(t3.c),t3.d @@ -3978,13 +4474,17 @@ EXPLAIN "query_block": { "select_id": 1, "const_condition": "1", - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t3.a = 1 and t3.d = 1 and t3.b = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t3.a = 1 and t3.d = 1 and t3.b = 2" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t3.a,t3.b,MAX(t3.c),t3.d @@ -3996,13 +4496,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t3.a = 1 and t3.d = 1 and t3.b = 2" - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t3.a = 1 and t3.d = 1 and t3.b = 2" + } + } + ] } } # AND formula : OR formula in WHERE @@ -4042,13 +4546,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 4" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 4" + } + } + ] } } } @@ -4067,13 +4575,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 4" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 4" + } + } + ] } } } @@ -4115,13 +4627,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.c", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 4 and t1.c > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 4 and t1.c > 1" + } + } + ] } } } @@ -4138,13 +4654,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.c", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 4 and t1.c > 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a > 1 or t1.c < 3) and t1.a < 4 and t1.c > 1" + } + } + ] } } } @@ -4186,13 +4706,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.c", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a = 1 or t1.a = 3) and (t1.a = 4 or t1.c > 1)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a = 1 or t1.a = 3) and (t1.a = 4 or t1.c > 1)" + } + } + ] } } } @@ -4209,13 +4733,17 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.c", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a = 1 or t1.a = 3) and (t1.a = 4 or t1.c > 1)" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a = 1 or t1.a = 3) and (t1.a = 4 or t1.c > 1)" + } + } + ] } } } @@ -4251,13 +4779,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c = 1" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,MAX(t1.b),t1.c @@ -4268,13 +4800,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c = 1" + } + } + ] } } # OR formula : pushdown through equality @@ -4308,13 +4844,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c = 1" + } + } + ] } } set statement optimizer_switch='condition_pushdown_from_having=off' for explain format=json SELECT t1.a,MAX(t1.b),t1.c @@ -4326,13 +4866,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.c = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.c = 1" + } + } + ] } } # OR formula : pushdown through equality, impossible WHERE @@ -4510,13 +5054,17 @@ EXPLAIN "filesort": { "sort_key": "t3.a", "temporary_table": { - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t3.d = t3.a and t3.a > 1 and (t3.c = 3 or t3.c < 2) and (t3.a = 1 or t3.a > 1)" - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t3.d = t3.a and t3.a > 1 and (t3.c = 3 or t3.c < 2) and (t3.a = 1 or t3.a > 1)" + } + } + ] } } } @@ -4533,13 +5081,17 @@ EXPLAIN "filesort": { "sort_key": "t3.a", "temporary_table": { - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t3.d = t3.a and t3.a > 1 and (t3.c = 3 or t3.c < 2) and (t3.a = 1 or t3.a > 1)" - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t3.d = t3.a and t3.a > 1 and (t3.c = 3 or t3.c < 2) and (t3.a = 1 or t3.a > 1)" + } + } + ] } } } @@ -4576,13 +5128,17 @@ EXPLAIN "filesort": { "sort_key": "t3.a", "temporary_table": { - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t3.d = t3.a and t3.a > 1 and (t3.c = 3 or t3.c < 2) and (t3.c = t3.a and t3.c < 15 or t3.a > 1)" - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t3.d = t3.a and t3.a > 1 and (t3.c = 3 or t3.c < 2) and (t3.c = t3.a and t3.c < 15 or t3.a > 1)" + } + } + ] } } } @@ -4599,13 +5155,17 @@ EXPLAIN "filesort": { "sort_key": "t3.a", "temporary_table": { - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t3.d = t3.a and t3.a > 1 and (t3.c = 3 or t3.c < 2) and (t3.c = t3.a and t3.a < 15 or t3.a > 1)" - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t3.d = t3.a and t3.a > 1 and (t3.c = 3 or t3.c < 2) and (t3.c = t3.a and t3.a < 15 or t3.a > 1)" + } + } + ] } } } @@ -4683,13 +5243,17 @@ EXPLAIN "filesort": { "sort_key": "t1.d1", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 4, - "filtered": 100, - "attached_condition": "t1.d1 between <cache>(inet_aton('1978-04-27')) and <cache>('2018-08-26')" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 4, + "filtered": 100, + "attached_condition": "t1.d1 between <cache>(inet_aton('1978-04-27')) and <cache>('2018-08-26')" + } + } + ] } } } @@ -4721,13 +5285,17 @@ EXPLAIN "filesort": { "sort_key": "t1.d1", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "t1.d1 not between <cache>(0) and <cache>(exp(0))" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.d1 not between <cache>(0) and <cache>(exp(0))" + } + } + ] } } } @@ -4792,23 +5360,31 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 7, - "filtered": 100, - "attached_condition": "t1.a = 8 or t1.a = (subquery#2)" - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t1.a = 8 or t1.a = (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 + } + } + ] } } ] @@ -4828,23 +5404,31 @@ EXPLAIN "filesort": { "sort_key": "t1.a, t1.b", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 7, - "filtered": 100, - "attached_condition": "(t1.a = 8 or t1.a = (subquery#2)) and t1.b < 20" - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "(t1.a = 8 or t1.a = (subquery#2)) and t1.b < 20" + } + } + ], "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 + } + } + ] } } ] @@ -4865,23 +5449,31 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 7, - "filtered": 100, - "attached_condition": "t1.a = 8 or t1.a = (subquery#2)" - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t1.a = 8 or t1.a = (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 + } + } + ] } } ] @@ -4898,23 +5490,31 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 7, - "filtered": 100, - "attached_condition": "t1.a = (subquery#2)" - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t1.a = (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 + } + } + ] } } ] diff --git a/mysql-test/main/in_subq_cond_pushdown.result b/mysql-test/main/in_subq_cond_pushdown.result index eef320d2d04..f114fc6824e 100644 --- a/mysql-test/main/in_subq_cond_pushdown.result +++ b/mysql-test/main/in_subq_cond_pushdown.result @@ -51,40 +51,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.c < 25 and t1.a is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "`MAX(t2.g)` < 25", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.c < 25 and t1.a is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "`MAX(t2.g)` < 25", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5" + } + } + ] + } } } } } - } + ] } } # extracted AND formula : pushing into HAVING @@ -140,40 +150,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.c > 55 and t1.b < 4 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "f", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "`MAX(t2.g)` > 55 and t2.f < 4", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.c > 55 and t1.b < 4 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "f", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "`MAX(t2.g)` > 55 and t2.f < 4", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5" + } + } + ] + } } } } } - } + ] } } # extracted OR formula : pushing into HAVING @@ -231,40 +251,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "(t1.c > 60 or t1.c < 25) and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "f", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "`MAX(t2.g)` > 60 or `MAX(t2.g)` < 25", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "(t1.c > 60 or t1.c < 25) and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "f", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "`MAX(t2.g)` > 60 or `MAX(t2.g)` < 25", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5" + } + } + ] + } } } } } - } + ] } } # extracted AND-OR formula : pushing into HAVING @@ -320,40 +350,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "(t1.c > 60 or t1.c < 25) and t1.b > 2 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "f", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "(`MAX(t2.g)` > 60 or `MAX(t2.g)` < 25) and t2.f > 2", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "(t1.c > 60 or t1.c < 25) and t1.b > 2 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "f", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "(`MAX(t2.g)` > 60 or `MAX(t2.g)` < 25) and t2.f > 2", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula : pushing into HAVING @@ -411,40 +451,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "(t1.a < 2 or t1.d > 3) and t1.b > 1 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "f", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "t2.f > 1", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "(t1.a < 2 or t1.d > 3) and t1.b > 1 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "f", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "t2.f > 1", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5" + } + } + ] + } } } } } - } + ] } } # using view IN subquery defINition : pushing into HAVING @@ -500,40 +550,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.c > 20 and t1.a is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["v1_x", "MAX(v1_y)"], - "ref": ["test.t1.a", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "`MAX(v1_y)` > 20", - "temporary_table": { - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 8, - "filtered": 100, - "attached_condition": "t3.x > 1 and t3.x <= 3" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.c > 20 and t1.a is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["v1_x", "MAX(v1_y)"], + "ref": ["test.t1.a", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "`MAX(v1_y)` > 20", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 8, + "filtered": 100, + "attached_condition": "t3.x > 1 and t3.x <= 3" + } + } + ] + } } } } } - } + ] } } # using equality : pushing into WHERE @@ -590,52 +650,64 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 8, - "filtered": 100, - "attached_condition": "t3.y > 20 and t3.x <= 3 and t3.y is not null" - }, - "block-nl-join": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 8, + "filtered": 100, + "attached_condition": "t3.y > 20 and t3.x <= 3 and t3.y is not null" + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "attached_condition": "t1.c = t3.y and t1.a is not null" + } }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL", - "attached_condition": "t1.c = t3.y and t1.a is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t3.y"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "`MAX(t2.g)` > 20", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5" + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t3.y"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "`MAX(t2.g)` > 20", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE @@ -693,39 +765,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a < 2 and t1.a is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.e < 2" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a < 2 and t1.a is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.e < 2" + } + } + ] + } } } } } - } + ] } } # extracted AND formula : pushing into WHERE @@ -783,39 +865,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a > 2 and t1.a < 5 and t1.a is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.e > 2 and t2.e < 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a > 2 and t1.a < 5 and t1.a is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.e > 2 and t2.e < 5" + } + } + ] + } } } } } - } + ] } } # extracted OR formula : pushing into WHERE @@ -875,39 +967,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "(t1.a < 2 or t1.a >= 4) and t1.a is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and (t2.e < 2 or t2.e >= 4)" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "(t1.a < 2 or t1.a >= 4) and t1.a is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and (t2.e < 2 or t2.e >= 4)" + } + } + ] + } } } } } - } + ] } } # extracted AND-OR formula : pushing into WHERE @@ -963,39 +1065,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "(t1.a < 2 or t1.a = 5) and t1.b > 3 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "f", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and (t2.e < 2 or t2.e = 5) and t2.f > 3" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "(t1.a < 2 or t1.a = 5) and t1.b > 3 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "f", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and (t2.e < 2 or t2.e = 5) and t2.f > 3" + } + } + ] + } } } } } - } + ] } } # extracted AND-OR formula : pushing into WHERE @@ -1051,39 +1163,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "(t1.a < 2 or t1.a = 5) and t1.b > 3 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "f", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and (t2.e < 2 or t2.e = 5) and t2.f > 3" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "(t1.a < 2 or t1.a = 5) and t1.b > 3 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "f", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and (t2.e < 2 or t2.e = 5) and t2.f > 3" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE @@ -1139,39 +1261,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "(t1.b < 3 or t1.d > 2) and t1.a < 2 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "f", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.e < 2" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "(t1.b < 3 or t1.d > 2) and t1.a < 2 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "f", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.e < 2" + } + } + ] + } } } } } - } + ] } } # using equalities : pushing into WHERE @@ -1227,37 +1359,47 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a = 1 and t1.d = 1 and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "MAX(t2.g)"], - "ref": ["const", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e = 1" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a = 1 and t1.d = 1 and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "MAX(t2.g)"], + "ref": ["const", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e = 1" + } + } + ] + } } } } - } + ] } } # using equality : pushing into WHERE @@ -1313,39 +1455,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.d = t1.a and t1.a > 1 and t1.a is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.e > 1" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.d = t1.a and t1.a > 1 and t1.a is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.e > 1" + } + } + ] + } } } } } - } + ] } } # using view IN subquery definition : pushing into WHERE @@ -1399,39 +1551,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a < 3 and t1.a is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["v1_x", "MAX(v1_y)"], - "ref": ["test.t1.a", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 8, - "filtered": 100, - "attached_condition": "t3.x > 1 and t3.x <= 3 and t3.x < 3" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a < 3 and t1.a is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["v1_x", "MAX(v1_y)"], + "ref": ["test.t1.a", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 8, + "filtered": 100, + "attached_condition": "t3.x > 1 and t3.x <= 3 and t3.x < 3" + } + } + ] + } } } } } - } + ] } } # using equality : pushing into WHERE @@ -1490,51 +1652,63 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 8, - "filtered": 100, - "attached_condition": "t3.x < 2 and t3.y > 30 and t3.x <= 3 and t3.x is not null" - }, - "block-nl-join": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 8, + "filtered": 100, + "attached_condition": "t3.x < 2 and t3.y > 30 and t3.x <= 3 and t3.x is not null" + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "119", + "join_type": "BNL", + "attached_condition": "t1.a = t3.x and t1.c is not null" + } }, - "buffer_type": "flat", - "buffer_size": "119", - "join_type": "BNL", - "attached_condition": "t1.a = t3.x and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "MAX(t2.g)"], - "ref": ["test.t3.x", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.e <= 3" + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "MAX(t2.g)"], + "ref": ["test.t3.x", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.e <= 3" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE @@ -1591,40 +1765,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "(t1.b < 3 or t1.b = 4) and t1.a < 3 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "f", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "t2.f < 3 or t2.f = 4", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.e < 3" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "(t1.b < 3 or t1.b = 4) and t1.a < 3 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "f", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "t2.f < 3 or t2.f = 4", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.e < 3" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula using addition : pushing into HAVING @@ -1680,40 +1864,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a + t1.c > 41 and t1.a is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "t2.e + `MAX(t2.g)` > 41", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a + t1.c > 41 and t1.a is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "t2.e + `MAX(t2.g)` > 41", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula using substitution : pushing into HAVING @@ -1771,40 +1965,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.c - t1.a < 35 and t1.a is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "`MAX(t2.g)` - t2.e < 35", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.c - t1.a < 35 and t1.a is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "`MAX(t2.g)` - t2.e < 35", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula using multiplication : pushing into HAVING @@ -1860,40 +2064,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.c * t1.a > 100 and t1.a is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "`MAX(t2.g)` * t2.e > 100", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.c * t1.a > 100 and t1.a is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "`MAX(t2.g)` * t2.e > 100", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula using division : pushing into HAVING @@ -1953,40 +2167,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.c / t1.a > 30 and t1.a is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "`MAX(t2.g)` / t2.e > 30", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.c / t1.a > 30 and t1.a is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "`MAX(t2.g)` / t2.e > 30", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula using BETWEEN : pushing into HAVING @@ -2042,40 +2266,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.c between 50 and 100 and t1.a is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "`MAX(t2.g)` between 50 and 100", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.c between 50 and 100 and t1.a is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "`MAX(t2.g)` between 50 and 100", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula using addition : pushing into WHERE @@ -2131,39 +2365,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a + t1.b > 5 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "f", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.e + t2.f > 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a + t1.b > 5 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "f", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.e + t2.f > 5" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula using substitution : pushing into WHERE @@ -2219,39 +2463,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a - t1.b > 0 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "f", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.e - t2.f > 0" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a - t1.b > 0 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "f", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.e - t2.f > 0" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula using multiplication : pushing into WHERE @@ -2307,39 +2561,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a * t1.b > 6 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "f", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.e * t2.f > 6" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a * t1.b > 6 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "f", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.e * t2.f > 6" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula using division : pushing into WHERE @@ -2397,39 +2661,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.b / t1.a > 2 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "f", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.f / t2.e > 2" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.b / t1.a > 2 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "f", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.f / t2.e > 2" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula using BETWEEN : pushing into WHERE @@ -2491,39 +2765,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a between 1 and 3 and t1.a is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["e", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.e between 1 and 3" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a between 1 and 3 and t1.a is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.e between 1 and 3" + } + } + ] + } } } } } - } + ] } } # conjunctive subformula : pushing into HAVING of the IN subquery @@ -2583,58 +2867,72 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.c > 3 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "MAX(v2.f)", "max_g"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "v2.max_g > 3", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "v2.e < 5", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_g > 25", - "filesort": { - "sort_key": "t2.e", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.c > 3 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "MAX(v2.f)", "max_g"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "v2.max_g > 3", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "v2.e < 5", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_g > 25", + "filesort": { + "sort_key": "t2.e", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5" + } + } + ] + } + } + } } } } - } + ] } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE of the IN subquery @@ -2693,57 +2991,71 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "MAX(v2.f)", "max_g"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "v2.e < 5 and v2.e > 1", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_g > 25", - "filesort": { - "sort_key": "t2.e", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.e > 1" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "MAX(v2.f)", "max_g"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "v2.e < 5 and v2.e > 1", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_g > 25", + "filesort": { + "sort_key": "t2.e", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.e > 1" + } + } + ] + } + } + } } } } - } + ] } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE and HAVING @@ -2803,58 +3115,72 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.c < 100 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "MAX(v2.f)", "max_g"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "having_condition": "v2.max_g < 100", - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "v2.e < 5 and v2.e > 1", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_g > 25", - "filesort": { - "sort_key": "t2.e", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.e > 1" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.c < 100 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "MAX(v2.f)", "max_g"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "v2.max_g < 100", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "v2.e < 5 and v2.e > 1", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_g > 25", + "filesort": { + "sort_key": "t2.e", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.e > 1" + } + } + ] + } + } + } } } } - } + ] } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE of the IN subquery @@ -2937,56 +3263,70 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "MAX(d_tab.f)", "max_g"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "d_tab.e < 5 and d_tab.e > 1", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_g > 25 and t2.e < 5 and t2.e > 1", - "filesort": { - "sort_key": "t2.f", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "MAX(d_tab.f)", "max_g"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "d_tab.e < 5 and d_tab.e > 1", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_g > 25 and t2.e < 5 and t2.e > 1", + "filesort": { + "sort_key": "t2.f", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100 + } + } + ] + } + } + } } } } - } + ] } } } } } - } + ] } } # conjunctive subformula : pushing into HAVING of the derived table @@ -3088,56 +3428,70 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "MAX(d_tab.f)", "max_g"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "d_tab.e < 5 and d_tab.e > 1", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_g > 25 and t2.e < 5 and t2.e > 1", - "filesort": { - "sort_key": "t2.f", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "MAX(d_tab.f)", "max_g"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "d_tab.e < 5 and d_tab.e > 1", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_g > 25 and t2.e < 5 and t2.e > 1", + "filesort": { + "sort_key": "t2.f", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100 + } + } + ] + } + } + } } } } - } + ] } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE of the derived table @@ -3240,56 +3594,70 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "MAX(d_tab.f)", "max_g"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "temporary_table": { - "table": { - "table_name": "<derived3>", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "d_tab.e < 5 and d_tab.e > 1", - "materialized": { - "query_block": { - "select_id": 3, - "having_condition": "max_g > 25 and t2.e < 5 and t2.e > 1", - "filesort": { - "sort_key": "t2.f", - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "MAX(d_tab.f)", "max_g"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "d_tab.e < 5 and d_tab.e > 1", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_g > 25 and t2.e < 5 and t2.e > 1", + "filesort": { + "sort_key": "t2.f", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100 + } + } + ] + } + } + } } } } - } + ] } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE and HAVING @@ -3374,70 +3742,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 8, - "filtered": 100, - "attached_condition": "t3.x < 5 and t3.x is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t3.x"], - "rows": 2, - "filtered": 100, - "attached_condition": "d_tab.max_c < 70", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 70", - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.a < 5 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery3>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "f", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 3, - "having_condition": "t2.f < 5", - "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 8, + "filtered": 100, + "attached_condition": "t3.x < 5 and t3.x is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t3.x"], + "rows": 2, + "filtered": 100, + "attached_condition": "d_tab.max_c < 70", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 70", + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { "table": { - "table_name": "t2", + "table_name": "t1", "access_type": "ALL", - "rows": 12, + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.a < 5 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery3>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "f", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, "filtered": 100, - "attached_condition": "t2.e > 1 and t2.e < 5" + "materialized": { + "unique": 1, + "query_block": { + "select_id": 3, + "having_condition": "t2.f < 5", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e > 1 and t2.e < 5" + } + } + ] + } + } + } } } - } + ] } } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE of the derived table @@ -3543,70 +3927,86 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 8, - "filtered": 100, - "attached_condition": "t3.x < 5 and t3.x is not null" - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t3.x"], - "rows": 2, - "filtered": 100, - "attached_condition": "d_tab.max_c < 70", - "materialized": { - "query_block": { - "select_id": 2, - "having_condition": "max_c < 70", - "filesort": { - "sort_key": "t1.a", - "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.a > 1 and t1.a < 5 and t1.a is not null and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery3>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["e", "f", "MAX(t2.g)"], - "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 3, - "having_condition": "t2.f < 5", - "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 8, + "filtered": 100, + "attached_condition": "t3.x < 5 and t3.x is not null" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t3.x"], + "rows": 2, + "filtered": 100, + "attached_condition": "d_tab.max_c < 70", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "max_c < 70", + "filesort": { + "sort_key": "t1.a", + "temporary_table": { + "nested_loop": [ + { "table": { - "table_name": "t2", + "table_name": "t1", "access_type": "ALL", - "rows": 12, + "rows": 16, + "filtered": 100, + "attached_condition": "t1.a > 1 and t1.a < 5 and t1.a is not null and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery3>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": ["e", "f", "MAX(t2.g)"], + "ref": ["test.t1.a", "test.t1.b", "test.t1.c"], + "rows": 1, "filtered": 100, - "attached_condition": "t2.e > 1 and t2.e < 5" + "materialized": { + "unique": 1, + "query_block": { + "select_id": 3, + "having_condition": "t2.f < 5", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e > 1 and t2.e < 5" + } + } + ] + } + } + } } } - } + ] } } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE @@ -3665,46 +4065,58 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.b > 1 and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "8", - "used_key_parts": ["f", "MAX(t2.g) OVER (PARTITION BY t2.f)"], - "ref": ["test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t2.f" - } - }, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.f > 1" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.b > 1 and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["f", "MAX(t2.g) OVER (PARTITION BY t2.f)"], + "ref": ["test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "window_functions_computation": { + "sorts": [ + { + "filesort": { + "sort_key": "t2.f" + } + } + ], + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.f > 1" + } + } + ] + } } } } } } - } + ] } } # conjunctive subformula : pushing into WHERE @@ -3757,47 +4169,62 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 16, - "filtered": 100, - "attached_condition": "t1.b > 1 and t1.b is not null and t1.c is not null" - }, - "table": { - "table_name": "<subquery2>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "12", - "used_key_parts": ["f", "CAST(SUM(t2.g) OVER (PARTITION BY t2.f) AS INT)"], - "ref": ["test.t1.b", "test.t1.c"], - "rows": 1, - "filtered": 100, - "attached_condition": "t1.c = `<subquery2>`.`CAST(SUM(t2.g) OVER (PARTITION BY t2.f) AS INT)`", - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t2.f" - } - }, - "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 12, - "filtered": 100, - "attached_condition": "t2.e < 5 and t2.f > 1" + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 16, + "filtered": 100, + "attached_condition": "t1.b > 1 and t1.b is not null and t1.c is not null" + } + }, + { + "table": { + "table_name": "<subquery2>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "12", + "used_key_parts": [ + "f", + "CAST(SUM(t2.g) OVER (PARTITION BY t2.f) AS INT)" + ], + "ref": ["test.t1.b", "test.t1.c"], + "rows": 1, + "filtered": 100, + "attached_condition": "t1.c = `<subquery2>`.`CAST(SUM(t2.g) OVER (PARTITION BY t2.f) AS INT)`", + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "window_functions_computation": { + "sorts": [ + { + "filesort": { + "sort_key": "t2.f" + } + } + ], + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 12, + "filtered": 100, + "attached_condition": "t2.e < 5 and t2.f > 1" + } + } + ] + } } } } } } - } + ] } } DROP TABLE t1,t2,t3; diff --git a/mysql-test/main/innodb_ext_key,off.rdiff b/mysql-test/main/innodb_ext_key,off.rdiff index 4d6c65c9971..b334d006737 100644 --- a/mysql-test/main/innodb_ext_key,off.rdiff +++ b/mysql-test/main/innodb_ext_key,off.rdiff @@ -265,30 +265,30 @@ drop table t0,t1,t2; # # MDEV-11196: Error:Run-Time Check Failure #2 - Stack around the variable 'key_buff' -@@ -755,11 +755,12 @@ - "select_id": 1, - "table": { - "table_name": "t1", -- "access_type": "range", -+ "access_type": "ref", - "possible_keys": ["f2"], - "key": "f2", -- "key_length": "3070", -- "used_key_parts": ["f2", "pk1"], -+ "key_length": "3066", -+ "used_key_parts": ["f2"], -+ "ref": ["const"], - "rows": 1, - "filtered": 100, - "index_condition": "t1.pk1 <= 5 and t1.pk2 <= 5 and t1.f2 = 'abc'", -@@ -788,8 +789,8 @@ - "access_type": "range", - "possible_keys": ["k1"], - "key": "k1", -- "key_length": "3011", -- "used_key_parts": ["pk1", "f2", "pk2"], -+ "key_length": "3007", -+ "used_key_parts": ["pk1", "f2"], - "rows": 1, - "filtered": 100, - "index_condition": "t1.f2 <= 5 and t1.pk2 <= 5 and t1.pk1 = 'abc'", +@@ -768,11 +768,12 @@ + { + "table": { + "table_name": "t1", +- "access_type": "range", ++ "access_type": "ref", + "possible_keys": ["f2"], + "key": "f2", +- "key_length": "3070", +- "used_key_parts": ["f2", "pk1"], ++ "key_length": "3066", ++ "used_key_parts": ["f2"], ++ "ref": ["const"], + "rows": 1, + "filtered": 100, + "index_condition": "t1.pk1 <= 5 and t1.pk2 <= 5 and t1.f2 = 'abc'", +@@ -805,8 +806,8 @@ + "access_type": "range", + "possible_keys": ["k1"], + "key": "k1", +- "key_length": "3011", +- "used_key_parts": ["pk1", "f2", "pk2"], ++ "key_length": "3007", ++ "used_key_parts": ["pk1", "f2"], + "rows": 1, + "filtered": 100, + "index_condition": "t1.f2 <= 5 and t1.pk2 <= 5 and t1.pk1 = 'abc'", diff --git a/mysql-test/main/innodb_ext_key.result b/mysql-test/main/innodb_ext_key.result index 5b99fa4e30b..3025e3ec3f0 100644 --- a/mysql-test/main/innodb_ext_key.result +++ b/mysql-test/main/innodb_ext_key.result @@ -764,18 +764,22 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["f2"], - "key": "f2", - "key_length": "3070", - "used_key_parts": ["f2", "pk1"], - "rows": 1, - "filtered": 100, - "index_condition": "t1.pk1 <= 5 and t1.pk2 <= 5 and t1.f2 = 'abc'", - "attached_condition": "t1.f1 <= '3'" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["f2"], + "key": "f2", + "key_length": "3070", + "used_key_parts": ["f2", "pk1"], + "rows": 1, + "filtered": 100, + "index_condition": "t1.pk1 <= 5 and t1.pk2 <= 5 and t1.f2 = 'abc'", + "attached_condition": "t1.f1 <= '3'" + } + } + ] } } drop table t1; @@ -794,18 +798,22 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["k1"], - "key": "k1", - "key_length": "3011", - "used_key_parts": ["pk1", "f2", "pk2"], - "rows": 1, - "filtered": 100, - "index_condition": "t1.f2 <= 5 and t1.pk2 <= 5 and t1.pk1 = 'abc'", - "attached_condition": "t1.f1 <= '3'" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["k1"], + "key": "k1", + "key_length": "3011", + "used_key_parts": ["pk1", "f2", "pk2"], + "rows": 1, + "filtered": 100, + "index_condition": "t1.f2 <= 5 and t1.pk2 <= 5 and t1.pk1 = 'abc'", + "attached_condition": "t1.f1 <= '3'" + } + } + ] } } drop table t1; diff --git a/mysql-test/main/intersect.result b/mysql-test/main/intersect.result index 3a194b60008..c7858b49cd4 100644 --- a/mysql-test/main/intersect.result +++ b/mysql-test/main/intersect.result @@ -51,36 +51,48 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] } }, { "query_block": { "select_id": 2, "operation": "INTERSECT", - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] } }, { "query_block": { "select_id": 3, "operation": "INTERSECT", - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] } } ] @@ -102,17 +114,21 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } }, { @@ -121,17 +137,21 @@ ANALYZE "operation": "INTERSECT", "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } }, { @@ -140,17 +160,21 @@ ANALYZE "operation": "INTERSECT", "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } } ] @@ -164,85 +188,101 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3,4>", - "access_type": "ALL", - "r_loops": 1, - "r_rows": 1, - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } - } - }, - { - "query_block": { - "select_id": 4, - "operation": "INTERSECT", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3,4>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 1, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } + }, + { + "query_block": { + "select_id": 4, + "operation": "INTERSECT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } select * from ((select a,b from t1) intersect (select c,d from t2) intersect (select e,f from t3)) a; @@ -300,35 +340,45 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] } }, { "query_block": { "select_id": 2, "operation": "INTERSECT", - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 3, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "256Kb", - "join_type": "BNL" - } + { + "block-nl-join": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "256Kb", + "join_type": "BNL" + } + } + ] } } ] @@ -350,17 +400,21 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } }, { @@ -369,91 +423,24 @@ ANALYZE "operation": "INTERSECT", "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "256Kb", - "join_type": "BNL", - "r_filtered": 100 - } - } - } - ] - } - } -} -ANALYZE format=json select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a; -ANALYZE -{ - "query_block": { - "select_id": 1, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3>", - "access_type": "ALL", - "r_loops": 1, - "r_rows": 1, - "query_specifications": [ + "nested_loop": [ { - "query_block": { - "select_id": 2, + "table": { + "table_name": "t2", + "access_type": "ALL", "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 } }, { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "r_loops": 1, - "r_total_time_ms": "REPLACED", + "block-nl-join": { "table": { - "table_name": "t2", + "table_name": "t3", "access_type": "ALL", "r_loops": 1, "rows": 3, @@ -463,32 +450,119 @@ ANALYZE "filtered": 100, "r_filtered": 100 }, - "block-nl-join": { - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "256Kb", - "join_type": "BNL", - "r_filtered": 100 - } + "buffer_type": "flat", + "buffer_size": "256Kb", + "join_type": "BNL", + "r_filtered": 100 } } ] } } - } + ] } } } +ANALYZE format=json select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 1, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "256Kb", + "join_type": "BNL", + "r_filtered": 100 + } + } + ] + } + } + ] + } + } + } + } + } + ] + } +} set @@optimizer_switch=@save_optimizer_switch; select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a; a b diff --git a/mysql-test/main/intersect_all.result b/mysql-test/main/intersect_all.result index 96bfb9ca1fb..6c7a9c1cdd2 100644 --- a/mysql-test/main/intersect_all.result +++ b/mysql-test/main/intersect_all.result @@ -63,36 +63,48 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 4, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 4, + "filtered": 100 + } + } + ] } }, { "query_block": { "select_id": 2, "operation": "INTERSECT", - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 4, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 4, + "filtered": 100 + } + } + ] } }, { "query_block": { "select_id": 3, "operation": "INTERSECT", - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 4, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 4, + "filtered": 100 + } + } + ] } } ] @@ -114,17 +126,21 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 4, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } }, { @@ -133,17 +149,21 @@ ANALYZE "operation": "INTERSECT", "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 1, - "rows": 4, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } }, { @@ -152,17 +172,21 @@ ANALYZE "operation": "INTERSECT", "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 4, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } } ] @@ -176,85 +200,101 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "r_loops": 1, - "rows": 4, - "r_rows": 2, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3,4>", - "access_type": "ALL", - "r_loops": 1, - "r_rows": 2, - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 4, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 1, - "rows": 4, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } - } - }, - { - "query_block": { - "select_id": 4, - "operation": "INTERSECT", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 4, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3,4>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 2, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } + }, + { + "query_block": { + "select_id": 4, + "operation": "INTERSECT", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } select * from ((select a,b from t1) intersect all (select c,d from t2) intersect all (select e,f from t3)) a; @@ -331,35 +371,45 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 6, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + } + } + ] } }, { "query_block": { "select_id": 2, "operation": "INTERSECT", - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 5, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 7, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "65", - "join_type": "BNL" - } + { + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 7, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL" + } + } + ] } } ] @@ -381,17 +431,21 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 6, - "r_rows": 6, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 6, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } }, { @@ -400,34 +454,40 @@ ANALYZE "operation": "INTERSECT", "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 5, - "r_rows": 5, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 1, - "rows": 7, - "r_rows": 7, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 5, + "r_rows": 5, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "65", - "join_type": "BNL", - "r_filtered": 100 - } + { + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL", + "r_filtered": 100 + } + } + ] } } ] @@ -441,83 +501,97 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "r_loops": 1, - "rows": 6, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3>", - "access_type": "ALL", - "r_loops": 1, - "r_rows": 3, - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 6, - "r_rows": 6, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 5, - "r_rows": 5, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "r_loops": 1, + "rows": 6, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3>", + "access_type": "ALL", + "r_loops": 1, + "r_rows": 3, + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 6, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] + } }, - "block-nl-join": { - "table": { - "table_name": "t2", - "access_type": "ALL", + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", "r_loops": 1, - "rows": 7, - "r_rows": 7, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "65", - "join_type": "BNL", - "r_filtered": 100 + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 5, + "r_rows": 5, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL", + "r_filtered": 100 + } + } + ] + } } - } + ] } - ] + } } } } - } + ] } } select * from ((select a,b from t1) intersect all (select c,e from t2,t3)) a; diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result index 3ab6c1cf310..10ed8960b64 100644 --- a/mysql-test/main/join_cache.result +++ b/mysql-test/main/join_cache.result @@ -6195,36 +6195,42 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "a", - "access_type": "range", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["a"], - "rows": 10, - "filtered": 100, - "attached_condition": "a.a <= 10", - "using_index": true - }, - "block-nl-join": { - "table": { - "table_name": "b", - "access_type": "range", - "possible_keys": ["kp1"], - "key": "kp1", - "key_length": "10", - "used_key_parts": ["kp1", "kp2"], - "rows": 836, - "filtered": 76.43428802, - "index_condition": "b.kp2 <= 10", - "attached_condition": "b.kp2 <= 10 and b.col1 + 1 < 33333" + "nested_loop": [ + { + "table": { + "table_name": "a", + "access_type": "range", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["a"], + "rows": 10, + "filtered": 100, + "attached_condition": "a.a <= 10", + "using_index": true + } }, - "buffer_type": "flat", - "buffer_size": "54", - "join_type": "BNL", - "attached_condition": "b.kp1 = a.a" - } + { + "block-nl-join": { + "table": { + "table_name": "b", + "access_type": "range", + "possible_keys": ["kp1"], + "key": "kp1", + "key_length": "10", + "used_key_parts": ["kp1", "kp2"], + "rows": 836, + "filtered": 76, + "index_condition": "b.kp2 <= 10", + "attached_condition": "b.kp2 <= 10 and b.col1 + 1 < 33333" + }, + "buffer_type": "flat", + "buffer_size": "54", + "join_type": "BNL", + "attached_condition": "b.kp1 = a.a" + } + } + ] } } drop table t1,t2,t3; diff --git a/mysql-test/main/join_outer.result b/mysql-test/main/join_outer.result index 6bcaee31e54..fde7689b142 100644 --- a/mysql-test/main/join_outer.result +++ b/mysql-test/main/join_outer.result @@ -2796,7 +2796,7 @@ test.t3 analyze status OK explain extended select * from t1 left join t3 on t1.a=t3.b and t3.a<5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 -1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 1.96 Using where +1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 0.50 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` left join `test`.`t3` on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5) where 1 # t3.filtered must less than 100%, too: @@ -2804,7 +2804,7 @@ explain extended select * from t1 left join (t3 join t2) on t1.a=t3.b and t3.a<5 id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 -1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 1.96 Using where +1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 0.50 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5) where 1 drop table t1,t2,t3; diff --git a/mysql-test/main/join_outer_jcl6.result b/mysql-test/main/join_outer_jcl6.result index 3d73ebdc9ba..cd13a4c48a6 100644 --- a/mysql-test/main/join_outer_jcl6.result +++ b/mysql-test/main/join_outer_jcl6.result @@ -2803,7 +2803,7 @@ test.t3 analyze status OK explain extended select * from t1 left join t3 on t1.a=t3.b and t3.a<5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 -1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 1.96 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 0.50 Using where; Using join buffer (flat, BNLH join) Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` left join `test`.`t3` on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5 and `test`.`t1`.`a` is not null) where 1 # t3.filtered must less than 100%, too: @@ -2811,7 +2811,7 @@ explain extended select * from t1 left join (t3 join t2) on t1.a=t3.b and t3.a<5 id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 1.96 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 0.50 Using where; Using join buffer (incremental, BNLH join) Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5 and `test`.`t1`.`a` is not null) where 1 drop table t1,t2,t3; diff --git a/mysql-test/main/key.result b/mysql-test/main/key.result index e94a7309964..2e2c8d894f0 100644 --- a/mysql-test/main/key.result +++ b/mysql-test/main/key.result @@ -1,4 +1,3 @@ -drop table if exists t1,t2,t3; SET SQL_WARNINGS=1; CREATE TABLE t1 ( ID CHAR(32) NOT NULL, @@ -685,3 +684,8 @@ c c 9 10 10 11 drop table t1,t2; +# +# MDEV-13756 Implement descending index: KEY (a DESC, b ASC) +# +create table t1 (a int, b int, key(a), key(a desc)); +drop table t1; diff --git a/mysql-test/main/key.test b/mysql-test/main/key.test index fe7a5f48e2d..29e08b8834a 100644 --- a/mysql-test/main/key.test +++ b/mysql-test/main/key.test @@ -1,6 +1,3 @@ ---disable_warnings -drop table if exists t1,t2,t3; ---enable_warnings --source include/have_sequence.inc SET SQL_WARNINGS=1; @@ -605,3 +602,9 @@ EXPLAIN SELECT t1.c, t2.c FROM t1, t2 WHERE t1.b=t2.a and t1.c=t2.b; SELECT t1.c, t2.c FROM t1, t2 WHERE t1.b=t2.a and t1.c=t2.b; drop table t1,t2; + +--echo # +--echo # MDEV-13756 Implement descending index: KEY (a DESC, b ASC) +--echo # +create table t1 (a int, b int, key(a), key(a desc)); +drop table t1; diff --git a/mysql-test/main/merge.result b/mysql-test/main/merge.result index 1e671e2504f..230fcf48e9d 100644 --- a/mysql-test/main/merge.result +++ b/mysql-test/main/merge.result @@ -1,8 +1,6 @@ set @save_default_storage_engine=@@global.default_storage_engine; set global default_storage_engine=myisam; set session default_storage_engine=myisam; -drop table if exists t1,t2,t3,t4,t5,t6; -drop database if exists mysqltest; create table t1 (a int not null primary key auto_increment, message char(20)); create table t2 (a int not null primary key auto_increment, message char(20)); INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1"); @@ -2266,7 +2264,6 @@ DROP TABLE t1; # Bug45781 infinite hang/crash in "opening tables" after handler tries to # open merge table # -DROP TABLE IF EXISTS m1,t1; CREATE TABLE t1(a int)engine=myisam; CREATE TABLE t2(a int)engine=myisam; CREATE TABLE t3(a int)engine=myisam; @@ -2376,7 +2373,6 @@ DROP TABLE t2, t1; # # Bug#46339 - crash on REPAIR TABLE merge table USE_FRM # -DROP TABLE IF EXISTS m1, t1; CREATE TABLE t1 (c1 INT) ENGINE=MYISAM; CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1) INSERT_METHOD=LAST; LOCK TABLE m1 READ; @@ -2565,7 +2561,6 @@ DROP TABLE t1; # # Test merge table with too many merge children. # -drop table if exists t_parent; set @save_table_open_cache=@@global.table_open_cache; # # Set @@global.table_open_cache to minimum @@ -2595,7 +2590,6 @@ deallocate prepare stmt; # drop table t_parent; set @@global.table_open_cache=@save_table_open_cache; -DROP DATABASE IF EXISTS mysql_test1; CREATE DATABASE mysql_test1; CREATE TABLE t1 ... DATA DIRECTORY=... INDEX DIRECTORY=... CREATE TABLE mysql_test1.t2 ... DATA DIRECTORY=... INDEX DIRECTORY=... @@ -2881,7 +2875,6 @@ DROP TABLE t1; # More tests with TEMPORARY MERGE table and permanent children. # First without locked tables. # -DROP TABLE IF EXISTS t1, t2, t3, t4, m1, m2; # CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM; CREATE TABLE t2 (c1 INT, c2 INT) ENGINE=MyISAM; @@ -3582,7 +3575,6 @@ DROP TABLE t1, t2, t3, t4, m1, m2; # Test that merge tables are closed correctly when opened using # HANDLER ... OPEN. # The general case. -DROP TABLE IF EXISTS t1, t2, t3; connect con1,localhost,root,,; CREATE TABLE t1 (c1 int); CREATE TABLE t2 (c1 int); @@ -3635,7 +3627,6 @@ drop table t4, t3, t2, t1; # # Bug#51240 ALTER TABLE of a locked MERGE table fails # -DROP TABLE IF EXISTS m1, t1; CREATE TABLE t1 (c1 INT); CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1); LOCK TABLE m1 WRITE; @@ -3657,7 +3648,6 @@ DROP TABLE m1, t1; # # Test for bug #37371 "CREATE TABLE LIKE merge loses UNION parameter" # -drop tables if exists t1, m1, m2; create table t1 (i int) engine=myisam; create table m1 (i int) engine=mrg_myisam union=(t1) insert_method=first; create table m2 like m1; @@ -3677,7 +3667,6 @@ drop tables m1, m2, t1; # Test case for Bug#54811 "Assert in mysql_lock_have_duplicate()" # Check that unique_table() works correctly for merge tables. # -drop table if exists t1, t2, t3, m1, m2; create table t1 (a int); create table t2 (a int); create table t3 (b int); @@ -3723,7 +3712,6 @@ drop table t1, t2, t3, m1, m2; # Bug#56494 Segfault in upgrade_shared_lock_to_exclusive() for # REPAIR of merge table # -DROP TABLE IF EXISTS t1, t2, t_not_exists; CREATE TABLE t1(a INT); ALTER TABLE t1 engine= MERGE UNION (t_not_exists); ANALYZE TABLE t1; @@ -3767,7 +3755,6 @@ DROP TABLE t1, t2; # Bug#57002 Assert in upgrade_shared_lock_to_exclusive() # for ALTER TABLE + MERGE tables # -DROP TABLE IF EXISTS t1, m1; CREATE TABLE t1(a INT) engine=myisam; CREATE TABLE m1(a INT) engine=merge UNION(t1); LOCK TABLES t1 READ, m1 WRITE; @@ -3779,7 +3766,6 @@ DROP TABLE m1, t1; # Test for bug #11754210 - "45777: CHECK TABLE DOESN'T SHOW ALL # PROBLEMS FOR MERGE TABLE COMPLIANCE IN 5.1" # -drop tables if exists t1, t2, t3, t4, m1; create table t1(id int) engine=myisam; create view t3 as select 1 as id; create table t4(id int) engine=memory; @@ -3809,8 +3795,7 @@ test.m1 repair error Corrupt drop tables m1, t1, t4; drop view t3; # -# MDEV-10424 - Assertion `ticket == __null' failed in -# MDL_request::set_type +# MDEV-10424 Assertion `ticket == __null' failed in MDL_request::set_type # CREATE TABLE t1 (f1 INT) ENGINE=MyISAM; CREATE TABLE tmerge (f1 INT) ENGINE=MERGE UNION=(t1); @@ -3829,7 +3814,9 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status Table is already up to date DEALLOCATE PREPARE stmt; DROP TABLE t1, tmerge; -End of 5.5 tests +# +# End of 5.5 tests +# # # Additional coverage for refactoring which is made as part # of fix for bug #27480 "Extend CREATE TEMPORARY TABLES privilege @@ -3837,8 +3824,7 @@ End of 5.5 tests # # Check that prelocking works correctly for various variants of # merge tables. -drop table if exists t1, t2, m1; -drop function if exists f1; +# create table t1 (j int); insert into t1 values (1); create function f1() returns int return (select count(*) from m1); @@ -3904,11 +3890,6 @@ checksum table m1; Table Checksum test.m1 3459908756 drop tables t1, m1; -DROP TABLE IF EXISTS t1; -DROP TABLE IF EXISTS m1; -DROP TRIGGER IF EXISTS trg1; -DROP TABLE IF EXISTS q1; -DROP TABLE IF EXISTS q2; CREATE TABLE t1(a INT); CREATE TABLE m1(a INT) ENGINE = MERGE UNION (q1, q2); CREATE TRIGGER trg1 BEFORE DELETE ON t1 @@ -3919,3 +3900,32 @@ ERROR HY000: Unable to open underlying table which is differently defined or of DROP TRIGGER trg1; DROP TABLE t1; DROP TABLE m1; +set global default_storage_engine=@save_default_storage_engine; +# +# End of 10.0 tests +# +# +# MDEV-27407 Different ASC/DESC index attributes on MERGE and underlying table can cause wrong results +# +create table t (a int, key(a desc)) engine=myisam; +create table tm (a int, key(a)) engine=merge union(t); +select * from tm; +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +drop table tm, t; +# +# MDEV-27586 Auto-increment does not work with DESC on MERGE table +# +create table t (a int not null, primary key(a desc)) engine=myisam; +create table tm (a int not null auto_increment, primary key(a desc)) engine=merge union=(t) insert_method=first; +insert into tm () values (); +insert into tm () values (); +insert into tm () values (); +select * from tm; +a +3 +2 +1 +drop table tm, t; +# +# End of 10.8 tests +# diff --git a/mysql-test/main/merge.test b/mysql-test/main/merge.test index 99cce370beb..0485f3ed1c3 100644 --- a/mysql-test/main/merge.test +++ b/mysql-test/main/merge.test @@ -13,12 +13,6 @@ set session default_storage_engine=myisam; # This test assumes a stable character set --source include/default_charset.inc -# Clean up resources used in this test case. ---disable_warnings -drop table if exists t1,t2,t3,t4,t5,t6; -drop database if exists mysqltest; ---enable_warnings - let $MYSQLD_DATADIR= `select @@datadir`; create table t1 (a int not null primary key auto_increment, message char(20)); create table t2 (a int not null primary key auto_increment, message char(20)); @@ -1652,10 +1646,6 @@ DROP TABLE t1; --echo # open merge table --echo # ---disable_warnings -DROP TABLE IF EXISTS m1,t1; ---enable_warnings - CREATE TABLE t1(a int)engine=myisam; CREATE TABLE t2(a int)engine=myisam; CREATE TABLE t3(a int)engine=myisam; @@ -1756,9 +1746,6 @@ DROP TABLE t2, t1; --echo # --echo # Bug#46339 - crash on REPAIR TABLE merge table USE_FRM --echo # ---disable_warnings -DROP TABLE IF EXISTS m1, t1; ---enable_warnings # # Test derived from a proposal of Shane Bester. # @@ -1893,9 +1880,6 @@ DROP TABLE t1; --echo # --echo # Test merge table with too many merge children. --echo # ---disable_warnings -drop table if exists t_parent; ---enable_warnings set @save_table_open_cache=@@global.table_open_cache; --echo # --echo # Set @@global.table_open_cache to minimum @@ -1910,9 +1894,6 @@ let $1 = `select @@table_open_cache;`; --disable_query_log while ($1) { ---disable_warnings - eval drop table if exists t$1; ---enable_warnings eval create table t$1 (a int) engine=myisam; eval set @a=ifnull(concat(@a, ", ", "t$1"), "t$1"); dec $1; @@ -1956,9 +1937,6 @@ set @@global.table_open_cache=@save_table_open_cache; # # Test DATA/INDEX DIRECTORY # ---disable_warnings -DROP DATABASE IF EXISTS mysql_test1; ---enable_warnings CREATE DATABASE mysql_test1; --disable_query_log # data/index directory don't work in HAVE_purify builds. Disable @@ -2269,9 +2247,6 @@ DROP TABLE t1; --echo # More tests with TEMPORARY MERGE table and permanent children. --echo # First without locked tables. --echo # ---disable_warnings -DROP TABLE IF EXISTS t1, t2, t3, t4, m1, m2; ---enable_warnings # --echo # CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM; @@ -2590,9 +2565,6 @@ DROP TABLE t1, t2, t3, t4, m1, m2; --echo # Test that merge tables are closed correctly when opened using --echo # HANDLER ... OPEN. --echo # The general case. ---disable_warnings -DROP TABLE IF EXISTS t1, t2, t3; ---enable_warnings connect (con1,localhost,root,,); CREATE TABLE t1 (c1 int); CREATE TABLE t2 (c1 int); @@ -2648,10 +2620,6 @@ drop table t4, t3, t2, t1; --echo # Bug#51240 ALTER TABLE of a locked MERGE table fails --echo # ---disable_warnings -DROP TABLE IF EXISTS m1, t1; ---enable_warnings - CREATE TABLE t1 (c1 INT); CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1); LOCK TABLE m1 WRITE; @@ -2677,9 +2645,6 @@ DROP TABLE m1, t1; --echo # --echo # Test for bug #37371 "CREATE TABLE LIKE merge loses UNION parameter" --echo # ---disable_warnings -drop tables if exists t1, m1, m2; ---enable_warnings create table t1 (i int) engine=myisam; create table m1 (i int) engine=mrg_myisam union=(t1) insert_method=first; create table m2 like m1; @@ -2692,9 +2657,6 @@ drop tables m1, m2, t1; --echo # Test case for Bug#54811 "Assert in mysql_lock_have_duplicate()" --echo # Check that unique_table() works correctly for merge tables. --echo # ---disable_warnings -drop table if exists t1, t2, t3, m1, m2; ---enable_warnings create table t1 (a int); create table t2 (a int); create table t3 (b int); @@ -2749,10 +2711,6 @@ drop table t1, t2, t3, m1, m2; --echo # REPAIR of merge table --echo # ---disable_warnings -DROP TABLE IF EXISTS t1, t2, t_not_exists; ---enable_warnings - CREATE TABLE t1(a INT); ALTER TABLE t1 engine= MERGE UNION (t_not_exists); # This caused the segfault @@ -2779,10 +2737,6 @@ DROP TABLE t1, t2; --echo # for ALTER TABLE + MERGE tables --echo # ---disable_warnings -DROP TABLE IF EXISTS t1, m1; ---enable_warnings - CREATE TABLE t1(a INT) engine=myisam; CREATE TABLE m1(a INT) engine=merge UNION(t1); LOCK TABLES t1 READ, m1 WRITE; @@ -2799,9 +2753,6 @@ DROP TABLE m1, t1; --echo # Test for bug #11754210 - "45777: CHECK TABLE DOESN'T SHOW ALL --echo # PROBLEMS FOR MERGE TABLE COMPLIANCE IN 5.1" --echo # ---disable_warnings -drop tables if exists t1, t2, t3, t4, m1; ---enable_warnings create table t1(id int) engine=myisam; create view t3 as select 1 as id; create table t4(id int) engine=memory; @@ -2821,8 +2772,7 @@ drop view t3; --echo # ---echo # MDEV-10424 - Assertion `ticket == __null' failed in ---echo # MDL_request::set_type +--echo # MDEV-10424 Assertion `ticket == __null' failed in MDL_request::set_type --echo # CREATE TABLE t1 (f1 INT) ENGINE=MyISAM; CREATE TABLE tmerge (f1 INT) ENGINE=MERGE UNION=(t1); @@ -2832,9 +2782,9 @@ EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t1, tmerge; - ---echo End of 5.5 tests - +--echo # +--echo # End of 5.5 tests +--echo # --echo # --echo # Additional coverage for refactoring which is made as part @@ -2843,10 +2793,7 @@ DROP TABLE t1, tmerge; --echo # --echo # Check that prelocking works correctly for various variants of --echo # merge tables. ---disable_warnings -drop table if exists t1, t2, m1; -drop function if exists f1; ---enable_warnings +--echo # create table t1 (j int); insert into t1 values (1); create function f1() returns int return (select count(*) from m1); @@ -2892,14 +2839,6 @@ drop tables t1, m1; # Check effect of Bug#27480-preliminary patch: # a merge-table with non-existing children, opened from a prelocked list. ---disable_warnings -DROP TABLE IF EXISTS t1; -DROP TABLE IF EXISTS m1; -DROP TRIGGER IF EXISTS trg1; -DROP TABLE IF EXISTS q1; -DROP TABLE IF EXISTS q2; ---enable_warnings - CREATE TABLE t1(a INT); CREATE TABLE m1(a INT) ENGINE = MERGE UNION (q1, q2); @@ -2914,12 +2853,36 @@ DROP TRIGGER trg1; DROP TABLE t1; DROP TABLE m1; ---disable_result_log ---disable_query_log set global default_storage_engine=@save_default_storage_engine; ---enable_result_log ---enable_query_log # Check that all connections opened by test cases in this file are really # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc + +--echo # +--echo # End of 10.0 tests +--echo # + +--echo # +--echo # MDEV-27407 Different ASC/DESC index attributes on MERGE and underlying table can cause wrong results +--echo # +create table t (a int, key(a desc)) engine=myisam; +create table tm (a int, key(a)) engine=merge union(t); +--error ER_WRONG_MRG_TABLE +select * from tm; +drop table tm, t; + +--echo # +--echo # MDEV-27586 Auto-increment does not work with DESC on MERGE table +--echo # +create table t (a int not null, primary key(a desc)) engine=myisam; +create table tm (a int not null auto_increment, primary key(a desc)) engine=merge union=(t) insert_method=first; +insert into tm () values (); +insert into tm () values (); +insert into tm () values (); +select * from tm; +drop table tm, t; + +--echo # +--echo # End of 10.8 tests +--echo # diff --git a/mysql-test/main/multi_update.result b/mysql-test/main/multi_update.result index 61e04c3d4a9..674dc79fe12 100644 --- a/mysql-test/main/multi_update.result +++ b/mysql-test/main/multi_update.result @@ -1184,22 +1184,28 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "partitions": ["Current"], - "access_type": "system", - "possible_keys": ["PRIMARY"], - "rows": 1, - "filtered": 100 - }, - "table": { - "table_name": "t1", - "partitions": ["Current"], - "access_type": "system", - "possible_keys": ["PRIMARY"], - "rows": 1, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "partitions": ["Current"], + "access_type": "system", + "possible_keys": ["PRIMARY"], + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "t1", + "partitions": ["Current"], + "access_type": "system", + "possible_keys": ["PRIMARY"], + "rows": 1, + "filtered": 100 + } + } + ] } } # Expecting partition "Relevant" @@ -1208,22 +1214,28 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "partitions": ["Relevant"], - "access_type": "system", - "possible_keys": ["PRIMARY"], - "rows": 1, - "filtered": 100 - }, - "table": { - "table_name": "t1", - "partitions": ["Relevant"], - "access_type": "system", - "possible_keys": ["PRIMARY"], - "rows": 1, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "partitions": ["Relevant"], + "access_type": "system", + "possible_keys": ["PRIMARY"], + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "t1", + "partitions": ["Relevant"], + "access_type": "system", + "possible_keys": ["PRIMARY"], + "rows": 1, + "filtered": 100 + } + } + ] } } # Expecting partition "Archive" @@ -1232,22 +1244,28 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "partitions": ["Archive"], - "access_type": "system", - "possible_keys": ["PRIMARY"], - "rows": 1, - "filtered": 100 - }, - "table": { - "table_name": "t1", - "partitions": ["Archive"], - "access_type": "system", - "possible_keys": ["PRIMARY"], - "rows": 1, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "partitions": ["Archive"], + "access_type": "system", + "possible_keys": ["PRIMARY"], + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "t1", + "partitions": ["Archive"], + "access_type": "system", + "possible_keys": ["PRIMARY"], + "rows": 1, + "filtered": 100 + } + } + ] } } DROP TABLES t1, t2; diff --git a/mysql-test/main/my_print_defaults.result b/mysql-test/main/my_print_defaults.result index 64aa7b45ca8..45765de0a1a 100644 --- a/mysql-test/main/my_print_defaults.result +++ b/mysql-test/main/my_print_defaults.result @@ -14,10 +14,6 @@ # # MDEV-25908: -e does not work for my_print_defaults # -# Testing -e ---key_buffer_size=20M ---max_allowed_packet=250M ---table_open_cache=1000 #Testing --defaults-extra-file --key_buffer_size=20M --max_allowed_packet=250M @@ -25,27 +21,38 @@ # # Testing other options # -# Testing -c option ---key_buffer_size=20M ---max_allowed_packet=250M ---table_open_cache=1000 # Testing --defaults-file --key_buffer_size=20M --max_allowed_packet=250M --table_open_cache=1000 -# Testing -g option +# Testing --defaults-group-suffix --key_buffer_size=20M --max_allowed_packet=250M --table_open_cache=1000 --table_definition_cache=2000 --read_buffer_size=1M --thread_cache_size=8 -# Testing --defaults-group-suffix +# Testing --no-defaults +# End of 10.5 Test +# Beginning of 10.7 test +# +# MDEV-26238: Remove inconsistent behaviour of --default-* options in +# my_print_defaults +# +# checking that --defaults* option only works when mentioned at beginning +# Testing --defaults-file at beginning only +--key_buffer_size=20M +--max_allowed_packet=250M +--table_open_cache=1000 +# Testing --defaults-extra-file works at beginning only +--key_buffer_size=20M +--max_allowed_packet=250M +--table_open_cache=1000 +# Testing --defaults-group-suffix works at beginning only --key_buffer_size=20M --max_allowed_packet=250M --table_open_cache=1000 --table_definition_cache=2000 --read_buffer_size=1M --thread_cache_size=8 -# Testing --no-defaults -# End of 10.5 Test +# End of 10.7 test diff --git a/mysql-test/main/my_print_defaults.test b/mysql-test/main/my_print_defaults.test index bfd4e563826..bb650f49e83 100644 --- a/mysql-test/main/my_print_defaults.test +++ b/mysql-test/main/my_print_defaults.test @@ -30,7 +30,7 @@ long_query_time=60 slow_query_log=1 EOF ---exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server +--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server --remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf --remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf @@ -55,10 +55,8 @@ max_allowed_packet=250M table_open_cache=1000 EOF ---echo # Testing -e ---exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQLTEST_VARDIR/tmp/tmp1.cnf -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server --echo #Testing --defaults-extra-file ---exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server +--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server --remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf --remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf @@ -87,20 +85,80 @@ read_buffer_size=1M thread_cache_size=8 EOF ---echo # Testing -c option ---exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server --echo # Testing --defaults-file --exec $MYSQL_MY_PRINT_DEFAULTS --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server ---echo # Testing -g option ---exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp3.cnf --mysqld mysql.server -g .1 --echo # Testing --defaults-group-suffix ---exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp3.cnf --mysqld mysql.server --defaults-group-suffix=.1 +--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp3.cnf --defaults-group-suffix=.1 --mysqld mysql.server --echo # Testing --no-defaults ---exec $MYSQL_MY_PRINT_DEFAULTS --no-defaults +--exec $MYSQL_MY_PRINT_DEFAULTS --no-defaults --mysqld --remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf --remove_file $MYSQLTEST_VARDIR/tmp/tmp3.cnf --echo # End of 10.5 Test + +--echo # Beginning of 10.7 test + +--echo # +--echo # MDEV-26238: Remove inconsistent behaviour of --default-* options in +--echo # my_print_defaults +--echo # + +--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf +[mariadb] +key_buffer_size=20M +max_allowed_packet=250M +table_open_cache=1000 +EOF + +--write_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf +[mariadb] +key_buffer_size=10M +max_allowed_packet=250M +table_open_cache=1000 +EOF + +--write_file $MYSQLTEST_VARDIR/tmp/tmp3.cnf +[mariadb] +key_buffer_size=30M +max_allowed_packet=250M +table_open_cache=1000 +EOF + +--echo # checking that --defaults* option only works when mentioned at beginning + +--echo # Testing --defaults-file at beginning only +--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mysqld +--error 7 +--exec $MYSQL_MY_PRINT_DEFAULTS --mysqld --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf +--remove_file $MYSQLTEST_VARDIR/tmp/tmp3.cnf + +--echo # Testing --defaults-extra-file works at beginning only +--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld +--error 7 +--exec $MYSQL_MY_PRINT_DEFAULTS --mysqld --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp2.cnf + +--write_file $MYSQLTEST_VARDIR/tmp/tmp3.cnf +[mariadb] +key_buffer_size=20M +max_allowed_packet=250M +table_open_cache=1000 + +[mariadb.1] +table_definition_cache=2000 +read_buffer_size=1M +thread_cache_size=8 +EOF + +--echo # Testing --defaults-group-suffix works at beginning only +--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp3.cnf --defaults-group-suffix=.1 --mysqld +--error 7 +--exec $MYSQL_MY_PRINT_DEFAULTS --mysqld --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp3.cnf --defaults-group-suffix=.1 + +--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf +--remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf +--remove_file $MYSQLTEST_VARDIR/tmp/tmp3.cnf + +--echo # End of 10.7 test diff --git a/mysql-test/main/myisam-optimize.result b/mysql-test/main/myisam-optimize.result deleted file mode 100644 index 63cdcd9f248..00000000000 --- a/mysql-test/main/myisam-optimize.result +++ /dev/null @@ -1,83 +0,0 @@ -# -# MDEV-8475 stale .TMM file causes Aria engine to stop serving the table -# -create table t1 (pk int primary key, i int) engine=MyISAM; -insert into t1 values (1,1),(2,2); -connect con1,localhost,root,,; -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `pk` int(11) NOT NULL, - `i` int(11) DEFAULT NULL, - PRIMARY KEY (`pk`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -OPTIMIZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 optimize status OK -disconnect con1; -connect con1,localhost,root,,; -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `pk` int(11) NOT NULL, - `i` int(11) DEFAULT NULL, - PRIMARY KEY (`pk`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -OPTIMIZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 optimize status Table is already up to date -disconnect con1; -connect con1,localhost,root,,; -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `pk` int(11) NOT NULL, - `i` int(11) DEFAULT NULL, - PRIMARY KEY (`pk`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -OPTIMIZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 optimize status Table is already up to date -disconnect con1; -connection default; -DROP TABLE t1; -create table t1 (pk int primary key, i int) engine=aria; -insert into t1 values (1,1),(2,2); -connect con1,localhost,root,,; -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `pk` int(11) NOT NULL, - `i` int(11) DEFAULT NULL, - PRIMARY KEY (`pk`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 -OPTIMIZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 optimize status OK -disconnect con1; -connect con1,localhost,root,,; -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `pk` int(11) NOT NULL, - `i` int(11) DEFAULT NULL, - PRIMARY KEY (`pk`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 -OPTIMIZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 optimize status Table is already up to date -disconnect con1; -connect con1,localhost,root,,; -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `pk` int(11) NOT NULL, - `i` int(11) DEFAULT NULL, - PRIMARY KEY (`pk`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 -OPTIMIZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 optimize status Table is already up to date -disconnect con1; -connection default; -DROP TABLE t1; diff --git a/mysql-test/main/myisam-optimize.test b/mysql-test/main/myisam-optimize.test deleted file mode 100644 index 44e38e1e708..00000000000 --- a/mysql-test/main/myisam-optimize.test +++ /dev/null @@ -1,60 +0,0 @@ ---echo # ---echo # MDEV-8475 stale .TMM file causes Aria engine to stop serving the table ---echo # ---disable_service_connection -create table t1 (pk int primary key, i int) engine=MyISAM; -insert into t1 values (1,1),(2,2); ---let $datadir=`SELECT @@datadir` - ---write_file $datadir/test/t1.TMM -EOF - ---connect (con1,localhost,root,,) -SHOW CREATE TABLE t1; -OPTIMIZE TABLE t1; ---disconnect con1 - ---connect (con1,localhost,root,,) -SHOW CREATE TABLE t1; -OPTIMIZE TABLE t1; ---disconnect con1 - ---connect (con1,localhost,root,,) -SHOW CREATE TABLE t1; -OPTIMIZE TABLE t1; ---disconnect con1 - -# Cleanup ---connection default -DROP TABLE t1; - -# -# Test also Aria -# - -create table t1 (pk int primary key, i int) engine=aria; -insert into t1 values (1,1),(2,2); ---let $datadir=`SELECT @@datadir` - ---write_file $datadir/test/t1.TMM -EOF - ---connect (con1,localhost,root,,) -SHOW CREATE TABLE t1; -OPTIMIZE TABLE t1; ---disconnect con1 - ---connect (con1,localhost,root,,) -SHOW CREATE TABLE t1; -OPTIMIZE TABLE t1; ---disconnect con1 - ---connect (con1,localhost,root,,) -SHOW CREATE TABLE t1; -OPTIMIZE TABLE t1; ---disconnect con1 - -# Cleanup ---connection default -DROP TABLE t1; ---enable_service_connection diff --git a/mysql-test/main/myisam.result b/mysql-test/main/myisam.result index 1b6a5cba915..0b0099d7b84 100644 --- a/mysql-test/main/myisam.result +++ b/mysql-test/main/myisam.result @@ -1,6 +1,5 @@ call mtr.add_suppression("Can't find record in '.*'"); call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired"); -drop table if exists t1,t2,t3; SET SQL_WARNINGS=1; CREATE TABLE t1 ( STRING_DATA char(255) default NULL, @@ -2706,3 +2705,108 @@ DROP TABLE t1; # # End of 5.5 tests # +# +# MDEV-27303 Table corruption after insert into a non-InnoDB table with DESC index +# +create table t1 ( +a bigint default 0, +b bigint default 0, +c binary(128) not null, +d datetime default '0000-00-00 00:00:00', +key (c desc,b,d,a) +) engine=aria; +insert into t1 (c) values +('xx'),('bb'),('tt'),('pp'),('mm'),('yy'),('rr'),('bb'),('yy'),('gg'), +('dd'),('fx'),('wi'),('ix'),('ox'),('mu'),('ux'),('pm'),('mx'),('xu'), +('ul'),('lp'),('px'),('lp'),('xx'),('pq'),('qs'),('se'),('ee'),('xx'), +('rv'),('ff'),('vj'),('jy'),('yn'),('nc'),('nx'),('hj'),('ji'),('ik'), +('kk'),('ww'),('xx'),('yd'),('dw'),('wk'),('kr'),('dd'),('rj'),('jf'), +('bx'),('fc'),('cp'),('pm'),('mw'),('wy'),('yl'),('li'),('ic'),('he'), +('ci'),('il'),('lz'),('zd'),('gz'),('xd'),('ze'),('dm'),('ms'),('xd'), +('sw'),('we'),('nb'),('tx'),('vr'),('xw'),('aa'),('ah'),('hd'),('jl'), +('lf'),('fw'),('wx'),('xh'),('hr'),('zx'),('vw'),('rm'),('mx'),('xt'), +('tp'),('ps'),('sh'),('ga'),('df'),('as'),('gz'),('xd'),('yy'),('xr'); +check table t1 extended; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +# +# MDEV-27309 Server crash or ASAN memcpy-param-overlap upon INSERT into Aria/MyISAM table with DESC key +# +CREATE TABLE t1 (id INT, c BINARY(80), PRIMARY KEY(id)); +ALTER TABLE t1 ADD KEY(c DESC, id); +INSERT INTO t1 VALUES (1,NULL),(2,''),(3,''); +DROP TABLE t1; +# +# MDEV-27330 Wrong sorting order with DESC index and empty strings in MyISAM/Aria table +# +create table t (id int, c char(128) not null, key (c desc)); +insert into t values (1,''),(2,'foo'),(3,''),(4,'bar'); +select c from t order by c; +c + + +bar +foo +drop table t; +# +# MDEV-27340 NULL gets lost (becomes empty string), SELECT hangs with DESC index on MyISAM/Aria table +# +create table t (c char(8), key(c desc)) character set utf8mb4; +insert into t values (''),('foo'),(null),(''),('bar'); +check table t; +Table Op Msg_type Msg_text +test.t check status OK +check table t extended; +Table Op Msg_type Msg_text +test.t check status OK +select distinct c from t; +c +NULL + +bar +foo +select c from t; +c +foo +bar + + +NULL +drop table t; +# +# MDEV-27434 DESC attribute does not work with auto-increment on secondary column of multi-part index +# +create table t (a int auto_increment, b int, unique(b,a desc)) engine=myisam; +insert ignore into t (b) values (10),(10),(10); +select * from t; +a b +3 10 +2 10 +1 10 +drop table t; +# +# MDEV-27585 Auto-increment on secondary column increments unexpectedly with DESC key +# +create table t (c char(16), i int auto_increment, index (c,i desc)) engine=myisam collate latin1_swedish_ci; +insert into t (c) values ('ä'),('a'); +select hex(c),c,i from t order by c, i; +hex(c) c i +61 a 1 +C3A4 ä 1 +drop table t; +# +# MDEV-27617 HANDLER KEY > (x) does not work with DESC keys, Spider is affected and returns wrong results +# +create table t (a int, b char(1), primary key(a desc)) engine=myisam; +insert into t VALUES (1,'f'),(2,'g'),(3,'j'), (4,'i'),(5,'h'); +handler t open; +# MUST return 2,'g'. '>' always means READ_AFTER_KEY. desc or not. +handler t read `primary` > (3); +a b +2 g +handler t close; +drop table t; +# +# End of 10.8 tests +# diff --git a/mysql-test/main/myisam.test b/mysql-test/main/myisam.test index 58d094d7d08..ec49e71bc2d 100644 --- a/mysql-test/main/myisam.test +++ b/mysql-test/main/myisam.test @@ -8,9 +8,6 @@ call mtr.add_suppression("Can't find record in '.*'"); call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired"); # Initialise ---disable_warnings -drop table if exists t1,t2,t3; ---enable_warnings SET SQL_WARNINGS=1; # @@ -1831,3 +1828,85 @@ DROP TABLE t1; --echo # --echo # End of 5.5 tests --echo # + +--echo # +--echo # MDEV-27303 Table corruption after insert into a non-InnoDB table with DESC index +--echo # +create table t1 ( + a bigint default 0, + b bigint default 0, + c binary(128) not null, + d datetime default '0000-00-00 00:00:00', + key (c desc,b,d,a) +) engine=aria; +insert into t1 (c) values + ('xx'),('bb'),('tt'),('pp'),('mm'),('yy'),('rr'),('bb'),('yy'),('gg'), + ('dd'),('fx'),('wi'),('ix'),('ox'),('mu'),('ux'),('pm'),('mx'),('xu'), + ('ul'),('lp'),('px'),('lp'),('xx'),('pq'),('qs'),('se'),('ee'),('xx'), + ('rv'),('ff'),('vj'),('jy'),('yn'),('nc'),('nx'),('hj'),('ji'),('ik'), + ('kk'),('ww'),('xx'),('yd'),('dw'),('wk'),('kr'),('dd'),('rj'),('jf'), + ('bx'),('fc'),('cp'),('pm'),('mw'),('wy'),('yl'),('li'),('ic'),('he'), + ('ci'),('il'),('lz'),('zd'),('gz'),('xd'),('ze'),('dm'),('ms'),('xd'), + ('sw'),('we'),('nb'),('tx'),('vr'),('xw'),('aa'),('ah'),('hd'),('jl'), + ('lf'),('fw'),('wx'),('xh'),('hr'),('zx'),('vw'),('rm'),('mx'),('xt'), + ('tp'),('ps'),('sh'),('ga'),('df'),('as'),('gz'),('xd'),('yy'),('xr'); +check table t1 extended; +drop table t1; + +--echo # +--echo # MDEV-27309 Server crash or ASAN memcpy-param-overlap upon INSERT into Aria/MyISAM table with DESC key +--echo # +CREATE TABLE t1 (id INT, c BINARY(80), PRIMARY KEY(id)); +ALTER TABLE t1 ADD KEY(c DESC, id); +INSERT INTO t1 VALUES (1,NULL),(2,''),(3,''); +DROP TABLE t1; + +--echo # +--echo # MDEV-27330 Wrong sorting order with DESC index and empty strings in MyISAM/Aria table +--echo # +create table t (id int, c char(128) not null, key (c desc)); +insert into t values (1,''),(2,'foo'),(3,''),(4,'bar'); +select c from t order by c; +drop table t; + +--echo # +--echo # MDEV-27340 NULL gets lost (becomes empty string), SELECT hangs with DESC index on MyISAM/Aria table +--echo # +create table t (c char(8), key(c desc)) character set utf8mb4; +insert into t values (''),('foo'),(null),(''),('bar'); +check table t; +check table t extended; +select distinct c from t; +select c from t; +drop table t; + +--echo # +--echo # MDEV-27434 DESC attribute does not work with auto-increment on secondary column of multi-part index +--echo # +create table t (a int auto_increment, b int, unique(b,a desc)) engine=myisam; +insert ignore into t (b) values (10),(10),(10); +select * from t; +drop table t; + +--echo # +--echo # MDEV-27585 Auto-increment on secondary column increments unexpectedly with DESC key +--echo # +create table t (c char(16), i int auto_increment, index (c,i desc)) engine=myisam collate latin1_swedish_ci; +insert into t (c) values ('ä'),('a'); +select hex(c),c,i from t order by c, i; +drop table t; + +--echo # +--echo # MDEV-27617 HANDLER KEY > (x) does not work with DESC keys, Spider is affected and returns wrong results +--echo # +create table t (a int, b char(1), primary key(a desc)) engine=myisam; +insert into t VALUES (1,'f'),(2,'g'),(3,'j'), (4,'i'),(5,'h'); +handler t open; +--echo # MUST return 2,'g'. '>' always means READ_AFTER_KEY. desc or not. +handler t read `primary` > (3); +handler t close; +drop table t; + +--echo # +--echo # End of 10.8 tests +--echo # diff --git a/mysql-test/main/myisam_optimize.result b/mysql-test/main/myisam_optimize.result index f71d524fadb..28c9caa83b2 100644 --- a/mysql-test/main/myisam_optimize.result +++ b/mysql-test/main/myisam_optimize.result @@ -43,3 +43,86 @@ i UNLOCK TABLES; DROP TABLE t1; # End of 10.0 tests +# +# MDEV-8475 stale .TMM file causes Aria engine to stop serving the table +# +create table t1 (pk int primary key, i int) engine=MyISAM; +insert into t1 values (1,1),(2,2); +connect con1,localhost,root,,; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +disconnect con1; +connect con1,localhost,root,,; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status Table is already up to date +disconnect con1; +connect con1,localhost,root,,; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status Table is already up to date +disconnect con1; +connection default; +DROP TABLE t1; +create table t1 (pk int primary key, i int) engine=aria; +insert into t1 values (1,1),(2,2); +connect con1,localhost,root,,; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +disconnect con1; +connect con1,localhost,root,,; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status Table is already up to date +disconnect con1; +connect con1,localhost,root,,; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + `i` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status Table is already up to date +disconnect con1; +connection default; +DROP TABLE t1; diff --git a/mysql-test/main/myisam_optimize.test b/mysql-test/main/myisam_optimize.test index 82096f0b4e3..44215fd2848 100644 --- a/mysql-test/main/myisam_optimize.test +++ b/mysql-test/main/myisam_optimize.test @@ -64,4 +64,64 @@ UNLOCK TABLES; DROP TABLE t1; --echo # End of 10.0 tests +--echo # +--echo # MDEV-8475 stale .TMM file causes Aria engine to stop serving the table +--echo # +create table t1 (pk int primary key, i int) engine=MyISAM; +insert into t1 values (1,1),(2,2); +--let $datadir=`SELECT @@datadir` + +--write_file $datadir/test/t1.TMM +EOF + +--connect (con1,localhost,root,,) +SHOW CREATE TABLE t1; +OPTIMIZE TABLE t1; +--disconnect con1 + +--connect (con1,localhost,root,,) +SHOW CREATE TABLE t1; +OPTIMIZE TABLE t1; +--disconnect con1 + +--connect (con1,localhost,root,,) +SHOW CREATE TABLE t1; +OPTIMIZE TABLE t1; +--disconnect con1 + +# Cleanup +--connection default +DROP TABLE t1; + +# +# Test also Aria +# + +create table t1 (pk int primary key, i int) engine=aria; +insert into t1 values (1,1),(2,2); +--let $datadir=`SELECT @@datadir` + +--write_file $datadir/test/t1.TMM +EOF + +--connect (con1,localhost,root,,) +SHOW CREATE TABLE t1; +OPTIMIZE TABLE t1; +--disconnect con1 + +--connect (con1,localhost,root,,) +SHOW CREATE TABLE t1; +OPTIMIZE TABLE t1; +--disconnect con1 + +--connect (con1,localhost,root,,) +SHOW CREATE TABLE t1; +OPTIMIZE TABLE t1; +--disconnect con1 + +# Cleanup +--connection default +DROP TABLE t1; + --enable_service_connection + diff --git a/mysql-test/main/mysql_install_db_win_utf8.result b/mysql-test/main/mysql_install_db_win_utf8.result new file mode 100644 index 00000000000..744c982b291 --- /dev/null +++ b/mysql-test/main/mysql_install_db_win_utf8.result @@ -0,0 +1,14 @@ +Running bootstrap +Creating my.ini file +Removing default user +Allowing remote access for user root +Setting root password +Creation of the database was successful +# Kill the server +connect con1,localhost,root,パスワード,mysql; +SELECT @@datadir; +@@datadir +DATADIR/ +# Kill the server +connection default; +# restart diff --git a/mysql-test/main/mysql_install_db_win_utf8.test b/mysql-test/main/mysql_install_db_win_utf8.test new file mode 100644 index 00000000000..fc67b66d3ca --- /dev/null +++ b/mysql-test/main/mysql_install_db_win_utf8.test @@ -0,0 +1,35 @@ +--source include/windows.inc +--source include/check_utf8_cli.inc + +# Create database in tmp directory using mysql_install_db.exe, +# and start server from this directory. +let $ddir= $MYSQLTEST_VARDIR/tmp/датадир; +--error 0,1 +rmdir $ddir; +exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --password=パスワード -R; +--source include/kill_mysqld.inc + +# Note "restart" via MTR does not work, if server's command line has +# non-ASCII characters used (or, characters outside of ANSI codepage). +# This is a perl limitation, which is worked around in this test - +# the server started in background, via exec $MYSQLD + +--replace_result $MYSQLD MYSQLD $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +exec $MYSQLD --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.1 --datadir=$ddir --loose-innodb > NUL 2>&1 &; +--enable_reconnect +--source include/wait_until_connected_again.inc +--disable_reconnect + +connect (con1,localhost,root,パスワード,mysql); + +# Smoke test - check that we're actually using datadir +# we've created (i.e restart_parameters worked) +--replace_result $ddir DATADIR +SELECT @@datadir; +# restart in the original datadir again +--source include/kill_mysqld.inc +rmdir $ddir; + +connection default; +--source include/start_mysqld.inc + diff --git a/mysql-test/main/mysql_upgrade.result b/mysql-test/main/mysql_upgrade.result index b4c42d6828d..f119937bf59 100644 --- a/mysql-test/main/mysql_upgrade.result +++ b/mysql-test/main/mysql_upgrade.result @@ -1,4 +1,5 @@ set sql_mode=""; +call mtr.add_suppression("Incorrect definition of table mysql.column_stats:.*"); Run mysql_upgrade once Phase 1/7: Checking and upgrading mysql database Processing databases diff --git a/mysql-test/main/mysql_upgrade.test b/mysql-test/main/mysql_upgrade.test index 0751cee7429..b9ff05401f7 100644 --- a/mysql-test/main/mysql_upgrade.test +++ b/mysql-test/main/mysql_upgrade.test @@ -6,6 +6,7 @@ set sql_mode=""; +call mtr.add_suppression("Incorrect definition of table mysql.column_stats:.*"); # # Basic test that we can run mysql_upgrde and that it finds the # expected binaries it uses. diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index f2ba6ac2d53..4e1563086bf 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -42,6 +42,9 @@ The following specify which files/extra groups are read (specified before remain full' errors. No longer needed, as the server now handles this automatically. --bind-address=name IP address to bind to. + --binlog-alter-two-phase + When set, split ALTER at binary logging into 2 + statements: START ALTER and COMMIT/ROLLBACK ALTER --binlog-annotate-row-events Tells the master to annotate RBR events with the statement that caused these events @@ -370,7 +373,8 @@ The following specify which files/extra groups are read (specified before remain Specifies type of the histograms created by ANALYZE. Possible values are: SINGLE_PREC_HB - single precision height-balanced, DOUBLE_PREC_HB - double precision - height-balanced. + height-balanced, JSON_HB - height-balanced, stored as + JSON. --host-cache-size=# How many host names should be cached to avoid resolving. (Automatically configured unless set explicitly) --idle-readonly-transaction-timeout=# @@ -1479,6 +1483,7 @@ automatic-sp-privileges TRUE back-log 80 big-tables FALSE bind-address (No default value) +binlog-alter-two-phase FALSE binlog-annotate-row-events TRUE binlog-cache-size 32768 binlog-checksum CRC32 diff --git a/mysql-test/main/mysqldump-system.result b/mysql-test/main/mysqldump-system.result index bf2d60c698c..559f6f29f44 100644 --- a/mysql-test/main/mysqldump-system.result +++ b/mysql-test/main/mysqldump-system.result @@ -23,15 +23,17 @@ create table mysql.tz like mysql.time_zone_transition; alter table mysql.tz engine=innodb; insert into mysql.tz select * from mysql.time_zone_transition; set global innodb_stats_persistent=1; +set time_zone="+03:00"; +SET TIMESTAMP= UNIX_TIMESTAMP('2022-01-07 07:07:00'); ANALYZE TABLE mysql.tz PERSISTENT FOR ALL; Table Op Msg_type Msg_text mysql.tz analyze status Engine-independent statistics collected mysql.tz analyze status OK delete from mysql.index_stats where prefix_arity!=1; delete from mysql.column_stats where column_name!='Time_zone_id'; -set time_zone="+03:00"; update mysql.innodb_index_stats set last_update="2020-01-01" where database_name="mysql" and table_name="tz"; update mysql.innodb_table_stats set last_update="2020-01-01" where database_name="mysql" and table_name="tz"; +update mysql.column_stats set histogram=json_replace(histogram, '$.collected_by', replace(json_value(histogram, '$.collected_by'), @@version, 'version')); set global innodb_stats_persistent= @save_innodb_stats_persistent; alter table mysql.time_zone_name ORDER BY Name; CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(Host 'localhost'); @@ -94,7 +96,7 @@ USE mysql; LOCK TABLES `column_stats` WRITE; /*!40000 ALTER TABLE `column_stats` DISABLE KEYS */; REPLACE INTO `column_stats` VALUES -('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,254,'DOUBLE_PREC_HB','\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿'); +('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340966921, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"5\", \"size\": 0.002544529, \"ndv\": 1}]}'); /*!40000 ALTER TABLE `column_stats` ENABLE KEYS */; UNLOCK TABLES; @@ -708,7 +710,7 @@ USE mysql; LOCK TABLES `column_stats` WRITE; /*!40000 ALTER TABLE `column_stats` DISABLE KEYS */; REPLACE INTO `column_stats` VALUES -('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,254,'DOUBLE_PREC_HB','\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿'); +('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340966921, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"5\", \"size\": 0.002544529, \"ndv\": 1}]}'); /*!40000 ALTER TABLE `column_stats` ENABLE KEYS */; UNLOCK TABLES; @@ -1299,7 +1301,7 @@ USE mysql; LOCK TABLES `column_stats` WRITE; /*!40000 ALTER TABLE `column_stats` DISABLE KEYS */; INSERT IGNORE INTO `column_stats` VALUES -('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,254,'DOUBLE_PREC_HB','\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿'); +('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340966921, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"5\", \"size\": 0.002544529, \"ndv\": 1}]}'); /*!40000 ALTER TABLE `column_stats` ENABLE KEYS */; UNLOCK TABLES; diff --git a/mysql-test/main/mysqldump-system.test b/mysql-test/main/mysqldump-system.test index 7e85fcc1a11..85ad44211a8 100644 --- a/mysql-test/main/mysqldump-system.test +++ b/mysql-test/main/mysqldump-system.test @@ -43,13 +43,15 @@ create table mysql.tz like mysql.time_zone_transition; alter table mysql.tz engine=innodb; insert into mysql.tz select * from mysql.time_zone_transition; set global innodb_stats_persistent=1; +set time_zone="+03:00"; +SET TIMESTAMP= UNIX_TIMESTAMP('2022-01-07 07:07:00'); ANALYZE TABLE mysql.tz PERSISTENT FOR ALL; # for predictable output in tests delete from mysql.index_stats where prefix_arity!=1; delete from mysql.column_stats where column_name!='Time_zone_id'; -set time_zone="+03:00"; update mysql.innodb_index_stats set last_update="2020-01-01" where database_name="mysql" and table_name="tz"; update mysql.innodb_table_stats set last_update="2020-01-01" where database_name="mysql" and table_name="tz"; +update mysql.column_stats set histogram=json_replace(histogram, '$.collected_by', replace(json_value(histogram, '$.collected_by'), @@version, 'version')); set global innodb_stats_persistent= @save_innodb_stats_persistent; alter table mysql.time_zone_name ORDER BY Name; diff --git a/mysql-test/main/mysqldump.test b/mysql-test/main/mysqldump.test index 7dc3cfe8558..238d90e4cdc 100644 --- a/mysql-test/main/mysqldump.test +++ b/mysql-test/main/mysqldump.test @@ -965,8 +965,8 @@ DROP TABLE t1, t2; [mysqltest1] port=1234 EOF ---exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 ---exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 mysqltest1 +--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 +--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 mysqltest1 --remove_file $MYSQLTEST_VARDIR/tmp/tmp.cnf --echo # diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 6a6032e5271..02b448eabc3 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -1019,7 +1019,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "access_type": "ref", "index": "a", "used_range_estimates": false, - "cause": "not available", + "reason": "not available", "rowid_filter_skipped": "cost_factor <= 0", "rows": 1, "cost": 200.0585794, @@ -1076,7 +1076,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "access_type": "ref", "index": "a", "used_range_estimates": false, - "cause": "not available", + "reason": "not available", "rowid_filter_skipped": "cost_factor <= 0", "rows": 1, "cost": 200.0585794, @@ -2082,12 +2082,12 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { { "column_name": "a", "ranges": ["1 <= a <= 1"], - "selectivity_from_histogram": 0.1796875 + "selectivity_from_histogram": 0.181 }, { "column_name": "b", "ranges": ["2 <= b <= 2"], - "selectivity_from_histogram": 0.015625 + "selectivity_from_histogram": 0.021 } ], "cond_selectivity": 0.021 @@ -2167,6 +2167,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { { "index": "a_a", "can_resolve_order": true, + "direction": 1, "updated_limit": 47, "index_scan_time": 47, "usable": false, @@ -2175,6 +2176,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { { "index": "a_c", "can_resolve_order": true, + "direction": 1, "updated_limit": 47, "range_scan_time": 4.331020747, "index_scan_time": 4.331020747, @@ -2813,15 +2815,6 @@ explain extended select * from t1 where a in (select pk from t10) { "transformation": { "select_id": 2, "from": "IN (SELECT)", - "to": "materialization", - "sjm_scan_allowed": true, - "possible": true - } - }, - { - "transformation": { - "select_id": 2, - "from": "IN (SELECT)", "to": "semijoin", "chosen": true } @@ -2846,6 +2839,15 @@ explain extended select * from t1 where a in (select pk from t10) { "transformation": { "select_id": 2, "from": "IN (SELECT)", + "to": "materialization", + "sjm_scan_allowed": true, + "possible": true + } + }, + { + "transformation": { + "select_id": 2, + "from": "IN (SELECT)", "to": "semijoin", "converted_to_semi_join": true } @@ -4029,7 +4031,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "access_type": "ref", "index": "a", "used_range_estimates": false, - "cause": "not better than ref estimates", + "reason": "not better than ref estimates", "rowid_filter_skipped": "cost_factor <= 0", "rows": 1, "cost": 3.001757383, @@ -4086,7 +4088,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "index": "a", "rec_per_key_stats_missing": true, "used_range_estimates": false, - "cause": "not better than ref estimates", + "reason": "not better than ref estimates", "rowid_filter_skipped": "worst/max seeks clipping", "rows": 2, "cost": 3.003514767, @@ -4383,15 +4385,6 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "transformation": { "select_id": 2, "from": "IN (SELECT)", - "to": "materialization", - "sjm_scan_allowed": true, - "possible": true - } - }, - { - "transformation": { - "select_id": 2, - "from": "IN (SELECT)", "to": "semijoin", "chosen": true } @@ -4416,6 +4409,15 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ "transformation": { "select_id": 2, "from": "IN (SELECT)", + "to": "materialization", + "sjm_scan_allowed": true, + "possible": true + } + }, + { + "transformation": { + "select_id": 2, + "from": "IN (SELECT)", "to": "semijoin", "converted_to_semi_join": true } @@ -4832,15 +4834,6 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "transformation": { "select_id": 2, "from": "IN (SELECT)", - "to": "materialization", - "sjm_scan_allowed": true, - "possible": true - } - }, - { - "transformation": { - "select_id": 2, - "from": "IN (SELECT)", "to": "semijoin", "chosen": true } @@ -4859,15 +4852,6 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "transformation": { "select_id": 3, "from": "IN (SELECT)", - "to": "materialization", - "sjm_scan_allowed": true, - "possible": true - } - }, - { - "transformation": { - "select_id": 3, - "from": "IN (SELECT)", "to": "semijoin", "chosen": true } @@ -4892,6 +4876,15 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "transformation": { "select_id": 2, "from": "IN (SELECT)", + "to": "materialization", + "sjm_scan_allowed": true, + "possible": true + } + }, + { + "transformation": { + "select_id": 2, + "from": "IN (SELECT)", "to": "semijoin", "converted_to_semi_join": true } @@ -4900,6 +4893,15 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "transformation": { "select_id": 3, "from": "IN (SELECT)", + "to": "materialization", + "sjm_scan_allowed": true, + "possible": true + } + }, + { + "transformation": { + "select_id": 3, + "from": "IN (SELECT)", "to": "semijoin", "converted_to_semi_join": true } @@ -6406,15 +6408,6 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "transformation": { "select_id": 2, "from": "IN (SELECT)", - "to": "materialization", - "sjm_scan_allowed": true, - "possible": true - } - }, - { - "transformation": { - "select_id": 2, - "from": "IN (SELECT)", "to": "semijoin", "chosen": true } @@ -6433,15 +6426,6 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "transformation": { "select_id": 3, "from": "IN (SELECT)", - "to": "materialization", - "sjm_scan_allowed": true, - "possible": true - } - }, - { - "transformation": { - "select_id": 3, - "from": "IN (SELECT)", "to": "semijoin", "chosen": true } @@ -6466,6 +6450,15 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "transformation": { "select_id": 2, "from": "IN (SELECT)", + "to": "materialization", + "sjm_scan_allowed": true, + "possible": true + } + }, + { + "transformation": { + "select_id": 2, + "from": "IN (SELECT)", "to": "semijoin", "converted_to_semi_join": true } @@ -6474,6 +6467,15 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { "transformation": { "select_id": 3, "from": "IN (SELECT)", + "to": "materialization", + "sjm_scan_allowed": true, + "possible": true + } + }, + { + "transformation": { + "select_id": 3, + "from": "IN (SELECT)", "to": "semijoin", "converted_to_semi_join": true } @@ -7898,17 +7900,21 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["start_date"], - "key": "start_date", - "key_length": "8", - "used_key_parts": ["start_date", "end_date"], - "rows": 1000, - "filtered": 100, - "index_condition": "t1.start_date >= '2019-02-10' and t1.end_date < '2019-04-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["start_date"], + "key": "start_date", + "key_length": "8", + "used_key_parts": ["start_date", "end_date"], + "rows": 1000, + "filtered": 100, + "index_condition": "t1.start_date >= '2019-02-10' and t1.end_date < '2019-04-01'" + } + } + ] } } select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; @@ -7984,20 +7990,20 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [ { "access_type": "scan", - "resulting_rows": 5.9375, - "cost": 2.829589844, + "resulting_rows": 5, + "cost": 3.017089844, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records": 5.9375, - "cost": 2.829589844, + "records": 5, + "cost": 3.017089844, "uses_join_buffering": false } }, - "rows_for_plan": 5.9375, + "rows_for_plan": 5, "cost_for_plan": 4.017089844, "rest_of_plan": [ @@ -8011,21 +8017,21 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [ { "access_type": "scan", - "resulting_rows": 804.6875, - "cost": 256.8548584, + "resulting_rows": 800, + "cost": 220.9863281, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records": 804.6875, - "cost": 256.8548584, + "records": 800, + "cost": 220.9863281, "uses_join_buffering": false } }, - "rows_for_plan": 4777.832031, - "cost_for_plan": 1216.438354 + "rows_for_plan": 4000, + "cost_for_plan": 1025.003418 } ] }, @@ -8039,20 +8045,20 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [ { "access_type": "scan", - "resulting_rows": 804.6875, - "cost": 43.25976562, + "resulting_rows": 800, + "cost": 44.19726562, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records": 804.6875, - "cost": 43.25976562, + "records": 800, + "cost": 44.19726562, "uses_join_buffering": false } }, - "rows_for_plan": 804.6875, + "rows_for_plan": 800, "cost_for_plan": 204.1972656, "pruned_by_heuristic": true } @@ -8107,7 +8113,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "access_type": "ref", "index": "b", "used_range_estimates": false, - "cause": "not available", + "reason": "not available", "rowid_filter_skipped": "cost_factor <= 0", "rows": 1, "cost": 20.00585794, @@ -8115,8 +8121,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) }, { "access_type": "scan", - "resulting_rows": 804.6875, - "cost": 43.25976562, + "resulting_rows": 800, + "cost": 44.19726562, "chosen": false } ], @@ -8130,8 +8136,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) }, "rows_for_plan": 10, "cost_for_plan": 26.02294779, - "selectivity": 0.8046875, - "estimated_join_cardinality": 8.046875 + "selectivity": 0.8, + "estimated_join_cardinality": 8 } ] }, @@ -8145,20 +8151,20 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) [ { "access_type": "scan", - "resulting_rows": 804.6875, - "cost": 43.25976562, + "resulting_rows": 800, + "cost": 44.19726562, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records": 804.6875, - "cost": 43.25976562, + "records": 800, + "cost": 44.19726562, "uses_join_buffering": false } }, - "rows_for_plan": 804.6875, + "rows_for_plan": 800, "cost_for_plan": 204.1972656, "pruned_by_cost": true } @@ -8310,7 +8316,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "access_type": "ref", "index": "a", "used_range_estimates": false, - "cause": "not available", + "reason": "not available", "rowid_filter_skipped": "cost_factor <= 0", "rows": 1, "cost": 20.00585794, @@ -8378,7 +8384,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "access_type": "ref", "index": "a", "used_range_estimates": false, - "cause": "not available", + "reason": "not available", "rowid_filter_skipped": "cost_factor <= 0", "rows": 1, "cost": 200.0585794, @@ -8421,7 +8427,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN EXTENDED SELECT * from t1 WHERE a between 1 and 5 and b <= 5; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 100 0.22 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 0.25 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` between 1 and 5 and `test`.`t1`.`b` <= 5 select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; @@ -8432,19 +8438,19 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) "column_name": "a", "ranges": ["1 <= a <= 5"], - "selectivity_from_histogram": 0.046875 + "selectivity_from_histogram": 0.05 }, { "column_name": "b", "ranges": ["NULL < b <= 5"], - "selectivity_from_histogram": 0.046875 + "selectivity_from_histogram": 0.05 } ] ] EXPLAIN EXTENDED SELECT * from t1 WHERE a != 5; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 99.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` <> 5 select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; @@ -8458,13 +8464,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) "NULL < a < 5", "5 < a" ], - "selectivity_from_histogram": 1 + "selectivity_from_histogram": 0.99 } ] ] EXPLAIN EXTENDED SELECT * from t1 WHERE b >= 10 and b < 25; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 100 15.62 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 15.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` >= 10 and `test`.`t1`.`b` < 25 select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; @@ -8475,7 +8481,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) "column_name": "b", "ranges": ["10 <= b < 25"], - "selectivity_from_histogram": 0.15625 + "selectivity_from_histogram": 0.15 } ] ] @@ -8728,16 +8734,6 @@ json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) { "select_id": 2, "from": "IN (SELECT)", - "to": "materialization", - "sjm_scan_allowed": true, - "possible": true - } - }, - { - "transformation": - { - "select_id": 2, - "from": "IN (SELECT)", "to": "semijoin", "chosen": true } @@ -8998,7 +8994,7 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) "access_type": "ref", "index": "idx_a", "used_range_estimates": false, - "cause": "not available", + "reason": "not available", "rows": 1.8367, "cost": 2.000585794, "chosen": true diff --git a/mysql-test/main/opt_trace_ucs2.result b/mysql-test/main/opt_trace_ucs2.result index 8eb3ec521fa..9e4f25f3150 100644 --- a/mysql-test/main/opt_trace_ucs2.result +++ b/mysql-test/main/opt_trace_ucs2.result @@ -7,17 +7,21 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["col1"], - "key": "col1", - "key_length": "21", - "used_key_parts": ["col1"], - "rows": 2, - "filtered": 100, - "index_condition": "t1.col1 >= 'a'" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["col1"], + "key": "col1", + "key_length": "21", + "used_key_parts": ["col1"], + "rows": 2, + "filtered": 100, + "index_condition": "t1.col1 >= 'a'" + } + } + ] } } select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result index 5f56201af9c..b6345cd142e 100644 --- a/mysql-test/main/order_by.result +++ b/mysql-test/main/order_by.result @@ -1,5 +1,4 @@ call mtr.add_suppression("Sort aborted.*"); -drop table if exists t1,t2,t3; call mtr.add_suppression("Out of sort memory; increase server sort buffer size"); CREATE TABLE t1 ( id int(6) DEFAULT '0' NOT NULL, @@ -3401,30 +3400,34 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "read_sorted_file": { - "r_rows": 5, - "filesort": { - "sort_key": "t1.a", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "r_limit": 5, - "r_used_priority_queue": false, - "r_output_rows": 100, - "r_buffer_size": "REPLACED", - "r_sort_mode": "sort_key,packed_addon_fields", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 100, - "r_rows": 100, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "nested_loop": [ + { + "read_sorted_file": { + "r_rows": 5, + "filesort": { + "sort_key": "t1.a", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_limit": 5, + "r_used_priority_queue": false, + "r_output_rows": 100, + "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,packed_addon_fields", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 100, + "r_rows": 100, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } } } - } + ] } } SELECT * FROM t1 ORDER BY a LIMIT 5; @@ -3751,29 +3754,33 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "read_sorted_file": { - "r_rows": 100, - "filesort": { - "sort_key": "t1.a, t1.b, t1.c", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "r_used_priority_queue": false, - "r_output_rows": 100, - "r_buffer_size": "REPLACED", - "r_sort_mode": "sort_key,packed_addon_fields", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 100, + "nested_loop": [ + { + "read_sorted_file": { "r_rows": 100, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "filesort": { + "sort_key": "t1.a, t1.b, t1.c", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 100, + "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,packed_addon_fields", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 100, + "r_rows": 100, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } } } - } + ] } } select * from t1 order by a,b,c; @@ -3910,29 +3917,33 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "read_sorted_file": { - "r_rows": 5, - "filesort": { - "sort_key": "t1.b desc", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "r_used_priority_queue": false, - "r_output_rows": 5, - "r_buffer_size": "REPLACED", - "r_sort_mode": "packed_sort_key,rowid", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 5, + "nested_loop": [ + { + "read_sorted_file": { "r_rows": 5, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "filesort": { + "sort_key": "t1.b desc", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 5, + "r_buffer_size": "REPLACED", + "r_sort_mode": "packed_sort_key,rowid", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 5, + "r_rows": 5, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } } } - } + ] } } drop table t1; @@ -3952,29 +3963,33 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "read_sorted_file": { - "r_rows": 6, - "filesort": { - "sort_key": "t1.a, t1.b", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "r_used_priority_queue": false, - "r_output_rows": 6, - "r_buffer_size": "REPLACED", - "r_sort_mode": "packed_sort_key,rowid", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 6, + "nested_loop": [ + { + "read_sorted_file": { "r_rows": 6, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "filesort": { + "sort_key": "t1.a, t1.b", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 6, + "r_buffer_size": "REPLACED", + "r_sort_mode": "packed_sort_key,rowid", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 6, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } } } - } + ] } } select a, b, c from t1 order by a, b; @@ -4000,29 +4015,33 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "read_sorted_file": { - "r_rows": 6, - "filesort": { - "sort_key": "t1.a, t1.b", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "r_used_priority_queue": false, - "r_output_rows": 6, - "r_buffer_size": "REPLACED", - "r_sort_mode": "sort_key,packed_addon_fields", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 6, + "nested_loop": [ + { + "read_sorted_file": { "r_rows": 6, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "filesort": { + "sort_key": "t1.a, t1.b", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 6, + "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,packed_addon_fields", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 6, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } } } - } + ] } } select a, b, c from t1 order by a, b; @@ -4062,29 +4081,33 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "read_sorted_file": { - "r_rows": 10, - "filesort": { - "sort_key": "t1.a", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "r_used_priority_queue": false, - "r_output_rows": 10, - "r_buffer_size": "REPLACED", - "r_sort_mode": "packed_sort_key,packed_addon_fields", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 10, + "nested_loop": [ + { + "read_sorted_file": { "r_rows": 10, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "filesort": { + "sort_key": "t1.a", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 10, + "r_buffer_size": "REPLACED", + "r_sort_mode": "packed_sort_key,packed_addon_fields", + "table": { + "table_name": "t1", + "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 + } + } } } - } + ] } } drop table t1; @@ -4237,17 +4260,21 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 50, - "r_rows": 50, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 50, + "r_rows": 50, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ], "subqueries": [ { "expression_cache": { @@ -4266,18 +4293,22 @@ ANALYZE "r_buffer_size": "REPLACED" across executions)", "r_sort_mode": "sort_key,rowid", "temporary_table": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 50, - "rows": 50, - "r_rows": 50, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 2, - "attached_condition": "t1.b = t2.b" - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 50, + "rows": 50, + "r_rows": 50, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 2, + "attached_condition": "t1.b = t2.b" + } + } + ] } } } @@ -4367,43 +4398,53 @@ EXPLAIN { "query_block": { "select_id": 1, - "read_sorted_file": { - "filesort": { - "sort_key": "t1.a desc", - "table": { - "table_name": "<subquery2>", - "access_type": "ALL", - "possible_keys": ["distinct_key"], - "rows": 3, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t2.b = 3 and t2.a is not null" + "nested_loop": [ + { + "read_sorted_file": { + "filesort": { + "sort_key": "t1.a desc", + "table": { + "table_name": "<subquery2>", + "access_type": "ALL", + "possible_keys": ["distinct_key"], + "rows": 3, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t2.b = 3 and t2.a is not null" + } + } + ] + } } } } } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 1, + "filtered": 100, + "using_index": true + } } - }, - "table": { - "table_name": "t1", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 1, - "filtered": 100, - "using_index": true - } + ] } } SELECT t1.a @@ -4430,42 +4471,52 @@ EXPLAIN { "query_block": { "select_id": 1, - "read_sorted_file": { - "filesort": { - "sort_key": "t1.a desc", - "table": { - "table_name": "<subquery2>", - "access_type": "ALL", - "possible_keys": ["distinct_key"], - "rows": 3, - "filtered": 100, - "materialized": { - "unique": 1, - "query_block": { - "select_id": 2, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 3, - "filtered": 100, - "attached_condition": "t2.b = 3 and t2.a is not null" + "nested_loop": [ + { + "read_sorted_file": { + "filesort": { + "sort_key": "t1.a desc", + "table": { + "table_name": "<subquery2>", + "access_type": "ALL", + "possible_keys": ["distinct_key"], + "rows": 3, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t2.b = 3 and t2.a is not null" + } + } + ] + } } } } } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["a"], + "ref": ["test.t2.a"], + "rows": 1, + "filtered": 100 + } } - }, - "table": { - "table_name": "t1", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["a"], - "ref": ["test.t2.a"], - "rows": 1, - "filtered": 100 - } + ] } } SELECT t1.a, group_concat(t1.b) @@ -4478,3 +4529,38 @@ a group_concat(t1.b) 58 1 DROP TABLE t1, t2; # End of 10.6 tests +# +# MDEV-13756 Implement descending index: KEY (a DESC, b ASC) +# +create table t1 (a int, b int, c int, key r (a desc, b asc)); +insert t1 select seq % 10, seq div 10, seq from seq_1_to_55; +insert t1 values (NULL, NULL, NULL), (9, NULL, NULL); +explain select * from t1 force index(r) order by a,b limit 20; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 57 Using filesort +explain select * from t1 force index(r) order by a desc,b limit 20; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL r 10 NULL 20 +select * from t1 force index(r) order by a desc,b limit 20; +a b c +9 NULL NULL +9 0 9 +9 1 19 +9 2 29 +9 3 39 +9 4 49 +8 0 8 +8 1 18 +8 2 28 +8 3 38 +8 4 48 +7 0 7 +7 1 17 +7 2 27 +7 3 37 +7 4 47 +6 0 6 +6 1 16 +6 2 26 +6 3 36 +drop table t1; diff --git a/mysql-test/main/order_by.test b/mysql-test/main/order_by.test index fee2880bac9..1cd9efa2710 100644 --- a/mysql-test/main/order_by.test +++ b/mysql-test/main/order_by.test @@ -9,11 +9,6 @@ --source include/no_view_protocol.inc call mtr.add_suppression("Sort aborted.*"); - ---disable_warnings -drop table if exists t1,t2,t3; ---enable_warnings - call mtr.add_suppression("Out of sort memory; increase server sort buffer size"); --source include/have_sequence.inc @@ -21,8 +16,6 @@ call mtr.add_suppression("Out of sort memory; increase server sort buffer size") # Test old ORDER BY bug # ---source include/have_sequence.inc - CREATE TABLE t1 ( id int(6) DEFAULT '0' NOT NULL, idservice int(5), @@ -2703,3 +2696,14 @@ eval $query; DROP TABLE t1, t2; --echo # End of 10.6 tests + +--echo # +--echo # MDEV-13756 Implement descending index: KEY (a DESC, b ASC) +--echo # +create table t1 (a int, b int, c int, key r (a desc, b asc)); +insert t1 select seq % 10, seq div 10, seq from seq_1_to_55; +insert t1 values (NULL, NULL, NULL), (9, NULL, NULL); +explain select * from t1 force index(r) order by a,b limit 20; +explain select * from t1 force index(r) order by a desc,b limit 20; + select * from t1 force index(r) order by a desc,b limit 20; +drop table t1; diff --git a/mysql-test/main/order_by_innodb.result b/mysql-test/main/order_by_innodb.result index 1d96a62e423..741084c8a6c 100644 --- a/mysql-test/main/order_by_innodb.result +++ b/mysql-test/main/order_by_innodb.result @@ -176,7 +176,7 @@ id id 1 NULL 2 1 3 3 -create index for_latest_sort on t2 (d1 desc, d2 desc, id desc); +create index for_latest_sort on t2 (d1, d2, id); select t1.id,t2.id from @@ -194,6 +194,36 @@ id id 1 NULL 2 1 3 3 +# Now, same as above but use a DESC index +CREATE TABLE t3 ( +id int NOT NULL PRIMARY KEY, +id2 int NOT NULL, +d1 datetime, +d2 timestamp NOT NULL, +KEY id2 (id2) +) engine=innodb; +insert into t3 values +(1,2,'2019-03-05 00:00:00','2019-03-06 00:00:00'), +(2,3,'2019-03-05 00:00:00','2019-03-06 00:00:00'), +(3,3,'2019-03-06 00:00:00','2019-03-05 00:00:00'); +create index for_latest_sort on t3 (d1 desc, d2 desc, id desc); +select +t1.id,t3.id +from +t1 left join +t3 on t3.id2 = t1.id and +t3.id = (select dd.id +from t3 dd +where +dd.id2 = t1.id and +d1 > '2019-02-06 00:00:00' + order by +dd.d1 desc, dd.d2 desc, dd.id desc limit 1 +); +id id +1 NULL +2 1 +3 3 # # MDEV-27270: Wrong query plan with Range Checked for Each Record and ORDER BY ... LIMIT # @@ -217,5 +247,40 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL PRIMARY 4 NULL # Using index 1 PRIMARY t2 eq_ref PRIMARY,id2 PRIMARY 4 func # Using where 2 DEPENDENT SUBQUERY dd range id2,for_latest_sort for_latest_sort 6 NULL # Using where -drop table t1,t2; +drop table t1,t2,t3; # End of 10.2 tests +# +# MDEV-26938 Support descending indexes internally in InnoDB +# +create table t1 (a int, b int, c int, key r (a desc, b asc)); +insert t1 select seq % 10, seq div 10, seq from seq_1_to_55; +insert t1 values (NULL, NULL, NULL), (9, NULL, NULL); +explain select * from t1 force index(r) order by a,b limit 20; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 57 Using filesort +explain select * from t1 force index(r) order by a desc,b limit 20; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL r 10 NULL 20 +select * from t1 force index(r) order by a desc,b limit 20; +a b c +9 NULL NULL +9 0 9 +9 1 19 +9 2 29 +9 3 39 +9 4 49 +8 0 8 +8 1 18 +8 2 28 +8 3 38 +8 4 48 +7 0 7 +7 1 17 +7 2 27 +7 3 37 +7 4 47 +6 0 6 +6 1 16 +6 2 26 +6 3 36 +drop table t1; diff --git a/mysql-test/main/order_by_innodb.test b/mysql-test/main/order_by_innodb.test index fbff825e26e..bdaef56672f 100644 --- a/mysql-test/main/order_by_innodb.test +++ b/mysql-test/main/order_by_innodb.test @@ -162,7 +162,7 @@ from dd.d1 desc, dd.d2 desc, dd.id desc limit 1 ); -create index for_latest_sort on t2 (d1 desc, d2 desc, id desc); +create index for_latest_sort on t2 (d1, d2, id); select t1.id,t2.id @@ -178,6 +178,38 @@ from dd.d1 desc, dd.d2 desc, dd.id desc limit 1 ); +--echo # Now, same as above but use a DESC index + +CREATE TABLE t3 ( + id int NOT NULL PRIMARY KEY, + id2 int NOT NULL, + d1 datetime, + d2 timestamp NOT NULL, + KEY id2 (id2) +) engine=innodb; + +insert into t3 values + (1,2,'2019-03-05 00:00:00','2019-03-06 00:00:00'), + (2,3,'2019-03-05 00:00:00','2019-03-06 00:00:00'), + (3,3,'2019-03-06 00:00:00','2019-03-05 00:00:00'); +create index for_latest_sort on t3 (d1 desc, d2 desc, id desc); + + +select + t1.id,t3.id +from + t1 left join + t3 on t3.id2 = t1.id and + t3.id = (select dd.id + from t3 dd + where + dd.id2 = t1.id and + d1 > '2019-02-06 00:00:00' + order by + dd.d1 desc, dd.d2 desc, dd.id desc limit 1 + ); + + --echo # --echo # MDEV-27270: Wrong query plan with Range Checked for Each Record and ORDER BY ... LIMIT --echo # @@ -199,6 +231,18 @@ from order by dd.d1, dd.d2, dd.id limit 1 ); -drop table t1,t2; + +drop table t1,t2,t3; --echo # End of 10.2 tests + +--echo # +--echo # MDEV-26938 Support descending indexes internally in InnoDB +--echo # +create table t1 (a int, b int, c int, key r (a desc, b asc)); +insert t1 select seq % 10, seq div 10, seq from seq_1_to_55; +insert t1 values (NULL, NULL, NULL), (9, NULL, NULL); +explain select * from t1 force index(r) order by a,b limit 20; +explain select * from t1 force index(r) order by a desc,b limit 20; + select * from t1 force index(r) order by a desc,b limit 20; +drop table t1; diff --git a/mysql-test/main/order_by_pack_big.result b/mysql-test/main/order_by_pack_big.result index a7cf2436bcc..e34b1a4a90a 100644 --- a/mysql-test/main/order_by_pack_big.result +++ b/mysql-test/main/order_by_pack_big.result @@ -93,29 +93,33 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "read_sorted_file": { - "r_rows": 10000, - "filesort": { - "sort_key": "t3.`id` DIV 100", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "r_used_priority_queue": false, - "r_output_rows": 10000, - "r_buffer_size": "REPLACED", - "r_sort_mode": "sort_key,packed_addon_fields", - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 10000, + "nested_loop": [ + { + "read_sorted_file": { "r_rows": 10000, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "filesort": { + "sort_key": "t3.`id` DIV 100", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 10000, + "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,packed_addon_fields", + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 10000, + "r_rows": 10000, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } } } - } + ] } } flush status; @@ -250,30 +254,34 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "read_sorted_file": { - "r_rows": 10000, - "filesort": { - "sort_key": "t3.`id` DIV 100", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "r_used_priority_queue": false, - "r_output_rows": 10000, - "r_sort_passes": 4, - "r_buffer_size": "REPLACED", - "r_sort_mode": "sort_key,packed_addon_fields", - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 10000, + "nested_loop": [ + { + "read_sorted_file": { "r_rows": 10000, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "filesort": { + "sort_key": "t3.`id` DIV 100", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 10000, + "r_sort_passes": 4, + "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,packed_addon_fields", + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 10000, + "r_rows": 10000, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } } } - } + ] } } flush status; @@ -405,29 +413,33 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "read_sorted_file": { - "r_rows": 10000, - "filesort": { - "sort_key": "t3.`names`, t3.address", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "r_used_priority_queue": false, - "r_output_rows": 10000, - "r_buffer_size": "REPLACED", - "r_sort_mode": "packed_sort_key,packed_addon_fields", - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 10000, + "nested_loop": [ + { + "read_sorted_file": { "r_rows": 10000, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "filesort": { + "sort_key": "t3.`names`, t3.address", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 10000, + "r_buffer_size": "REPLACED", + "r_sort_mode": "packed_sort_key,packed_addon_fields", + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 10000, + "r_rows": 10000, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } } } - } + ] } } flush status; @@ -454,29 +466,33 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "read_sorted_file": { - "r_rows": 10000, - "filesort": { - "sort_key": "t3.`names`, t3.address", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "r_used_priority_queue": false, - "r_output_rows": 10000, - "r_buffer_size": "REPLACED", - "r_sort_mode": "packed_sort_key,rowid", - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 10000, + "nested_loop": [ + { + "read_sorted_file": { "r_rows": 10000, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 + "filesort": { + "sort_key": "t3.`names`, t3.address", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 10000, + "r_buffer_size": "REPLACED", + "r_sort_mode": "packed_sort_key,rowid", + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 10000, + "r_rows": 10000, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } } } - } + ] } } flush status; diff --git a/mysql-test/main/partition.result b/mysql-test/main/partition.result index ac759239de6..0d37d4cb168 100644 --- a/mysql-test/main/partition.result +++ b/mysql-test/main/partition.result @@ -2741,7 +2741,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t2 p1,p2 ALL NULL NULL NULL NULL 400 Using where explain extended select * from t2 where b=5; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 19.61 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 0.10 Using where Warnings: Note 1003 select `test`.`t2`.`part_key` AS `part_key`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where `test`.`t2`.`b` = 5 explain partitions select * from t2 where b=5; @@ -2749,7 +2749,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t2 p0,p1,p2,p3,p4 ALL NULL NULL NULL NULL 1000 Using where explain extended select * from t2 partition(p0) where b=1; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 200 19.61 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 200 20.00 Using where Warnings: Note 1003 select `test`.`t2`.`part_key` AS `part_key`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` PARTITION (`p0`) where `test`.`t2`.`b` = 1 set @@use_stat_tables= @save_use_stat_tables; diff --git a/mysql-test/main/partition_error.result b/mysql-test/main/partition_error.result index ba3957bedfd..0b07fe30130 100644 --- a/mysql-test/main/partition_error.result +++ b/mysql-test/main/partition_error.result @@ -907,7 +907,7 @@ partitions 3 (partition tablespace ts1, partition x2 tablespace ts2, partition x3 tablespace ts3); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ts1, +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' partition x2 tablespace ts2, partition x3 tablespace ts3)' at line 8 CREATE TABLE t1 ( diff --git a/mysql-test/main/partition_exchange.result b/mysql-test/main/partition_exchange.result index 5a3d7330d96..b7c9be3480e 100644 --- a/mysql-test/main/partition_exchange.result +++ b/mysql-test/main/partition_exchange.result @@ -1,4 +1,3 @@ -DROP TABLE IF EXISTS t1, t2, t3, t, tp, tsp, tmp; # # Bug#11894100: EXCHANGE PARTITION CAN'T BE EXECUTED IF # ROW_FORMAT WAS SET EXPLICITLY @@ -6,25 +5,19 @@ DROP TABLE IF EXISTS t1, t2, t3, t, tp, tsp, tmp; # Same definition (both have ROW_FORMAT set) CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, -year year(2) DEFAULT NULL, +year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB ROW_FORMAT=COMPACT PARTITION BY HASH (id) PARTITIONS 2; -Warnings: -Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead CREATE TABLE t2 LIKE t1; -Warnings: -Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead ALTER TABLE t2 REMOVE PARTITIONING; -Warnings: -Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead SHOW CREATE TABLE t1; Table t1 Create Table CREATE TABLE `t1` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=COMPACT @@ -34,7 +27,7 @@ SHOW CREATE TABLE t2; Table t2 Create Table CREATE TABLE `t2` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=COMPACT @@ -53,15 +46,11 @@ ENGINE InnoDB ROW_FORMAT Compact CREATE_OPTIONS row_format=COMPACT ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead SHOW CREATE TABLE t1; Table t1 Create Table CREATE TABLE `t1` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=COMPACT @@ -71,7 +60,7 @@ SHOW CREATE TABLE t2; Table t2 Create Table CREATE TABLE `t2` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=COMPACT @@ -93,24 +82,16 @@ DROP TABLE t2; # Only the partitioned table have ROW_FORMAT set. CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, -year year(2) DEFAULT NULL, +year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead SHOW CREATE TABLE t1; Table t1 Create Table CREATE TABLE `t1` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=COMPACT @@ -120,7 +101,7 @@ SHOW CREATE TABLE t2; Table t2 Create Table CREATE TABLE `t2` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci @@ -142,36 +123,24 @@ CREATE_OPTIONS DROP TABLE t1, t2; CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, -year year(2) DEFAULT NULL, +year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB PARTITION BY HASH (id) PARTITIONS 2; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, -year year(2) DEFAULT NULL, +year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB ROW_FORMAT = COMPACT; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead SHOW CREATE TABLE t1; Table t1 Create Table CREATE TABLE `t1` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci @@ -181,7 +150,7 @@ SHOW CREATE TABLE t2; Table t2 Create Table CREATE TABLE `t2` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=COMPACT @@ -203,36 +172,24 @@ CREATE_OPTIONS row_format=COMPACT DROP TABLE t1, t2; CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, -year year(2) DEFAULT NULL, +year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB PARTITION BY HASH (id) PARTITIONS 2; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, -year year(2) DEFAULT NULL, +year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead SHOW CREATE TABLE t1; Table t1 Create Table CREATE TABLE `t1` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci @@ -242,7 +199,7 @@ SHOW CREATE TABLE t2; Table t2 Create Table CREATE TABLE `t2` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci @@ -264,36 +221,24 @@ CREATE_OPTIONS DROP TABLE t1, t2; CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, -year year(2) DEFAULT NULL, +year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB ROW_FORMAT = REDUNDANT PARTITION BY HASH (id) PARTITIONS 2; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, -year year(2) DEFAULT NULL, +year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB ROW_FORMAT = REDUNDANT; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead SHOW CREATE TABLE t1; Table t1 Create Table CREATE TABLE `t1` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=REDUNDANT @@ -303,7 +248,7 @@ SHOW CREATE TABLE t2; Table t2 Create Table CREATE TABLE `t2` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=REDUNDANT @@ -325,33 +270,25 @@ CREATE_OPTIONS row_format=REDUNDANT DROP TABLE t1, t2; CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, -year year(2) DEFAULT NULL, +year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB PARTITION BY HASH (id) PARTITIONS 2; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, -year year(2) DEFAULT NULL, +year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB ROW_FORMAT = REDUNDANT; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2; ERROR HY000: Non matching attribute 'ROW_FORMAT' between partition and table SHOW CREATE TABLE t1; Table t1 Create Table CREATE TABLE `t1` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci @@ -361,7 +298,7 @@ SHOW CREATE TABLE t2; Table t2 Create Table CREATE TABLE `t2` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=REDUNDANT @@ -383,33 +320,25 @@ CREATE_OPTIONS row_format=REDUNDANT DROP TABLE t1, t2; CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, -year year(2) DEFAULT NULL, +year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB ROW_FORMAT = COMPACT PARTITION BY HASH (id) PARTITIONS 2; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, -year year(2) DEFAULT NULL, +year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB ROW_FORMAT = REDUNDANT; -Warnings: -Level Note -Code 1287 -Message 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2; ERROR HY000: Non matching attribute 'ROW_FORMAT' between partition and table SHOW CREATE TABLE t1; Table t1 Create Table CREATE TABLE `t1` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=COMPACT @@ -419,7 +348,7 @@ SHOW CREATE TABLE t2; Table t2 Create Table CREATE TABLE `t2` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `year` year(2) DEFAULT NULL, + `year` year(4) DEFAULT NULL, `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=REDUNDANT @@ -1320,3 +1249,14 @@ CREATE TABLE t2 (a INT, PRIMARY KEY(a)) CHECKSUM=1, ENGINE=InnoDB; ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; ERROR HY000: Tables have different definitions DROP TABLE t1, t2; +# +# MDEV-27683 EXCHANGE PARTITION allows different index direction, but causes further errors +# +CREATE TABLE t1 (a INT, KEY(a DESC)) PARTITION BY KEY(a) PARTITIONS 4; +CREATE TABLE t2 (a INT, KEY(a)); +ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; +ERROR HY000: Tables have different definitions +DROP TABLE t1, t2; +# +# End of 10.8 tests +# diff --git a/mysql-test/main/partition_exchange.test b/mysql-test/main/partition_exchange.test index 8e0be49b5ab..82ccc29e00e 100644 --- a/mysql-test/main/partition_exchange.test +++ b/mysql-test/main/partition_exchange.test @@ -1,11 +1,6 @@ --source include/have_innodb.inc --source include/have_partition.inc ---disable_warnings -DROP TABLE IF EXISTS t1, t2, t3, t, tp, tsp, tmp; ---enable_warnings - ---enable_prepare_warnings --echo # --echo # Bug#11894100: EXCHANGE PARTITION CAN'T BE EXECUTED IF --echo # ROW_FORMAT WAS SET EXPLICITLY @@ -14,7 +9,7 @@ DROP TABLE IF EXISTS t1, t2, t3, t, tp, tsp, tmp; --echo # Same definition (both have ROW_FORMAT set) CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, - year year(2) DEFAULT NULL, + year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB ROW_FORMAT=COMPACT @@ -46,7 +41,7 @@ DROP TABLE t2; --echo # Only the partitioned table have ROW_FORMAT set. CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, - year year(2) DEFAULT NULL, + year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB; @@ -63,7 +58,7 @@ ORDER BY TABLE_NAME; DROP TABLE t1, t2; CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, - year year(2) DEFAULT NULL, + year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB @@ -71,7 +66,7 @@ PARTITION BY HASH (id) PARTITIONS 2; CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, - year year(2) DEFAULT NULL, + year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB ROW_FORMAT = COMPACT; @@ -88,7 +83,7 @@ ORDER BY TABLE_NAME; DROP TABLE t1, t2; CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, - year year(2) DEFAULT NULL, + year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB @@ -96,7 +91,7 @@ PARTITION BY HASH (id) PARTITIONS 2; CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, - year year(2) DEFAULT NULL, + year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB; @@ -113,7 +108,7 @@ ORDER BY TABLE_NAME; DROP TABLE t1, t2; CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, - year year(2) DEFAULT NULL, + year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB ROW_FORMAT = REDUNDANT @@ -121,7 +116,7 @@ PARTITION BY HASH (id) PARTITIONS 2; CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, - year year(2) DEFAULT NULL, + year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB ROW_FORMAT = REDUNDANT; @@ -138,7 +133,7 @@ ORDER BY TABLE_NAME; DROP TABLE t1, t2; CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, - year year(2) DEFAULT NULL, + year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB @@ -146,7 +141,7 @@ PARTITION BY HASH (id) PARTITIONS 2; CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, - year year(2) DEFAULT NULL, + year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB ROW_FORMAT = REDUNDANT; @@ -164,7 +159,7 @@ ORDER BY TABLE_NAME; DROP TABLE t1, t2; CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, - year year(2) DEFAULT NULL, + year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB ROW_FORMAT = COMPACT @@ -172,7 +167,7 @@ PARTITION BY HASH (id) PARTITIONS 2; CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, - year year(2) DEFAULT NULL, + year year DEFAULT NULL, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) ) ENGINE=InnoDB ROW_FORMAT = REDUNDANT; @@ -556,4 +551,15 @@ ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; # Cleanup DROP TABLE t1, t2; ---disable_prepare_warnings +--echo # +--echo # MDEV-27683 EXCHANGE PARTITION allows different index direction, but causes further errors +--echo # +CREATE TABLE t1 (a INT, KEY(a DESC)) PARTITION BY KEY(a) PARTITIONS 4; +CREATE TABLE t2 (a INT, KEY(a)); +--error ER_TABLES_DIFFERENT_METADATA +ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; +DROP TABLE t1, t2; + +--echo # +--echo # End of 10.8 tests +--echo # diff --git a/mysql-test/main/partition_order.result b/mysql-test/main/partition_order.result index cecfc90eefb..d4a0c133d10 100644 --- a/mysql-test/main/partition_order.result +++ b/mysql-test/main/partition_order.result @@ -1,4 +1,3 @@ -drop table if exists t1; CREATE TABLE t1 ( a int not null, b int not null, @@ -783,3 +782,17 @@ a b c 1 1 1 1 NULL NULL drop table t1; +# +# MDEV-13756 Implement descending index: KEY (a DESC, b ASC) +# +create table t1 (a int, b int, key(a desc)) partition by hash(a) partitions 4; +insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6); +explain select * from t1 order by a limit 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 5 NULL 3 +select * from t1 order by a limit 3; +a b +1 1 +2 2 +3 3 +drop table t1; diff --git a/mysql-test/main/partition_order.test b/mysql-test/main/partition_order.test index ad956361d00..f5cd4c25074 100644 --- a/mysql-test/main/partition_order.test +++ b/mysql-test/main/partition_order.test @@ -1,14 +1,9 @@ -#--disable_abort_on_error # # Simple test for the partition storage engine # Focuses on tests of ordered index read # -- source include/have_partition.inc ---disable_warnings -drop table if exists t1; ---enable_warnings - # # Ordered index read, int type # @@ -842,3 +837,12 @@ INSERT into t1 values (1, NULL, NULL), (2, NULL, '10'); select * from t1 where a = 1 order by a desc, b desc; select * from t1 where a = 1 order by b desc; drop table t1; + +--echo # +--echo # MDEV-13756 Implement descending index: KEY (a DESC, b ASC) +--echo # +create table t1 (a int, b int, key(a desc)) partition by hash(a) partitions 4; +insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6); +explain select * from t1 order by a limit 3; +select * from t1 order by a limit 3; +drop table t1; diff --git a/mysql-test/main/range.result b/mysql-test/main/range.result index 31777773240..6ff4f409666 100644 --- a/mysql-test/main/range.result +++ b/mysql-test/main/range.result @@ -2412,17 +2412,21 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "10", - "used_key_parts": ["a", "b"], - "rows": 6, - "filtered": 100, - "attached_condition": "(t1.a,t1.b) in (<cache>((2,3)),<cache>((3,3)),<cache>((8,8)),<cache>((7,7)))" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "10", + "used_key_parts": ["a", "b"], + "rows": 6, + "filtered": 100, + "attached_condition": "(t1.a,t1.b) in (<cache>((2,3)),<cache>((3,3)),<cache>((8,8)),<cache>((7,7)))" + } + } + ] } } select * from t1 where (a,b) IN ((2, 3),(3,3),(8,8),(7,7)); @@ -2472,17 +2476,21 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a,t1.b + t1.a) in (<cache>((4,9)),<cache>((8,8)),<cache>((7,7)))" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a,t1.b + t1.a) in (<cache>((4,9)),<cache>((8,8)),<cache>((7,7)))" + } + } + ] } } select * from t1 where (a,b+a) IN ((4,9),(8,8),(7,7)); @@ -2498,17 +2506,21 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a,t1.b) in ((4,t1.a - 1),(8,t1.a + 8),(7,t1.a + 7))" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a,t1.b) in ((4,t1.a - 1),(8,t1.a + 8),(7,t1.a + 7))" + } + } + ] } } select * from t1 where (a,b) IN ((4,a-1),(8,a+8),(7,a+7)); @@ -2538,37 +2550,43 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "5", - "used_key_parts": ["d"], - "rowid_filter": { - "range": { - "key": "idx2", - "used_key_parts": ["e"] - }, - "rows": 12, - "selectivity_pct": 60 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": ["idx1", "idx2"], + "key": "idx1", + "key_length": "5", + "used_key_parts": ["d"], + "rowid_filter": { + "range": { + "key": "idx2", + "used_key_parts": ["e"] + }, + "rows": 12, + "selectivity_pct": 60 + }, + "rows": 3, + "filtered": 60, + "index_condition": "t2.d is not null", + "attached_condition": "(t2.d,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((2,2)))" + } }, - "rows": 3, - "filtered": 60, - "index_condition": "t2.d is not null", - "attached_condition": "(t2.d,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((2,2)))" - }, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.d"], - "rows": 8, - "filtered": 100 - } + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.d"], + "rows": 8, + "filtered": 100 + } + } + ] } } select * from t1,t2 @@ -2618,37 +2636,43 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "5", - "used_key_parts": ["d"], - "rowid_filter": { - "range": { - "key": "idx2", - "used_key_parts": ["e"] - }, - "rows": 15, - "selectivity_pct": 14.42307692 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": ["idx1", "idx2"], + "key": "idx1", + "key_length": "5", + "used_key_parts": ["d"], + "rowid_filter": { + "range": { + "key": "idx2", + "used_key_parts": ["e"] + }, + "rows": 15, + "selectivity_pct": 14.42307692 + }, + "rows": 8, + "filtered": 14.42307663, + "index_condition": "t2.d is not null", + "attached_condition": "(t2.d,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1" + } }, - "rows": 8, - "filtered": 14.42307663, - "index_condition": "t2.d is not null", - "attached_condition": "(t2.d,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1" - }, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.d"], - "rows": 8, - "filtered": 100 - } + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.d"], + "rows": 8, + "filtered": 100 + } + } + ] } } select * from t1,t2 @@ -2723,37 +2747,43 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "5", - "used_key_parts": ["d"], - "rowid_filter": { - "range": { - "key": "idx2", - "used_key_parts": ["e"] - }, - "rows": 7, - "selectivity_pct": 6.730769231 + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": ["idx1", "idx2"], + "key": "idx1", + "key_length": "5", + "used_key_parts": ["d"], + "rowid_filter": { + "range": { + "key": "idx2", + "used_key_parts": ["e"] + }, + "rows": 7, + "selectivity_pct": 6.730769231 + }, + "rows": 7, + "filtered": 6.730769157, + "index_condition": "t2.d is not null", + "attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1" + } }, - "rows": 7, - "filtered": 6.730769157, - "index_condition": "t2.d is not null", - "attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1" - }, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.d"], - "rows": 11, - "filtered": 100 - } + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.d"], + "rows": 11, + "filtered": 100 + } + } + ] } } select * from t1,t2 @@ -2781,29 +2811,35 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["idx3"], - "key": "idx3", - "key_length": "10", - "used_key_parts": ["d", "e"], - "rows": 5, - "filtered": 100, - "index_condition": "t2.d is not null", - "attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1" - }, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.d"], - "rows": 11, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": ["idx3"], + "key": "idx3", + "key_length": "10", + "used_key_parts": ["d", "e"], + "rows": 5, + "filtered": 100, + "index_condition": "t2.d is not null", + "attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.d"], + "rows": 11, + "filtered": 100 + } + } + ] } } select * from t1,t2 @@ -2830,29 +2866,35 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 15, - "filtered": 100, - "index_condition": "t1.a is not null" - }, - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["idx3"], - "key": "idx3", - "key_length": "5", - "used_key_parts": ["d"], - "ref": ["test.t1.a"], - "rows": 3, - "filtered": 100, - "attached_condition": "(t1.a,t2.e) in ((4,t1.a + 1),(7,t1.a + 1),(8,t1.a + 1)) and octet_length(t2.f) = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 15, + "filtered": 100, + "index_condition": "t1.a is not null" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["idx3"], + "key": "idx3", + "key_length": "5", + "used_key_parts": ["d"], + "ref": ["test.t1.a"], + "rows": 3, + "filtered": 100, + "attached_condition": "(t1.a,t2.e) in ((4,t1.a + 1),(7,t1.a + 1),(8,t1.a + 1)) and octet_length(t2.f) = 1" + } + } + ] } } select * from t1,t2 @@ -2887,26 +2929,32 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "possible_keys": ["idx"], - "rows": 144, - "filtered": 100, - "attached_condition": "t1.a is not null" - }, - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["idx3"], - "key": "idx3", - "key_length": "5", - "used_key_parts": ["d"], - "ref": ["test.t1.a"], - "rows": 3, - "filtered": 100, - "attached_condition": "(t1.a,t2.e) in ((t2.e,t1.a + 1),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": ["idx"], + "rows": 144, + "filtered": 100, + "attached_condition": "t1.a is not null" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["idx3"], + "key": "idx3", + "key_length": "5", + "used_key_parts": ["d"], + "ref": ["test.t1.a"], + "rows": 3, + "filtered": 100, + "attached_condition": "(t1.a,t2.e) in ((t2.e,t1.a + 1),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1" + } + } + ] } } select * from t1,t2 @@ -2935,30 +2983,36 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 12, - "filtered": 100, - "index_condition": "t1.a is not null", - "attached_condition": "(t1.a,2) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and octet_length(t1.c) = 1" - }, - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["idx3"], - "key": "idx3", - "key_length": "5", - "used_key_parts": ["d"], - "ref": ["test.t1.a"], - "rows": 3, - "filtered": 100, - "attached_condition": "octet_length(t2.f) = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 12, + "filtered": 100, + "index_condition": "t1.a is not null", + "attached_condition": "(t1.a,2) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and octet_length(t1.c) = 1" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["idx3"], + "key": "idx3", + "key_length": "5", + "used_key_parts": ["d"], + "ref": ["test.t1.a"], + "rows": 3, + "filtered": 100, + "attached_condition": "octet_length(t2.f) = 1" + } + } + ] } } select * from t1,t2 @@ -3012,41 +3066,49 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "const", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["id"], - "ref": ["const"], - "rows": 1, - "filtered": 100 - }, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 12, - "filtered": 100, - "index_condition": "t1.a is not null", - "attached_condition": "(t1.a,1 + 1) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and octet_length(t1.c) = 1" - }, - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["idx3"], - "key": "idx3", - "key_length": "5", - "used_key_parts": ["d"], - "ref": ["test.t1.a"], - "rows": 3, - "filtered": 100, - "attached_condition": "octet_length(t2.f) = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "const", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["id"], + "ref": ["const"], + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 12, + "filtered": 100, + "index_condition": "t1.a is not null", + "attached_condition": "(t1.a,1 + 1) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and octet_length(t1.c) = 1" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["idx3"], + "key": "idx3", + "key_length": "5", + "used_key_parts": ["d"], + "ref": ["test.t1.a"], + "rows": 3, + "filtered": 100, + "attached_condition": "octet_length(t2.f) = 1" + } + } + ] } } select * from t1,t2,t3 diff --git a/mysql-test/main/range_mrr_icp.result b/mysql-test/main/range_mrr_icp.result index 6817edd30cd..c2c715a0a89 100644 --- a/mysql-test/main/range_mrr_icp.result +++ b/mysql-test/main/range_mrr_icp.result @@ -2415,18 +2415,22 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "10", - "used_key_parts": ["a", "b"], - "rows": 6, - "filtered": 100, - "attached_condition": "(t1.a,t1.b) in (<cache>((2,3)),<cache>((3,3)),<cache>((8,8)),<cache>((7,7)))", - "mrr_type": "Rowid-ordered scan" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "10", + "used_key_parts": ["a", "b"], + "rows": 6, + "filtered": 100, + "attached_condition": "(t1.a,t1.b) in (<cache>((2,3)),<cache>((3,3)),<cache>((8,8)),<cache>((7,7)))", + "mrr_type": "Rowid-ordered scan" + } + } + ] } } select * from t1 where (a,b) IN ((2, 3),(3,3),(8,8),(7,7)); @@ -2476,18 +2480,22 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a,t1.b + t1.a) in (<cache>((4,9)),<cache>((8,8)),<cache>((7,7)))", - "mrr_type": "Rowid-ordered scan" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a,t1.b + t1.a) in (<cache>((4,9)),<cache>((8,8)),<cache>((7,7)))", + "mrr_type": "Rowid-ordered scan" + } + } + ] } } select * from t1 where (a,b+a) IN ((4,9),(8,8),(7,7)); @@ -2503,18 +2511,22 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 5, - "filtered": 100, - "attached_condition": "(t1.a,t1.b) in ((4,t1.a - 1),(8,t1.a + 8),(7,t1.a + 7))", - "mrr_type": "Rowid-ordered scan" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 5, + "filtered": 100, + "attached_condition": "(t1.a,t1.b) in ((4,t1.a - 1),(8,t1.a + 8),(7,t1.a + 7))", + "mrr_type": "Rowid-ordered scan" + } + } + ] } } select * from t1 where (a,b) IN ((4,a-1),(8,a+8),(7,a+7)); @@ -2544,30 +2556,36 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "5", - "used_key_parts": ["d"], - "rows": 3, - "filtered": 60, - "index_condition": "t2.d is not null", - "attached_condition": "(t2.d,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((2,2)))", - "mrr_type": "Rowid-ordered scan" - }, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.d"], - "rows": 8, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": ["idx1", "idx2"], + "key": "idx1", + "key_length": "5", + "used_key_parts": ["d"], + "rows": 3, + "filtered": 60, + "index_condition": "t2.d is not null", + "attached_condition": "(t2.d,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((2,2)))", + "mrr_type": "Rowid-ordered scan" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.d"], + "rows": 8, + "filtered": 100 + } + } + ] } } select * from t1,t2 @@ -2617,30 +2635,36 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "5", - "used_key_parts": ["d"], - "rows": 8, - "filtered": 14.42307663, - "index_condition": "t2.d is not null", - "attached_condition": "(t2.d,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1", - "mrr_type": "Rowid-ordered scan" - }, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.d"], - "rows": 8, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": ["idx1", "idx2"], + "key": "idx1", + "key_length": "5", + "used_key_parts": ["d"], + "rows": 8, + "filtered": 14.42307663, + "index_condition": "t2.d is not null", + "attached_condition": "(t2.d,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1", + "mrr_type": "Rowid-ordered scan" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.d"], + "rows": 8, + "filtered": 100 + } + } + ] } } select * from t1,t2 @@ -2715,30 +2739,36 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "5", - "used_key_parts": ["d"], - "rows": 7, - "filtered": 6.730769157, - "index_condition": "t2.d is not null", - "attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1", - "mrr_type": "Rowid-ordered scan" - }, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.d"], - "rows": 11, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": ["idx1", "idx2"], + "key": "idx1", + "key_length": "5", + "used_key_parts": ["d"], + "rows": 7, + "filtered": 6.730769157, + "index_condition": "t2.d is not null", + "attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1", + "mrr_type": "Rowid-ordered scan" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.d"], + "rows": 11, + "filtered": 100 + } + } + ] } } select * from t1,t2 @@ -2766,30 +2796,36 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["idx3"], - "key": "idx3", - "key_length": "10", - "used_key_parts": ["d", "e"], - "rows": 5, - "filtered": 100, - "index_condition": "t2.d is not null", - "attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1", - "mrr_type": "Rowid-ordered scan" - }, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "ref": ["test.t2.d"], - "rows": 11, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": ["idx3"], + "key": "idx3", + "key_length": "10", + "used_key_parts": ["d", "e"], + "rows": 5, + "filtered": 100, + "index_condition": "t2.d is not null", + "attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1", + "mrr_type": "Rowid-ordered scan" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t2.d"], + "rows": 11, + "filtered": 100 + } + } + ] } } select * from t1,t2 @@ -2816,30 +2852,36 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 15, - "filtered": 100, - "index_condition": "t1.a is not null", - "mrr_type": "Rowid-ordered scan" - }, - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["idx3"], - "key": "idx3", - "key_length": "5", - "used_key_parts": ["d"], - "ref": ["test.t1.a"], - "rows": 3, - "filtered": 100, - "attached_condition": "(t1.a,t2.e) in ((4,t1.a + 1),(7,t1.a + 1),(8,t1.a + 1)) and octet_length(t2.f) = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 15, + "filtered": 100, + "index_condition": "t1.a is not null", + "mrr_type": "Rowid-ordered scan" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["idx3"], + "key": "idx3", + "key_length": "5", + "used_key_parts": ["d"], + "ref": ["test.t1.a"], + "rows": 3, + "filtered": 100, + "attached_condition": "(t1.a,t2.e) in ((4,t1.a + 1),(7,t1.a + 1),(8,t1.a + 1)) and octet_length(t2.f) = 1" + } + } + ] } } select * from t1,t2 @@ -2874,26 +2916,32 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "possible_keys": ["idx"], - "rows": 144, - "filtered": 100, - "attached_condition": "t1.a is not null" - }, - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["idx3"], - "key": "idx3", - "key_length": "5", - "used_key_parts": ["d"], - "ref": ["test.t1.a"], - "rows": 3, - "filtered": 100, - "attached_condition": "(t1.a,t2.e) in ((t2.e,t1.a + 1),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": ["idx"], + "rows": 144, + "filtered": 100, + "attached_condition": "t1.a is not null" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["idx3"], + "key": "idx3", + "key_length": "5", + "used_key_parts": ["d"], + "ref": ["test.t1.a"], + "rows": 3, + "filtered": 100, + "attached_condition": "(t1.a,t2.e) in ((t2.e,t1.a + 1),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1" + } + } + ] } } select * from t1,t2 @@ -2922,31 +2970,37 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 12, - "filtered": 100, - "index_condition": "t1.a is not null", - "attached_condition": "(t1.a,2) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and octet_length(t1.c) = 1", - "mrr_type": "Rowid-ordered scan" - }, - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["idx3"], - "key": "idx3", - "key_length": "5", - "used_key_parts": ["d"], - "ref": ["test.t1.a"], - "rows": 3, - "filtered": 100, - "attached_condition": "octet_length(t2.f) = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 12, + "filtered": 100, + "index_condition": "t1.a is not null", + "attached_condition": "(t1.a,2) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and octet_length(t1.c) = 1", + "mrr_type": "Rowid-ordered scan" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["idx3"], + "key": "idx3", + "key_length": "5", + "used_key_parts": ["d"], + "ref": ["test.t1.a"], + "rows": 3, + "filtered": 100, + "attached_condition": "octet_length(t2.f) = 1" + } + } + ] } } select * from t1,t2 @@ -3000,42 +3054,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "const", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["id"], - "ref": ["const"], - "rows": 1, - "filtered": 100 - }, - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx"], - "key": "idx", - "key_length": "5", - "used_key_parts": ["a"], - "rows": 12, - "filtered": 100, - "index_condition": "t1.a is not null", - "attached_condition": "(t1.a,1 + 1) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and octet_length(t1.c) = 1", - "mrr_type": "Rowid-ordered scan" - }, - "table": { - "table_name": "t2", - "access_type": "ref", - "possible_keys": ["idx3"], - "key": "idx3", - "key_length": "5", - "used_key_parts": ["d"], - "ref": ["test.t1.a"], - "rows": 3, - "filtered": 100, - "attached_condition": "octet_length(t2.f) = 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "const", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["id"], + "ref": ["const"], + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx"], + "key": "idx", + "key_length": "5", + "used_key_parts": ["a"], + "rows": 12, + "filtered": 100, + "index_condition": "t1.a is not null", + "attached_condition": "(t1.a,1 + 1) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and octet_length(t1.c) = 1", + "mrr_type": "Rowid-ordered scan" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["idx3"], + "key": "idx3", + "key_length": "5", + "used_key_parts": ["d"], + "ref": ["test.t1.a"], + "rows": 3, + "filtered": 100, + "attached_condition": "octet_length(t2.f) = 1" + } + } + ] } } select * from t1,t2,t3 diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result index 9860b2e9ad3..5f1a4a1db76 100644 --- a/mysql-test/main/rowid_filter.result +++ b/mysql-test/main/rowid_filter.result @@ -77,26 +77,30 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rowid_filter": { - "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] - }, - "rows": 702, - "selectivity_pct": 11.69025812 - }, - "rows": 509, - "filtered": 11.69025803, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": ["i_l_shipdate", "i_l_quantity"], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 702, + "selectivity_pct": 11.69025812 + }, + "rows": 509, + "filtered": 11.69025803, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem @@ -113,36 +117,40 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rowid_filter": { - "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] - }, - "rows": 702, - "selectivity_pct": 11.69025812, - "r_rows": 605, - "r_lookups": 510, - "r_selectivity_pct": 11.76470588, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 509, - "r_rows": 60, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 11.69025803, - "r_filtered": 100, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": ["i_l_shipdate", "i_l_quantity"], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 702, + "selectivity_pct": 11.69025812, + "r_rows": 605, + "r_lookups": 510, + "r_selectivity_pct": 11.76470588, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 509, + "r_rows": 60, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 11.69025803, + "r_filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem @@ -221,18 +229,22 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rows": 509, - "filtered": 11.69025803, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": ["i_l_shipdate", "i_l_quantity"], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rows": 509, + "filtered": 11.69025803, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem @@ -249,23 +261,27 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "r_loops": 1, - "rows": 509, - "r_rows": 510, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 11.69025803, - "r_filtered": 11.76470588, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": ["i_l_shipdate", "i_l_quantity"], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "r_loops": 1, + "rows": 509, + "r_rows": 510, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 11.69025803, + "r_filtered": 11.76470588, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem @@ -347,42 +363,48 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rows": 98, - "filtered": 100, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rowid_filter": { - "range": { - "key": "i_o_totalprice", - "used_key_parts": ["o_totalprice"] - }, - "rows": 69, - "selectivity_pct": 4.6 + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rows": 98, + "filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" + } }, - "rows": 1, - "filtered": 4.599999905, - "attached_condition": "orders.o_totalprice between 200000 and 230000" - } + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rowid_filter": { + "range": { + "key": "i_o_totalprice", + "used_key_parts": ["o_totalprice"] + }, + "rows": 69, + "selectivity_pct": 4.6 + }, + "rows": 1, + "filtered": 4.599999905, + "attached_condition": "orders.o_totalprice between 200000 and 230000" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -402,57 +424,63 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "r_loops": 1, - "rows": 98, - "r_rows": 98, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rowid_filter": { - "range": { - "key": "i_o_totalprice", - "used_key_parts": ["o_totalprice"] - }, - "rows": 69, - "selectivity_pct": 4.6, - "r_rows": 71, - "r_lookups": 96, - "r_selectivity_pct": 10.41666667, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "r_loops": 1, + "rows": 98, + "r_rows": 98, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" + } }, - "r_loops": 98, - "rows": 1, - "r_rows": 0.112244898, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 4.599999905, - "r_filtered": 100, - "attached_condition": "orders.o_totalprice between 200000 and 230000" - } + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rowid_filter": { + "range": { + "key": "i_o_totalprice", + "used_key_parts": ["o_totalprice"] + }, + "rows": 69, + "selectivity_pct": 4.6, + "r_rows": 71, + "r_lookups": 96, + "r_selectivity_pct": 10.41666667, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 98, + "rows": 1, + "r_rows": 0.112244898, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 4.599999905, + "r_filtered": 100, + "attached_condition": "orders.o_totalprice between 200000 and 230000" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -486,34 +514,40 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rows": 98, - "filtered": 100, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rows": 1, - "filtered": 4.599999905, - "attached_condition": "orders.o_totalprice between 200000 and 230000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rows": 98, + "filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 4.599999905, + "attached_condition": "orders.o_totalprice between 200000 and 230000" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -533,44 +567,50 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "r_loops": 1, - "rows": 98, - "r_rows": 98, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "r_loops": 98, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 4.599999905, - "r_filtered": 11.2244898, - "attached_condition": "orders.o_totalprice between 200000 and 230000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "r_loops": 1, + "rows": 98, + "r_rows": 98, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 98, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 4.599999905, + "r_filtered": 11.2244898, + "attached_condition": "orders.o_totalprice between 200000 and 230000" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -606,52 +646,58 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity", - "i_l_quantity" - ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rowid_filter": { - "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] - }, - "rows": 702, - "selectivity_pct": 11.69025812 - }, - "rows": 509, - "filtered": 11.69025803, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rowid_filter": { - "range": { - "key": "i_o_totalprice", - "used_key_parts": ["o_totalprice"] - }, - "rows": 139, - "selectivity_pct": 9.266666667 + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity", + "i_l_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 702, + "selectivity_pct": 11.69025812 + }, + "rows": 509, + "filtered": 11.69025803, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } }, - "rows": 1, - "filtered": 9.266666412, - "attached_condition": "orders.o_totalprice between 180000 and 230000" - } + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rowid_filter": { + "range": { + "key": "i_o_totalprice", + "used_key_parts": ["o_totalprice"] + }, + "rows": 139, + "selectivity_pct": 9.266666667 + }, + "rows": 1, + "filtered": 9.266666412, + "attached_condition": "orders.o_totalprice between 180000 and 230000" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice @@ -673,72 +719,78 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity", - "i_l_quantity" - ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rowid_filter": { - "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] - }, - "rows": 702, - "selectivity_pct": 11.69025812, - "r_rows": 605, - "r_lookups": 510, - "r_selectivity_pct": 11.76470588, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 509, - "r_rows": 60, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 11.69025803, - "r_filtered": 100, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rowid_filter": { - "range": { - "key": "i_o_totalprice", - "used_key_parts": ["o_totalprice"] - }, - "rows": 139, - "selectivity_pct": 9.266666667, - "r_rows": 144, - "r_lookups": 59, - "r_selectivity_pct": 25.42372881, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity", + "i_l_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 702, + "selectivity_pct": 11.69025812, + "r_rows": 605, + "r_lookups": 510, + "r_selectivity_pct": 11.76470588, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 509, + "r_rows": 60, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 11.69025803, + "r_filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } }, - "r_loops": 60, - "rows": 1, - "r_rows": 0.266666667, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 9.266666412, - "r_filtered": 100, - "attached_condition": "orders.o_totalprice between 180000 and 230000" - } + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rowid_filter": { + "range": { + "key": "i_o_totalprice", + "used_key_parts": ["o_totalprice"] + }, + "rows": 139, + "selectivity_pct": 9.266666667, + "r_rows": 144, + "r_lookups": 59, + "r_selectivity_pct": 25.42372881, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 60, + "rows": 1, + "r_rows": 0.266666667, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 9.266666412, + "r_filtered": 100, + "attached_condition": "orders.o_totalprice between 180000 and 230000" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice @@ -780,36 +832,42 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity", - "i_l_quantity" - ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rows": 509, - "filtered": 11.69025803, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rows": 1, - "filtered": 9.266666412, - "attached_condition": "orders.o_totalprice between 180000 and 230000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity", + "i_l_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rows": 509, + "filtered": 11.69025803, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 9.266666412, + "attached_condition": "orders.o_totalprice between 180000 and 230000" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice @@ -831,46 +889,52 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity", - "i_l_quantity" - ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "r_loops": 1, - "rows": 509, - "r_rows": 510, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 11.69025803, - "r_filtered": 11.76470588, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "r_loops": 60, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 9.266666412, - "r_filtered": 26.66666667, - "attached_condition": "orders.o_totalprice between 180000 and 230000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity", + "i_l_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "r_loops": 1, + "rows": 509, + "r_rows": 510, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 11.69025803, + "r_filtered": 11.76470588, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 60, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 9.266666412, + "r_filtered": 26.66666667, + "attached_condition": "orders.o_totalprice between 180000 and 230000" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice @@ -910,42 +974,48 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "rows": 69, - "filtered": 100, - "index_condition": "orders.o_totalprice between 200000 and 230000" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_orderkey", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rowid_filter": { - "range": { - "key": "i_l_shipdate", - "used_key_parts": ["l_shipDATE"] - }, - "rows": 509, - "selectivity_pct": 8.476269775 + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "i_o_totalprice", + "key_length": "9", + "used_key_parts": ["o_totalprice"], + "rows": 69, + "filtered": 100, + "index_condition": "orders.o_totalprice between 200000 and 230000" + } }, - "rows": 4, - "filtered": 8.476269722, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" - } + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rowid_filter": { + "range": { + "key": "i_l_shipdate", + "used_key_parts": ["l_shipDATE"] + }, + "rows": 509, + "selectivity_pct": 8.476269775 + }, + "rows": 4, + "filtered": 8.476269722, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -965,57 +1035,63 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "r_loops": 1, - "rows": 69, - "r_rows": 71, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "index_condition": "orders.o_totalprice between 200000 and 230000" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_orderkey", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rowid_filter": { - "range": { - "key": "i_l_shipdate", - "used_key_parts": ["l_shipDATE"] - }, - "rows": 509, - "selectivity_pct": 8.476269775, - "r_rows": 510, - "r_lookups": 476, - "r_selectivity_pct": 7.773109244, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "i_o_totalprice", + "key_length": "9", + "used_key_parts": ["o_totalprice"], + "r_loops": 1, + "rows": 69, + "r_rows": 71, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "index_condition": "orders.o_totalprice between 200000 and 230000" + } }, - "r_loops": 71, - "rows": 4, - "r_rows": 0.521126761, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 8.476269722, - "r_filtered": 100, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" - } + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rowid_filter": { + "range": { + "key": "i_l_shipdate", + "used_key_parts": ["l_shipDATE"] + }, + "rows": 509, + "selectivity_pct": 8.476269775, + "r_rows": 510, + "r_lookups": 476, + "r_selectivity_pct": 7.773109244, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 71, + "rows": 4, + "r_rows": 0.521126761, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.476269722, + "r_filtered": 100, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -1075,34 +1151,40 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "rows": 69, - "filtered": 100, - "index_condition": "orders.o_totalprice between 200000 and 230000" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_orderkey", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": 8.476269722, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "i_o_totalprice", + "key_length": "9", + "used_key_parts": ["o_totalprice"], + "rows": 69, + "filtered": 100, + "index_condition": "orders.o_totalprice between 200000 and 230000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": 8.476269722, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -1122,44 +1204,50 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "r_loops": 1, - "rows": 69, - "r_rows": 71, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "index_condition": "orders.o_totalprice between 200000 and 230000" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_orderkey", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 71, - "rows": 4, - "r_rows": 6.704225352, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 8.476269722, - "r_filtered": 7.773109244, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "i_o_totalprice", + "key_length": "9", + "used_key_parts": ["o_totalprice"], + "r_loops": 1, + "rows": 69, + "r_rows": 71, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "index_condition": "orders.o_totalprice between 200000 and 230000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 71, + "rows": 4, + "r_rows": 6.704225352, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.476269722, + "r_filtered": 7.773109244, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -1230,36 +1318,42 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_receiptdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_receiptdate", - "key_length": "4", - "used_key_parts": ["l_receiptDATE"], - "rows": 18, - "filtered": 0.566194832, - "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rows": 1, - "filtered": 7.466666698, - "attached_condition": "orders.o_totalprice between 200000 and 250000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_receiptdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_receiptdate", + "key_length": "4", + "used_key_parts": ["l_receiptDATE"], + "rows": 18, + "filtered": 0.566194832, + "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 7.466666698, + "attached_condition": "orders.o_totalprice between 200000 and 250000" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT l_shipdate, l_receiptdate, o_totalprice @@ -1283,46 +1377,52 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_receiptdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_receiptdate", - "key_length": "4", - "used_key_parts": ["l_receiptDATE"], - "r_loops": 1, - "rows": 18, - "r_rows": 18, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 0.566194832, - "r_filtered": 38.88888889, - "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "r_loops": 7, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 7.466666698, - "r_filtered": 14.28571429, - "attached_condition": "orders.o_totalprice between 200000 and 250000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_receiptdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_receiptdate", + "key_length": "4", + "used_key_parts": ["l_receiptDATE"], + "r_loops": 1, + "rows": 18, + "r_rows": 18, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.566194832, + "r_filtered": 38.88888889, + "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 7, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 7.466666698, + "r_filtered": 14.28571429, + "attached_condition": "orders.o_totalprice between 200000 and 250000" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for SELECT l_shipdate, l_receiptdate, o_totalprice @@ -1352,36 +1452,42 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_receiptdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_receiptdate", - "key_length": "4", - "used_key_parts": ["l_receiptDATE"], - "rows": 18, - "filtered": 0.566194832, - "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rows": 1, - "filtered": 7.466666698, - "attached_condition": "orders.o_totalprice between 200000 and 250000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_receiptdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_receiptdate", + "key_length": "4", + "used_key_parts": ["l_receiptDATE"], + "rows": 18, + "filtered": 0.566194832, + "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 7.466666698, + "attached_condition": "orders.o_totalprice between 200000 and 250000" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT l_shipdate, l_receiptdate, o_totalprice @@ -1405,46 +1511,52 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_receiptdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_receiptdate", - "key_length": "4", - "used_key_parts": ["l_receiptDATE"], - "r_loops": 1, - "rows": 18, - "r_rows": 18, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 0.566194832, - "r_filtered": 38.88888889, - "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "r_loops": 7, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 7.466666698, - "r_filtered": 14.28571429, - "attached_condition": "orders.o_totalprice between 200000 and 250000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_receiptdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_receiptdate", + "key_length": "4", + "used_key_parts": ["l_receiptDATE"], + "r_loops": 1, + "rows": 18, + "r_rows": 18, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.566194832, + "r_filtered": 38.88888889, + "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 7, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 7.466666698, + "r_filtered": 14.28571429, + "attached_condition": "orders.o_totalprice between 200000 and 250000" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for SELECT l_shipdate, l_receiptdate, o_totalprice @@ -1481,35 +1593,41 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "rows": 39, - "filtered": 3.200000048, - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_orderkey", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": 3.047460556, - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "rows": 39, + "filtered": 3.200000048, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": 3.047460556, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -1533,45 +1651,51 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "r_loops": 1, - "rows": 39, - "r_rows": 41, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 3.200000048, - "r_filtered": 2.43902439, - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_orderkey", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 1, - "rows": 4, - "r_rows": 6, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 3.047460556, - "r_filtered": 66.66666667, - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "r_loops": 1, + "rows": 39, + "r_rows": 41, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.200000048, + "r_filtered": 2.43902439, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 1, + "rows": 4, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.047460556, + "r_filtered": 66.66666667, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -1604,35 +1728,41 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "rows": 39, - "filtered": 3.200000048, - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_orderkey", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": 3.047460556, - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "rows": 39, + "filtered": 3.200000048, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": 3.047460556, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -1656,45 +1786,51 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "r_loops": 1, - "rows": 39, - "r_rows": 41, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 3.200000048, - "r_filtered": 2.43902439, - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_orderkey", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 1, - "rows": 4, - "r_rows": 6, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 3.047460556, - "r_filtered": 66.66666667, - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "r_loops": 1, + "rows": 39, + "r_rows": 41, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.200000048, + "r_filtered": 2.43902439, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 1, + "rows": 4, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.047460556, + "r_filtered": 66.66666667, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -1730,40 +1866,46 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_o_orderdate", - "i_o_totalprice", - "i_o_totaldiscount" - ], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "rows": 39, - "filtered": "REPLACED", - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_orderkey", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": "REPLACED", - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_o_orderdate", + "i_o_totalprice", + "i_o_totaldiscount" + ], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "rows": 39, + "filtered": "REPLACED", + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": "REPLACED", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -1787,50 +1929,56 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_o_orderdate", - "i_o_totalprice", - "i_o_totaldiscount" - ], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "r_loops": 1, - "rows": 39, - "r_rows": 41, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": "REPLACED", - "r_filtered": 2.43902439, - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_orderkey", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 1, - "rows": 4, - "r_rows": 6, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": "REPLACED", - "r_filtered": 66.66666667, - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_o_orderdate", + "i_o_totalprice", + "i_o_totaldiscount" + ], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "r_loops": 1, + "rows": 39, + "r_rows": 41, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": "REPLACED", + "r_filtered": 2.43902439, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 1, + "rows": 4, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": "REPLACED", + "r_filtered": 66.66666667, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -1863,40 +2011,46 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_o_orderdate", - "i_o_totalprice", - "i_o_totaldiscount" - ], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "rows": 39, - "filtered": "REPLACED", - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_orderkey", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": "REPLACED", - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_o_orderdate", + "i_o_totalprice", + "i_o_totaldiscount" + ], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "rows": 39, + "filtered": "REPLACED", + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": "REPLACED", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -1920,50 +2074,56 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_o_orderdate", - "i_o_totalprice", - "i_o_totaldiscount" - ], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "r_loops": 1, - "rows": 39, - "r_rows": 41, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": "REPLACED", - "r_filtered": 2.43902439, - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_orderkey", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 1, - "rows": 4, - "r_rows": 6, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": "REPLACED", - "r_filtered": 66.66666667, - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_o_orderdate", + "i_o_totalprice", + "i_o_totaldiscount" + ], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "r_loops": 1, + "rows": 39, + "r_rows": 41, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": "REPLACED", + "r_filtered": 2.43902439, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_orderkey", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 1, + "rows": 4, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": "REPLACED", + "r_filtered": 66.66666667, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -2108,40 +2268,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 101, - "filtered": 100, - "attached_condition": "t2.a2 is not null" - }, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["a1", "b1"], - "key": "a1", - "key_length": "5", - "used_key_parts": ["a1"], - "ref": ["test.t2.a2"], - "rows": 36, - "filtered": 28.75, - "attached_condition": "t1.b1 <= (subquery#2) and t1.pk1 + 1 = t2.pk2 + 2" - }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 101, + "filtered": 100, + "attached_condition": "t2.a2 is not null" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["a1", "b1"], + "key": "a1", + "key_length": "5", + "used_key_parts": ["a1"], + "ref": ["test.t2.a2"], + "rows": 36, + "filtered": 28.75, + "attached_condition": "t1.b1 <= (subquery#2) and t1.pk1 + 1 = t2.pk2 + 2" + } + } + ], "subqueries": [ { "query_block": { "select_id": 2, - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["pk2"], - "rows": 1, - "filtered": 100, - "index_condition": "t2.pk2 <= 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["pk2"], + "rows": 1, + "filtered": 100, + "index_condition": "t2.pk2 <= 1" + } + } + ] } } ] @@ -2317,23 +2487,27 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "35", - "used_key_parts": ["nm"], - "r_loops": 1, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 49.20000076, - "r_filtered": 100, - "index_condition": "t1.nm like '500%'", - "attached_condition": "t1.fl2 = 0" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx1", "idx2"], + "key": "idx1", + "key_length": "35", + "used_key_parts": ["nm"], + "r_loops": 1, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 49.20000076, + "r_filtered": 100, + "index_condition": "t1.nm like '500%'", + "attached_condition": "t1.fl2 = 0" + } + } + ] } } select * from t1 where nm like '500%' AND fl2 = 0; @@ -2363,23 +2537,27 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "35", - "used_key_parts": ["nm"], - "r_loops": 1, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 49.20000076, - "r_filtered": 100, - "index_condition": "t1.nm like '500%'", - "attached_condition": "t1.fl2 = 0" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx1", "idx2"], + "key": "idx1", + "key_length": "35", + "used_key_parts": ["nm"], + "r_loops": 1, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 49.20000076, + "r_filtered": 100, + "index_condition": "t1.nm like '500%'", + "attached_condition": "t1.fl2 = 0" + } + } + ] } } select * from t1 where nm like '500%' AND fl2 = 0; @@ -2434,36 +2612,40 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx1", "idx2"], - "key": "idx2", - "key_length": "2", - "used_key_parts": ["fl2"], - "ref": ["const"], - "rowid_filter": { - "range": { - "key": "idx1", - "used_key_parts": ["nm"] - }, - "rows": 115, - "selectivity_pct": 1.15, - "r_rows": 111, - "r_lookups": 100, - "r_selectivity_pct": 2, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 55, - "r_rows": 2, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 1.149999976, - "r_filtered": 100, - "attached_condition": "t1.nm like '75%'" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx1", "idx2"], + "key": "idx2", + "key_length": "2", + "used_key_parts": ["fl2"], + "ref": ["const"], + "rowid_filter": { + "range": { + "key": "idx1", + "used_key_parts": ["nm"] + }, + "rows": 115, + "selectivity_pct": 1.15, + "r_rows": 111, + "r_lookups": 100, + "r_selectivity_pct": 2, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 55, + "r_rows": 2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 1.149999976, + "r_filtered": 100, + "attached_condition": "t1.nm like '75%'" + } + } + ] } } select * from t1 where nm like '75%' AND fl2 = 0; @@ -2541,36 +2723,40 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx1", "idx2"], - "key": "idx2", - "key_length": "5", - "used_key_parts": ["fl2"], - "ref": ["const"], - "rowid_filter": { - "range": { - "key": "idx1", - "used_key_parts": ["nm"] - }, - "rows": 44, - "selectivity_pct": 0.44, - "r_rows": 44, - "r_lookups": 1000, - "r_selectivity_pct": 0, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 863, - "r_rows": 0, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 0.439999998, - "r_filtered": 100, - "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx1", "idx2"], + "key": "idx2", + "key_length": "5", + "used_key_parts": ["fl2"], + "ref": ["const"], + "rowid_filter": { + "range": { + "key": "idx1", + "used_key_parts": ["nm"] + }, + "rows": 44, + "selectivity_pct": 0.44, + "r_rows": 44, + "r_lookups": 1000, + "r_selectivity_pct": 0, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 863, + "r_rows": 0, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.439999998, + "r_filtered": 100, + "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" + } + } + ] } } create table t0 select * from t1 where nm like '34%'; @@ -2600,34 +2786,38 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx1", "idx2"], - "key": "idx2", - "key_length": "5", - "used_key_parts": ["fl2"], - "ref": ["const"], - "rowid_filter": { - "range": { - "key": "idx1", - "used_key_parts": ["nm"] - }, - "rows": 44, - "selectivity_pct": 0.44, - "r_rows": 0, - "r_lookups": 0, - "r_selectivity_pct": 0, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 853, - "r_rows": 0, - "filtered": 0.439999998, - "r_filtered": 100, - "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx1", "idx2"], + "key": "idx2", + "key_length": "5", + "used_key_parts": ["fl2"], + "ref": ["const"], + "rowid_filter": { + "range": { + "key": "idx1", + "used_key_parts": ["nm"] + }, + "rows": 44, + "selectivity_pct": 0.44, + "r_rows": 0, + "r_lookups": 0, + "r_selectivity_pct": 0, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 853, + "r_rows": 0, + "filtered": 0.439999998, + "r_filtered": 100, + "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" + } + } + ] } } drop table t0; diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index 3e673afbc99..990c6b4e894 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -80,26 +80,30 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rowid_filter": { - "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] - }, - "rows": 605, - "selectivity_pct": 10.07493755 - }, - "rows": 510, - "filtered": 10.07493782, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": ["i_l_shipdate", "i_l_quantity"], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 605, + "selectivity_pct": 10.07493755 + }, + "rows": 510, + "filtered": 10.07493782, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem @@ -116,36 +120,40 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rowid_filter": { - "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] - }, - "rows": 605, - "selectivity_pct": 10.07493755, - "r_rows": 605, - "r_lookups": 510, - "r_selectivity_pct": 11.76470588, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 510, - "r_rows": 60, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 10.07493782, - "r_filtered": 100, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": ["i_l_shipdate", "i_l_quantity"], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 605, + "selectivity_pct": 10.07493755, + "r_rows": 605, + "r_lookups": 510, + "r_selectivity_pct": 11.76470588, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 510, + "r_rows": 60, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 10.07493782, + "r_filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem @@ -224,18 +232,22 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rows": 510, - "filtered": 10.07493782, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": ["i_l_shipdate", "i_l_quantity"], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rows": 510, + "filtered": 10.07493782, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem @@ -252,23 +264,27 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "r_loops": 1, - "rows": 510, - "r_rows": 510, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 10.07493782, - "r_filtered": 11.76470588, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": ["i_l_shipdate", "i_l_quantity"], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "r_loops": 1, + "rows": 510, + "r_rows": 510, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 10.07493782, + "r_filtered": 11.76470588, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem @@ -350,35 +366,41 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rows": 98, - "filtered": 100, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", - "using_index": true - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rows": 1, - "filtered": 4.733333111, - "attached_condition": "orders.o_totalprice between 200000 and 230000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rows": 98, + "filtered": 100, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", + "using_index": true + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 4.733333111, + "attached_condition": "orders.o_totalprice between 200000 and 230000" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -398,45 +420,51 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "r_loops": 1, - "rows": 98, - "r_rows": 98, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", - "using_index": true - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "r_loops": 98, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 4.733333111, - "r_filtered": 11.2244898, - "attached_condition": "orders.o_totalprice between 200000 and 230000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "r_loops": 1, + "rows": 98, + "r_rows": 98, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", + "using_index": true + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 98, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 4.733333111, + "r_filtered": 11.2244898, + "attached_condition": "orders.o_totalprice between 200000 and 230000" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -470,35 +498,41 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rows": 98, - "filtered": 100, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", - "using_index": true - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rows": 1, - "filtered": 4.733333111, - "attached_condition": "orders.o_totalprice between 200000 and 230000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rows": 98, + "filtered": 100, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", + "using_index": true + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 4.733333111, + "attached_condition": "orders.o_totalprice between 200000 and 230000" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -518,45 +552,51 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "r_loops": 1, - "rows": 98, - "r_rows": 98, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", - "using_index": true - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "r_loops": 98, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 4.733333111, - "r_filtered": 11.2244898, - "attached_condition": "orders.o_totalprice between 200000 and 230000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "r_loops": 1, + "rows": 98, + "r_rows": 98, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", + "using_index": true + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 98, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 4.733333111, + "r_filtered": 11.2244898, + "attached_condition": "orders.o_totalprice between 200000 and 230000" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -592,44 +632,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity", - "i_l_quantity" - ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rowid_filter": { - "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] - }, - "rows": 605, - "selectivity_pct": 10.07493755 + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity", + "i_l_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 605, + "selectivity_pct": 10.07493755 + }, + "rows": 510, + "filtered": 10.07493782, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } }, - "rows": 510, - "filtered": 10.07493782, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rows": 1, - "filtered": 9.600000381, - "attached_condition": "orders.o_totalprice between 180000 and 230000" - } + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 9.600000381, + "attached_condition": "orders.o_totalprice between 180000 and 230000" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice @@ -651,59 +697,65 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity", - "i_l_quantity" - ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], - "rowid_filter": { - "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] - }, - "rows": 605, - "selectivity_pct": 10.07493755, - "r_rows": 605, - "r_lookups": 510, - "r_selectivity_pct": 11.76470588, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity", + "i_l_quantity" + ], + "key": "i_l_shipdate", + "key_length": "4", + "used_key_parts": ["l_shipDATE"], + "rowid_filter": { + "range": { + "key": "i_l_quantity", + "used_key_parts": ["l_quantity"] + }, + "rows": 605, + "selectivity_pct": 10.07493755, + "r_rows": 605, + "r_lookups": 510, + "r_selectivity_pct": 11.76470588, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 510, + "r_rows": 60, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 10.07493782, + "r_filtered": 100, + "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", + "attached_condition": "lineitem.l_quantity > 45" + } }, - "r_loops": 1, - "rows": 510, - "r_rows": 60, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 10.07493782, - "r_filtered": 100, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "r_loops": 60, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 9.600000381, - "r_filtered": 26.66666667, - "attached_condition": "orders.o_totalprice between 180000 and 230000" - } + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 60, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 9.600000381, + "r_filtered": 26.66666667, + "attached_condition": "orders.o_totalprice between 180000 and 230000" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice @@ -745,36 +797,42 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "rows": 144, - "filtered": 100, - "attached_condition": "orders.o_totalprice between 180000 and 230000", - "using_index": true - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity", - "i_l_quantity" - ], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": 0.855656624, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "i_o_totalprice", + "key_length": "9", + "used_key_parts": ["o_totalprice"], + "rows": 144, + "filtered": 100, + "attached_condition": "orders.o_totalprice between 180000 and 230000", + "using_index": true + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity", + "i_l_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": 0.855656624, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice @@ -796,46 +854,52 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "r_loops": 1, - "rows": 144, - "r_rows": 144, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "orders.o_totalprice between 180000 and 230000", - "using_index": true - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity", - "i_l_quantity" - ], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 144, - "rows": 4, - "r_rows": 6.625, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 0.855656624, - "r_filtered": 1.677148847, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "i_o_totalprice", + "key_length": "9", + "used_key_parts": ["o_totalprice"], + "r_loops": 1, + "rows": 144, + "r_rows": 144, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "orders.o_totalprice between 180000 and 230000", + "using_index": true + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity", + "i_l_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 144, + "rows": 4, + "r_rows": 6.625, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.855656624, + "r_filtered": 1.677148847, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice @@ -875,35 +939,41 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "rows": 71, - "filtered": 100, - "attached_condition": "orders.o_totalprice between 200000 and 230000", - "using_index": true - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": 8.492922783, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "i_o_totalprice", + "key_length": "9", + "used_key_parts": ["o_totalprice"], + "rows": 71, + "filtered": 100, + "attached_condition": "orders.o_totalprice between 200000 and 230000", + "using_index": true + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": 8.492922783, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -923,45 +993,51 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "r_loops": 1, - "rows": 71, - "r_rows": 71, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "orders.o_totalprice between 200000 and 230000", - "using_index": true - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 71, - "rows": 4, - "r_rows": 6.704225352, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 8.492922783, - "r_filtered": 7.773109244, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "i_o_totalprice", + "key_length": "9", + "used_key_parts": ["o_totalprice"], + "r_loops": 1, + "rows": 71, + "r_rows": 71, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "orders.o_totalprice between 200000 and 230000", + "using_index": true + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 71, + "rows": 4, + "r_rows": 6.704225352, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.492922783, + "r_filtered": 7.773109244, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -1021,35 +1097,41 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "rows": 71, - "filtered": 100, - "attached_condition": "orders.o_totalprice between 200000 and 230000", - "using_index": true - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": 8.492922783, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "i_o_totalprice", + "key_length": "9", + "used_key_parts": ["o_totalprice"], + "rows": 71, + "filtered": 100, + "attached_condition": "orders.o_totalprice between 200000 and 230000", + "using_index": true + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": 8.492922783, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -1069,45 +1151,51 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "i_o_totalprice", - "key_length": "9", - "used_key_parts": ["o_totalprice"], - "r_loops": 1, - "rows": 71, - "r_rows": 71, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "orders.o_totalprice between 200000 and 230000", - "using_index": true - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 71, - "rows": 4, - "r_rows": 6.704225352, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 8.492922783, - "r_filtered": 7.773109244, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "i_o_totalprice", + "key_length": "9", + "used_key_parts": ["o_totalprice"], + "r_loops": 1, + "rows": 71, + "r_rows": 71, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "orders.o_totalprice between 200000 and 230000", + "using_index": true + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 71, + "rows": 4, + "r_rows": 6.704225352, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 8.492922783, + "r_filtered": 7.773109244, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice @@ -1178,36 +1266,42 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_receiptdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_receiptdate", - "key_length": "4", - "used_key_parts": ["l_receiptDATE"], - "rows": 18, - "filtered": 0.566194832, - "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rows": 1, - "filtered": 5.666666508, - "attached_condition": "orders.o_totalprice between 200000 and 250000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_receiptdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_receiptdate", + "key_length": "4", + "used_key_parts": ["l_receiptDATE"], + "rows": 18, + "filtered": 0.566194832, + "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 5.666666508, + "attached_condition": "orders.o_totalprice between 200000 and 250000" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT l_shipdate, l_receiptdate, o_totalprice @@ -1231,46 +1325,52 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_receiptdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_receiptdate", - "key_length": "4", - "used_key_parts": ["l_receiptDATE"], - "r_loops": 1, - "rows": 18, - "r_rows": 18, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 0.566194832, - "r_filtered": 38.88888889, - "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "r_loops": 7, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 5.666666508, - "r_filtered": 14.28571429, - "attached_condition": "orders.o_totalprice between 200000 and 250000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_receiptdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_receiptdate", + "key_length": "4", + "used_key_parts": ["l_receiptDATE"], + "r_loops": 1, + "rows": 18, + "r_rows": 18, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.566194832, + "r_filtered": 38.88888889, + "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 7, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 5.666666508, + "r_filtered": 14.28571429, + "attached_condition": "orders.o_totalprice between 200000 and 250000" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for SELECT l_shipdate, l_receiptdate, o_totalprice @@ -1300,36 +1400,42 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_receiptdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_receiptdate", - "key_length": "4", - "used_key_parts": ["l_receiptDATE"], - "rows": 18, - "filtered": 0.566194832, - "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rows": 1, - "filtered": 5.666666508, - "attached_condition": "orders.o_totalprice between 200000 and 250000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_receiptdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_receiptdate", + "key_length": "4", + "used_key_parts": ["l_receiptDATE"], + "rows": 18, + "filtered": 0.566194832, + "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "rows": 1, + "filtered": 5.666666508, + "attached_condition": "orders.o_totalprice between 200000 and 250000" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT l_shipdate, l_receiptdate, o_totalprice @@ -1353,46 +1459,52 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "lineitem", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_receiptdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "i_l_receiptdate", - "key_length": "4", - "used_key_parts": ["l_receiptDATE"], - "r_loops": 1, - "rows": 18, - "r_rows": 18, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 0.566194832, - "r_filtered": 38.88888889, - "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" - }, - "table": { - "table_name": "orders", - "access_type": "eq_ref", - "possible_keys": ["PRIMARY", "i_o_totalprice"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["o_orderkey"], - "ref": ["dbt3_s001.lineitem.l_orderkey"], - "r_loops": 7, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 5.666666508, - "r_filtered": 14.28571429, - "attached_condition": "orders.o_totalprice between 200000 and 250000" - } + "nested_loop": [ + { + "table": { + "table_name": "lineitem", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_receiptdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "i_l_receiptdate", + "key_length": "4", + "used_key_parts": ["l_receiptDATE"], + "r_loops": 1, + "rows": 18, + "r_rows": 18, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.566194832, + "r_filtered": 38.88888889, + "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'" + } + }, + { + "table": { + "table_name": "orders", + "access_type": "eq_ref", + "possible_keys": ["PRIMARY", "i_o_totalprice"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["o_orderkey"], + "ref": ["dbt3_s001.lineitem.l_orderkey"], + "r_loops": 7, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 5.666666508, + "r_filtered": 14.28571429, + "attached_condition": "orders.o_totalprice between 200000 and 250000" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for SELECT l_shipdate, l_receiptdate, o_totalprice @@ -1429,35 +1541,41 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "rows": 41, - "filtered": 3.333333254, - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": 3.047460556, - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "rows": 41, + "filtered": 3.333333254, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": 3.047460556, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -1481,45 +1599,51 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "r_loops": 1, - "rows": 41, - "r_rows": 41, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 3.333333254, - "r_filtered": 2.43902439, - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 1, - "rows": 4, - "r_rows": 6, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 3.047460556, - "r_filtered": 66.66666667, - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "r_loops": 1, + "rows": 41, + "r_rows": 41, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.333333254, + "r_filtered": 2.43902439, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 1, + "rows": 4, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.047460556, + "r_filtered": 66.66666667, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -1552,35 +1676,41 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "rows": 41, - "filtered": 3.333333254, - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": 3.047460556, - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "rows": 41, + "filtered": 3.333333254, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": 3.047460556, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -1604,45 +1734,51 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "r_loops": 1, - "rows": 41, - "r_rows": 41, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 3.333333254, - "r_filtered": 2.43902439, - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 1, - "rows": 4, - "r_rows": 6, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 3.047460556, - "r_filtered": 66.66666667, - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "r_loops": 1, + "rows": 41, + "r_rows": 41, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.333333254, + "r_filtered": 2.43902439, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 1, + "rows": 4, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 3.047460556, + "r_filtered": 66.66666667, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -1678,40 +1814,46 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_o_orderdate", - "i_o_totalprice", - "i_o_totaldiscount" - ], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "rows": 41, - "filtered": "REPLACED", - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": "REPLACED", - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_o_orderdate", + "i_o_totalprice", + "i_o_totaldiscount" + ], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "rows": 41, + "filtered": "REPLACED", + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": "REPLACED", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -1735,50 +1877,56 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_o_orderdate", - "i_o_totalprice", - "i_o_totaldiscount" - ], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "r_loops": 1, - "rows": 41, - "r_rows": 41, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": "REPLACED", - "r_filtered": 2.43902439, - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 1, - "rows": 4, - "r_rows": 6, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": "REPLACED", - "r_filtered": 66.66666667, - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_o_orderdate", + "i_o_totalprice", + "i_o_totaldiscount" + ], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "r_loops": 1, + "rows": 41, + "r_rows": 41, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": "REPLACED", + "r_filtered": 2.43902439, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 1, + "rows": 4, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": "REPLACED", + "r_filtered": 66.66666667, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=on' for SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -1811,40 +1959,46 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_o_orderdate", - "i_o_totalprice", - "i_o_totaldiscount" - ], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "rows": 41, - "filtered": "REPLACED", - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "rows": 4, - "filtered": "REPLACED", - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_o_orderdate", + "i_o_totalprice", + "i_o_totaldiscount" + ], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "rows": 41, + "filtered": "REPLACED", + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "rows": 4, + "filtered": "REPLACED", + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -1868,50 +2022,56 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "orders", - "access_type": "range", - "possible_keys": [ - "PRIMARY", - "i_o_orderdate", - "i_o_totalprice", - "i_o_totaldiscount" - ], - "key": "i_o_totaldiscount", - "key_length": "9", - "used_key_parts": ["o_totaldiscount"], - "r_loops": 1, - "rows": 41, - "r_rows": 41, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": "REPLACED", - "r_filtered": 2.43902439, - "index_condition": "orders.o_totaldiscount between 18000 and 20000", - "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" - }, - "table": { - "table_name": "lineitem", - "access_type": "ref", - "possible_keys": [ - "PRIMARY", - "i_l_shipdate", - "i_l_orderkey", - "i_l_orderkey_quantity" - ], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["l_orderkey"], - "ref": ["dbt3_s001.orders.o_orderkey"], - "r_loops": 1, - "rows": 4, - "r_rows": 6, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": "REPLACED", - "r_filtered": 66.66666667, - "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" - } + "nested_loop": [ + { + "table": { + "table_name": "orders", + "access_type": "range", + "possible_keys": [ + "PRIMARY", + "i_o_orderdate", + "i_o_totalprice", + "i_o_totaldiscount" + ], + "key": "i_o_totaldiscount", + "key_length": "9", + "used_key_parts": ["o_totaldiscount"], + "r_loops": 1, + "rows": 41, + "r_rows": 41, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": "REPLACED", + "r_filtered": 2.43902439, + "index_condition": "orders.o_totaldiscount between 18000 and 20000", + "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'" + } + }, + { + "table": { + "table_name": "lineitem", + "access_type": "ref", + "possible_keys": [ + "PRIMARY", + "i_l_shipdate", + "i_l_orderkey", + "i_l_orderkey_quantity" + ], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["l_orderkey"], + "ref": ["dbt3_s001.orders.o_orderkey"], + "r_loops": 1, + "rows": 4, + "r_rows": 6, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": "REPLACED", + "r_filtered": 66.66666667, + "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" + } + } + ] } } set statement optimizer_switch='rowid_filter=off' for SELECT o_totaldiscount, o_totalprice, l_shipdate @@ -2056,40 +2216,50 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 101, - "filtered": 100, - "attached_condition": "t2.a2 is not null" - }, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["a1", "b1"], - "key": "a1", - "key_length": "5", - "used_key_parts": ["a1"], - "ref": ["test.t2.a2"], - "rows": 36, - "filtered": 28.75, - "attached_condition": "t1.b1 <= (subquery#2) and t1.pk1 + 1 = t2.pk2 + 2" - }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 101, + "filtered": 100, + "attached_condition": "t2.a2 is not null" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["a1", "b1"], + "key": "a1", + "key_length": "5", + "used_key_parts": ["a1"], + "ref": ["test.t2.a2"], + "rows": 36, + "filtered": 28.75, + "attached_condition": "t1.b1 <= (subquery#2) and t1.pk1 + 1 = t2.pk2 + 2" + } + } + ], "subqueries": [ { "query_block": { "select_id": 2, - "table": { - "table_name": "t2", - "access_type": "range", - "possible_keys": ["PRIMARY"], - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["pk2"], - "rows": 1, - "filtered": 100, - "index_condition": "t2.pk2 <= 1" - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["pk2"], + "rows": 1, + "filtered": 100, + "index_condition": "t2.pk2 <= 1" + } + } + ] } } ] @@ -2265,23 +2435,27 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "35", - "used_key_parts": ["nm"], - "r_loops": 1, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 49.20000076, - "r_filtered": 100, - "index_condition": "t1.nm like '500%'", - "attached_condition": "t1.fl2 = 0" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx1", "idx2"], + "key": "idx1", + "key_length": "35", + "used_key_parts": ["nm"], + "r_loops": 1, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 49.20000076, + "r_filtered": 100, + "index_condition": "t1.nm like '500%'", + "attached_condition": "t1.fl2 = 0" + } + } + ] } } select * from t1 where nm like '500%' AND fl2 = 0; @@ -2311,23 +2485,27 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "range", - "possible_keys": ["idx1", "idx2"], - "key": "idx1", - "key_length": "35", - "used_key_parts": ["nm"], - "r_loops": 1, - "rows": 1, - "r_rows": 1, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 49.20000076, - "r_filtered": 100, - "index_condition": "t1.nm like '500%'", - "attached_condition": "t1.fl2 = 0" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["idx1", "idx2"], + "key": "idx1", + "key_length": "35", + "used_key_parts": ["nm"], + "r_loops": 1, + "rows": 1, + "r_rows": 1, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 49.20000076, + "r_filtered": 100, + "index_condition": "t1.nm like '500%'", + "attached_condition": "t1.fl2 = 0" + } + } + ] } } select * from t1 where nm like '500%' AND fl2 = 0; @@ -2382,36 +2560,40 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx1", "idx2"], - "key": "idx2", - "key_length": "2", - "used_key_parts": ["fl2"], - "ref": ["const"], - "rowid_filter": { - "range": { - "key": "idx1", - "used_key_parts": ["nm"] - }, - "rows": 115, - "selectivity_pct": 1.15, - "r_rows": 111, - "r_lookups": 100, - "r_selectivity_pct": 2, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 55, - "r_rows": 2, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 1.149999976, - "r_filtered": 100, - "attached_condition": "t1.nm like '75%'" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx1", "idx2"], + "key": "idx2", + "key_length": "2", + "used_key_parts": ["fl2"], + "ref": ["const"], + "rowid_filter": { + "range": { + "key": "idx1", + "used_key_parts": ["nm"] + }, + "rows": 115, + "selectivity_pct": 1.15, + "r_rows": 111, + "r_lookups": 100, + "r_selectivity_pct": 2, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 55, + "r_rows": 2, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 1.149999976, + "r_filtered": 100, + "attached_condition": "t1.nm like '75%'" + } + } + ] } } select * from t1 where nm like '75%' AND fl2 = 0; @@ -2489,36 +2671,40 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx1", "idx2"], - "key": "idx2", - "key_length": "5", - "used_key_parts": ["fl2"], - "ref": ["const"], - "rowid_filter": { - "range": { - "key": "idx1", - "used_key_parts": ["nm"] - }, - "rows": 44, - "selectivity_pct": 0.44, - "r_rows": 44, - "r_lookups": 1000, - "r_selectivity_pct": 0, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 863, - "r_rows": 0, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 0.439999998, - "r_filtered": 100, - "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx1", "idx2"], + "key": "idx2", + "key_length": "5", + "used_key_parts": ["fl2"], + "ref": ["const"], + "rowid_filter": { + "range": { + "key": "idx1", + "used_key_parts": ["nm"] + }, + "rows": 44, + "selectivity_pct": 0.44, + "r_rows": 44, + "r_lookups": 1000, + "r_selectivity_pct": 0, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 863, + "r_rows": 0, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.439999998, + "r_filtered": 100, + "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" + } + } + ] } } create table t0 select * from t1 where nm like '34%'; @@ -2548,34 +2734,38 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["idx1", "idx2"], - "key": "idx2", - "key_length": "5", - "used_key_parts": ["fl2"], - "ref": ["const"], - "rowid_filter": { - "range": { - "key": "idx1", - "used_key_parts": ["nm"] - }, - "rows": 44, - "selectivity_pct": 0.44, - "r_rows": 0, - "r_lookups": 0, - "r_selectivity_pct": 0, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "r_loops": 1, - "rows": 853, - "r_rows": 0, - "filtered": 0.439999998, - "r_filtered": 100, - "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["idx1", "idx2"], + "key": "idx2", + "key_length": "5", + "used_key_parts": ["fl2"], + "ref": ["const"], + "rowid_filter": { + "range": { + "key": "idx1", + "used_key_parts": ["nm"] + }, + "rows": 44, + "selectivity_pct": 0.44, + "r_rows": 0, + "r_lookups": 0, + "r_selectivity_pct": 0, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 853, + "r_rows": 0, + "filtered": 0.439999998, + "r_filtered": 100, + "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" + } + } + ] } } drop table t0; @@ -2641,54 +2831,62 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["f1", "f2"], - "key": "f1", - "key_length": "13", - "used_key_parts": ["f1"], - "ref": ["const"], - "rowid_filter": { - "range": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["f1", "f2"], "key": "f1", - "used_key_parts": ["f1"] - }, - "rows": 1, - "selectivity_pct": 1.587301587 - }, - "rows": 1, - "filtered": 1.587301612, - "index_condition": "t1.f1 is null", - "attached_condition": "t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" - } + "key_length": "13", + "used_key_parts": ["f1"], + "ref": ["const"], + "rowid_filter": { + "range": { + "key": "f1", + "used_key_parts": ["f1"] + }, + "rows": 1, + "selectivity_pct": 1.587301587 + }, + "rows": 1, + "filtered": 1.587301612, + "index_condition": "t1.f1 is null", + "attached_condition": "t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" + } + } + ] } }, { "query_block": { "select_id": 2, "operation": "UNION", - "table": { - "table_name": "t1", - "access_type": "ref", - "possible_keys": ["f1", "f2"], - "key": "f1", - "key_length": "13", - "used_key_parts": ["f1"], - "ref": ["const"], - "rowid_filter": { - "range": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["f1", "f2"], "key": "f1", - "used_key_parts": ["f1"] - }, - "rows": 1, - "selectivity_pct": 1.587301587 - }, - "rows": 1, - "filtered": 1.587301612, - "index_condition": "t1.f1 is null", - "attached_condition": "t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" - } + "key_length": "13", + "used_key_parts": ["f1"], + "ref": ["const"], + "rowid_filter": { + "range": { + "key": "f1", + "used_key_parts": ["f1"] + }, + "rows": 1, + "selectivity_pct": 1.587301587 + }, + "rows": 1, + "filtered": 1.587301612, + "index_condition": "t1.f1 is null", + "attached_condition": "t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" + } + } + ] } } ] @@ -3636,81 +3834,93 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t", - "access_type": "index_merge", - "possible_keys": ["PRIMARY", "acli_rid", "acli_tp"], - "key_length": "2,767", - "index_merge": { - "intersect": { - "range": { - "key": "acli_tp", - "used_key_parts": ["tp"] + "nested_loop": [ + { + "table": { + "table_name": "t", + "access_type": "index_merge", + "possible_keys": ["PRIMARY", "acli_rid", "acli_tp"], + "key_length": "2,767", + "index_merge": { + "intersect": [ + { + "range": { + "key": "acli_tp", + "used_key_parts": ["tp"] + } + }, + { + "range": { + "key": "acli_rid", + "used_key_parts": ["rid"] + } + } + ] }, - "range": { - "key": "acli_rid", - "used_key_parts": ["rid"] - } + "r_loops": 1, + "rows": 2, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "t.tp = 121 and t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2'", + "using_index": true } }, - "r_loops": 1, - "rows": 2, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "attached_condition": "t.tp = 121 and t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2'", - "using_index": true - }, - "block-nl-join": { - "table": { - "table_name": "a", - "access_type": "ref", - "possible_keys": ["PRIMARY", "acei_aclid"], - "key": "acei_aclid", - "key_length": "8", - "used_key_parts": ["aclid"], - "ref": ["test.t.id"], - "r_loops": 1, - "rows": 1, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "8Kb", - "join_type": "BKA", - "mrr_type": "Rowid-ordered scan", - "attached_condition": "a.atp = 1", - "r_filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "fi", - "access_type": "ref", - "possible_keys": ["filt_aceid", "filt_fh"], - "key": "filt_aceid", - "key_length": "8", - "used_key_parts": ["aceid"], - "ref": ["test.a.id"], - "r_loops": 1, - "rows": 24, - "r_rows": 80, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 14.46428585, - "r_filtered": 100 + { + "block-nl-join": { + "table": { + "table_name": "a", + "access_type": "ref", + "possible_keys": ["PRIMARY", "acei_aclid"], + "key": "acei_aclid", + "key_length": "8", + "used_key_parts": ["aclid"], + "ref": ["test.t.id"], + "r_loops": 1, + "rows": 1, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "8Kb", + "join_type": "BKA", + "mrr_type": "Rowid-ordered scan", + "attached_condition": "a.atp = 1", + "r_filtered": 100 + } }, - "buffer_type": "incremental", - "buffer_size": "4Kb", - "join_type": "BKA", - "mrr_type": "Rowid-ordered scan", - "attached_condition": "fi.fh in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774)", - "r_filtered": 40 - } + { + "block-nl-join": { + "table": { + "table_name": "fi", + "access_type": "ref", + "possible_keys": ["filt_aceid", "filt_fh"], + "key": "filt_aceid", + "key_length": "8", + "used_key_parts": ["aceid"], + "ref": ["test.a.id"], + "r_loops": 1, + "rows": 24, + "r_rows": 80, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 14.46428585, + "r_filtered": 100 + }, + "buffer_type": "incremental", + "buffer_size": "4Kb", + "join_type": "BKA", + "mrr_type": "Rowid-ordered scan", + "attached_condition": "fi.fh in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774)", + "r_filtered": 40 + } + } + ] } } set optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result index 1143a4deb46..cc82c2b0f25 100644 --- a/mysql-test/main/selectivity.result +++ b/mysql-test/main/selectivity.result @@ -1245,8 +1245,8 @@ EXPLAIN EXTENDED SELECT * FROM language, country, continent WHERE country_group = lang_group AND lang_group IS NULL; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE country ALL NULL NULL NULL NULL 2 0.00 Using where -1 SIMPLE language ALL NULL NULL NULL NULL 6 0.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE country ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE language ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (flat, BNL join) 1 SIMPLE continent ALL NULL NULL NULL NULL 6 100.00 Using join buffer (incremental, BNL join) Warnings: Note 1003 select `test`.`language`.`lang_group` AS `lang_group`,`test`.`language`.`lang` AS `lang`,`test`.`country`.`code` AS `code`,`test`.`country`.`country_group` AS `country_group`,`test`.`continent`.`cont_group` AS `cont_group`,`test`.`continent`.`cont` AS `cont` from `test`.`language` join `test`.`country` join `test`.`continent` where `test`.`language`.`lang_group` = `test`.`country`.`country_group` and `test`.`country`.`country_group` is null @@ -1372,14 +1372,14 @@ test.t2 analyze status Table is already up to date explain extended select * from t1 straight_join t2 where t1.a=t2.a and t1.a<10; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.96 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.00 Using where 1 SIMPLE t2 ref a a 5 test.t1.a 10 100.00 Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 10 explain extended select * from t1 straight_join t2 where t1.a=t2.a and t2.a<10; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.96 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.00 Using where 1 SIMPLE t2 ref a a 5 test.t1.a 10 100.00 Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 10 @@ -1649,12 +1649,12 @@ test.t1 analyze status Table is already up to date # Check what info the optimizer has about selectivities explain extended select * from t1 use index () where a in (17,51,5); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 3.90 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.90 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`a` in (17,51,5) explain extended select * from t1 use index () where b=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.34 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.40 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`b` = 2 # Now, the equality is used for ref access, while the range condition @@ -1901,7 +1901,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN EXTENDED SELECT * from t1 where t1.a >= 81; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 3 66.41 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 66.67 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` >= 81 SELECT HEX(a), b from t1 where t1.a >= 81; @@ -1925,7 +1925,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 5 39.84 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 40.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 2 SET optimizer_use_condition_selectivity=3; diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result index e909e85a2c8..2ef0d2f5630 100644 --- a/mysql-test/main/selectivity_innodb.result +++ b/mysql-test/main/selectivity_innodb.result @@ -1257,8 +1257,8 @@ EXPLAIN EXTENDED SELECT * FROM language, country, continent WHERE country_group = lang_group AND lang_group IS NULL; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE country ALL NULL NULL NULL NULL 2 0.00 Using where -1 SIMPLE language ALL NULL NULL NULL NULL 6 0.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE country ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE language ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (flat, BNL join) 1 SIMPLE continent ALL NULL NULL NULL NULL 6 100.00 Using join buffer (incremental, BNL join) Warnings: Note 1003 select `test`.`language`.`lang_group` AS `lang_group`,`test`.`language`.`lang` AS `lang`,`test`.`country`.`code` AS `code`,`test`.`country`.`country_group` AS `country_group`,`test`.`continent`.`cont_group` AS `cont_group`,`test`.`continent`.`cont` AS `cont` from `test`.`language` join `test`.`country` join `test`.`continent` where `test`.`language`.`lang_group` = `test`.`country`.`country_group` and `test`.`country`.`country_group` is null @@ -1384,14 +1384,14 @@ test.t2 analyze status OK explain extended select * from t1 straight_join t2 where t1.a=t2.a and t1.a<10; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.96 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.00 Using where 1 SIMPLE t2 ref a a 5 test.t1.a 10 100.00 Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 10 explain extended select * from t1 straight_join t2 where t1.a=t2.a and t2.a<10; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.96 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.00 Using where 1 SIMPLE t2 ref a a 5 test.t1.a 10 100.00 Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 10 @@ -1661,12 +1661,12 @@ test.t1 analyze status OK # Check what info the optimizer has about selectivities explain extended select * from t1 use index () where a in (17,51,5); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 3.90 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.90 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`a` in (17,51,5) explain extended select * from t1 use index () where b=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.34 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.40 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`b` = 2 # Now, the equality is used for ref access, while the range condition @@ -1913,7 +1913,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN EXTENDED SELECT * from t1 where t1.a >= 81; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 3 66.41 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 66.67 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` >= 81 SELECT HEX(a), b from t1 where t1.a >= 81; @@ -1937,7 +1937,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 5 39.84 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 40.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 2 SET optimizer_use_condition_selectivity=3; diff --git a/mysql-test/main/set_operation.result b/mysql-test/main/set_operation.result index dd3912629bb..fa0fe21d156 100644 --- a/mysql-test/main/set_operation.result +++ b/mysql-test/main/set_operation.result @@ -571,192 +571,244 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + ] } }, { "query_block": { "select_id": 8, "operation": "UNION", - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "table_name": "<intersect2,3,4>", - "access_type": "ALL", - "query_specifications": [ - { - "query_block": { - "select_id": 2, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 6, - "filtered": 100 - } - } - }, - { - "query_block": { - "select_id": 3, - "operation": "INTERSECT", - "table": { - "message": "No tables used" - } - } - }, - { - "query_block": { - "select_id": 4, - "operation": "INTERSECT", - "table": { - "table_name": "<derived5>", - "access_type": "ALL", - "rows": 10, - "filtered": 100, - "materialized": { - "query_block": { - "union_result": { - "query_specifications": [ - { - "query_block": { - "select_id": 5, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100 - } - } - }, - { + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "materialized": { + "query_block": { + "union_result": { + "table_name": "<intersect2,3,4>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "INTERSECT", + "table": { + "message": "No tables used" + } + } + }, + { + "query_block": { + "select_id": 4, + "operation": "INTERSECT", + "nested_loop": [ + { + "table": { + "table_name": "<derived5>", + "access_type": "ALL", + "rows": 10, + "filtered": 100, + "materialized": { "query_block": { - "select_id": 6, - "operation": "UNION", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100 + "union_result": { + "query_specifications": [ + { + "query_block": { + "select_id": 5, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + ] + } + }, + { + "query_block": { + "select_id": 6, + "operation": "UNION", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + ] + } + } + ] } } } - ] + } } - } + ] } } - } + ] } - ] + } } } } - } + ] } }, { "query_block": { "select_id": 7, "operation": "EXCEPT", - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 5, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + ] } }, { "query_block": { "select_id": 9, "operation": "UNION", - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 6, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + } + } + ] } }, { "query_block": { "select_id": 10, "operation": "UNION", - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 5, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + ] } }, { "query_block": { "select_id": 11, "operation": "EXCEPT", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 6, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "65", - "join_type": "BNL" - } + { + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL" + } + } + ] } }, { "query_block": { "select_id": 12, "operation": "UNION", - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "t1.a < 4" - }, - "block-nl-join": { - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 6, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a < 4" + } }, - "buffer_type": "flat", - "buffer_size": "65", - "join_type": "BNL" - } + { + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL" + } + } + ] } }, { "query_block": { "select_id": 13, "operation": "UNION", - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 5, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + ] } } ] diff --git a/mysql-test/main/set_statement.result b/mysql-test/main/set_statement.result index c5ad11c74c0..7e8266d2ab3 100644 --- a/mysql-test/main/set_statement.result +++ b/mysql-test/main/set_statement.result @@ -132,6 +132,8 @@ sort_buffer_size 100000 '#------------------ STATEMENT Test 6 -----------------------#' '# Initialize variables to known setting' SET SESSION keep_files_on_create=ON; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '# Pre-STATEMENT variable value' SHOW SESSION VARIABLES LIKE 'keep_files_on_create'; @@ -142,6 +144,9 @@ SET STATEMENT keep_files_on_create=OFF FOR SELECT *,@@keep_files_on_create FROM v1 v2 @@keep_files_on_create 1 2 0 3 4 0 +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '# Post-STATEMENT variable value' SHOW SESSION VARIABLES LIKE 'keep_files_on_create'; @@ -174,6 +179,8 @@ myisam_repair_threads=1, sort_buffer_size = 200000, max_join_size=2222220000000, keep_files_on_create=ON; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '# LONG ' SHOW SESSION VARIABLES LIKE 'sort_buffer_size'; @@ -195,6 +202,9 @@ SET STATEMENT keep_files_on_create=OFF FOR SHOW SESSION VARIABLES LIKE 'keep_files_on_create'; Variable_name Value keep_files_on_create OFF +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SHOW SESSION VARIABLES LIKE 'keep_files_on_create'; Variable_name Value keep_files_on_create ON @@ -231,6 +241,8 @@ sort_buffer_size=100000, binlog_format=mixed, keep_files_on_create=ON, max_join_size=2222220000000; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '' '# Pre-STATEMENT variable value @@ -263,6 +275,9 @@ max_join_size=4444440000000 FOR SELECT myProc(123.45); myProc(123.45) 200006.17 +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SET STATEMENT myisam_sort_buffer_size=400000, myisam_repair_threads=2, sort_buffer_size=300000, @@ -272,6 +287,9 @@ max_join_size=4444440000000 FOR SELECT myProc(123.45); myProc(123.45) 300006.17 +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '# Post-STATEMENT No 1 variable value Pre-STATEMENT for No 2' SELECT @@myisam_sort_buffer_size, @@ -290,6 +308,9 @@ binlog_format=row, keep_files_on_create=OFF, max_join_size=4444440000000 FOR DROP FUNCTION myProc; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '# Post-STATEMENT No 2 variable value SELECT @@myisam_sort_buffer_size, @@ -309,6 +330,8 @@ sort_buffer_size=100000, binlog_format=mixed, keep_files_on_create=ON, max_join_size=2222220000000; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '' '# Pre-STATEMENT variable value @@ -329,6 +352,9 @@ keep_files_on_create=OFF, max_join_size=4444440000000 FOR PREPARE stmt1 FROM 'SET STATEMENT binlog_format=row FOR SELECT *,@@binlog_format,@@sort_buffer_size FROM t1'; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' 'Test No 1 Post Value & Test 2 Pre values' SELECT @@myisam_sort_buffer_size, @@ -350,6 +376,9 @@ EXECUTE stmt1; v1 v2 @@binlog_format @@sort_buffer_size 1 2 ROW 200000 3 4 ROW 200000 +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '# Post-STATEMENT No 2 SELECT @@myisam_sort_buffer_size, @@ -370,6 +399,8 @@ sort_buffer_size=100000, binlog_format=mixed, keep_files_on_create=ON, max_join_size=2222220000000; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '' '# Pre-STATEMENT variable value @@ -397,6 +428,9 @@ SELECT @@myisam_sort_buffer_size, @@keep_files_on_create, @@max_join_size; END| +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' 'Test No 1 Post Value & Test 2 Pre values' SELECT @@myisam_sort_buffer_size, @@ -418,6 +452,9 @@ max_join_size=4444440000001 FOR CALL p1(); @@myisam_sort_buffer_size @@myisam_repair_threads @@sort_buffer_size @@binlog_format @@keep_files_on_create @@max_join_size 400001 3 200001 ROW 0 4444440000001 +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '# Post-STATEMENT No 2 SELECT @@myisam_sort_buffer_size, @@ -438,6 +475,8 @@ sort_buffer_size=100000, binlog_format=mixed, keep_files_on_create=ON, max_join_size=2222220000000; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '' CREATE PROCEDURE p2() BEGIN @@ -470,6 +509,11 @@ max_join_size=4444440000000 FOR CALL p2(); @@myisam_sort_buffer_size @@myisam_repair_threads @@sort_buffer_size @@binlog_format @@keep_files_on_create @@max_join_size 400000 3 300000 MIXED 0 3333330000000 +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '# Post-STATEMENT SELECT @@myisam_sort_buffer_size, @@ -490,6 +534,8 @@ sort_buffer_size=100000, binlog_format=mixed, keep_files_on_create=ON, max_join_size=2222220000000; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '' CREATE PROCEDURE p3() BEGIN @@ -530,6 +576,13 @@ CALL p3(); 400000 2 200000 ROW 0 4444440000000 @@myisam_sort_buffer_size @@myisam_repair_threads @@sort_buffer_size @@binlog_format @@keep_files_on_create @@max_join_size 400000 3 300000 MIXED 0 3333330000000 +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '# Post-STATEMENT SELECT @@myisam_sort_buffer_size, @@ -552,6 +605,8 @@ sort_buffer_size=100000, binlog_format=mixed, keep_files_on_create=ON, max_join_size=2222220000000; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '' CREATE PROCEDURE p4() BEGIN @@ -625,6 +680,11 @@ CALL p4(); 320000 2 220022 ROW 1 2222220000000 @@myisam_sort_buffer_size @@myisam_repair_threads @@sort_buffer_size @@binlog_format @@keep_files_on_create @@max_join_size 320000 2 220022 ROW 1 2222220000000 +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '# Post-STATEMENT SELECT @@myisam_sort_buffer_size, @@ -768,6 +828,8 @@ sort_buffer_size=100000, binlog_format=mixed, keep_files_on_create=ON, max_join_size=2222220000000; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '# Pre-STATEMENT variable value SELECT @@myisam_sort_buffer_size, @@ -793,6 +855,10 @@ sort_buffer_size=230013, binlog_format=row, keep_files_on_create=ON, max_join_size=2323230000000; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '# Post-STATEMENT SELECT @@myisam_sort_buffer_size, @@ -813,6 +879,8 @@ sort_buffer_size=100000, binlog_format=mixed, keep_files_on_create=ON, max_join_size=2222220000000; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '# Pre-STATEMENT variable value SELECT @@myisam_sort_buffer_size, @@ -859,6 +927,10 @@ CALL p5(); 400000 2 200000 ROW 0 4444440000000 @@myisam_sort_buffer_size @@myisam_repair_threads @@sort_buffer_size @@binlog_format @@keep_files_on_create @@max_join_size 260000 3 230013 ROW 1 2323230000000 +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release '' '# Post-STATEMENT SELECT @@myisam_sort_buffer_size, @@ -970,6 +1042,8 @@ SELECT @@binlog_format; ROW SET @@binlog_format = @save_binlog_format; SET @@keep_files_on_create = @save_keep_files_on_create; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SET @@max_join_size = @save_max_join_size; SET @@myisam_repair_threads = @save_myisam_repair_threads; SET @@myisam_sort_buffer_size = @save_myisam_sort_buffer_size; diff --git a/mysql-test/main/shutdown_not_windows.combinations b/mysql-test/main/shutdown_debug.combinations index 684d4cfd61d..684d4cfd61d 100644 --- a/mysql-test/main/shutdown_not_windows.combinations +++ b/mysql-test/main/shutdown_debug.combinations diff --git a/mysql-test/main/shutdown_not_windows.result b/mysql-test/main/shutdown_debug.result index 524cdf20fa2..524cdf20fa2 100644 --- a/mysql-test/main/shutdown_not_windows.result +++ b/mysql-test/main/shutdown_debug.result diff --git a/mysql-test/main/shutdown_not_windows.test b/mysql-test/main/shutdown_debug.test index 43063ced494..587b88dc55e 100644 --- a/mysql-test/main/shutdown_not_windows.test +++ b/mysql-test/main/shutdown_debug.test @@ -1,4 +1,3 @@ -source include/not_windows.inc; source include/not_embedded.inc; source include/have_debug.inc; -- source include/no_view_protocol.inc @@ -10,7 +9,7 @@ call mtr.add_suppression('Thread .* did not exit'); set @old_dbug=@@global.debug_dbug; set global debug_dbug='+d,CONNECT_wait'; select variable_value into @cons from information_schema.global_status where variable_name='connections'; -exec $MYSQL -e 'select sleep(3600)' >/dev/null 2>&1 &; +exec $MYSQL -e "select sleep(3600)" >/dev/null 2>&1 &; let $wait_condition= select variable_value>@cons from information_schema.global_status where variable_name='connections'; source include/wait_condition.inc; source include/restart_mysqld.inc; diff --git a/mysql-test/main/sp-cursor.result b/mysql-test/main/sp-cursor.result index aa23d808352..83b05264339 100644 --- a/mysql-test/main/sp-cursor.result +++ b/mysql-test/main/sp-cursor.result @@ -812,3 +812,43 @@ DROP TABLE t; # # End of 10.6 tests # +# +# Start of 10.8 tests +# +# +# MDEV-10654 IN, OUT, INOUT parameters in CREATE FUNCTION +# +BEGIN NOT ATOMIC +DECLARE va INT; +DECLARE cur CURSOR (IN a INT) FOR SELECT a FROM dual; +OPEN cur(1); +FETCH cur INTO va; +CLOSE cur; +SELECT va; +END; +$$ +va +1 +BEGIN NOT ATOMIC +DECLARE va INT; +DECLARE cur CURSOR (OUT a INT) FOR SELECT a FROM dual; +OPEN cur(1); +FETCH cur INTO va; +CLOSE cur; +SELECT va; +END; +$$ +ERROR 42000: This version of MariaDB doesn't yet support 'OUT/INOUT cursor parameter' +BEGIN NOT ATOMIC +DECLARE va INT; +DECLARE cur CURSOR (INOUT a INT) FOR SELECT a FROM dual; +OPEN cur(1); +FETCH cur INTO va; +CLOSE cur; +SELECT va; +END; +$$ +ERROR 42000: This version of MariaDB doesn't yet support 'OUT/INOUT cursor parameter' +# +# End of 10.8 tests +# diff --git a/mysql-test/main/sp-cursor.test b/mysql-test/main/sp-cursor.test index c95d59b1d3b..feb681201a2 100644 --- a/mysql-test/main/sp-cursor.test +++ b/mysql-test/main/sp-cursor.test @@ -821,3 +821,54 @@ DROP TABLE t; --echo # --echo # End of 10.6 tests --echo # + + +--echo # +--echo # Start of 10.8 tests +--echo # + +--echo # +--echo # MDEV-10654 IN, OUT, INOUT parameters in CREATE FUNCTION +--echo # + +DELIMITER $$; +BEGIN NOT ATOMIC + DECLARE va INT; + DECLARE cur CURSOR (IN a INT) FOR SELECT a FROM dual; + OPEN cur(1); + FETCH cur INTO va; + CLOSE cur; + SELECT va; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_NOT_SUPPORTED_YET +BEGIN NOT ATOMIC + DECLARE va INT; + DECLARE cur CURSOR (OUT a INT) FOR SELECT a FROM dual; + OPEN cur(1); + FETCH cur INTO va; + CLOSE cur; + SELECT va; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_NOT_SUPPORTED_YET +BEGIN NOT ATOMIC + DECLARE va INT; + DECLARE cur CURSOR (INOUT a INT) FOR SELECT a FROM dual; + OPEN cur(1); + FETCH cur INTO va; + CLOSE cur; + SELECT va; +END; +$$ +DELIMITER ;$$ + +--echo # +--echo # End of 10.8 tests +--echo # diff --git a/mysql-test/main/sp-inout.result b/mysql-test/main/sp-inout.result new file mode 100644 index 00000000000..a1e7ffa9799 --- /dev/null +++ b/mysql-test/main/sp-inout.result @@ -0,0 +1,2033 @@ +# +# MDEV-10654 IN, OUT, INOUT parameters in CREATE FUNCTION +# +# +# CREATE FUNCTION with IN, OUT, INOUT qualifiers +# SHOW CREATE FUNCTION +# +CREATE FUNCTION add_func(IN a INT, IN b INT, OUT c INT, INOUT d INT) RETURNS INT +BEGIN +SET c= 100; +SET d= d + 1; +RETURN a + b; +END; +$$ +SHOW CREATE FUNCTION add_func; +Function sql_mode Create Function character_set_client collation_connection Database Collation +add_func STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `add_func`(IN a INT, IN b INT, OUT c INT, INOUT d INT) RETURNS int(11) +BEGIN +SET c= 100; +SET d= d + 1; +RETURN a + b; +END latin1 latin1_swedish_ci latin1_swedish_ci +DROP FUNCTION add_func; +# +# CREATE PROCEDURE with IN, OUT, INOUT qualifiers +# SHOW CREATE PROCEDURE +# +CREATE PROCEDURE add_proc(IN a INT, IN b INT, INOUT c INT, OUT d INT) +BEGIN +SET d= a + b + c + d; +END; +$$ +SHOW CREATE PROCEDURE add_proc; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +add_proc STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `add_proc`(IN a INT, IN b INT, INOUT c INT, OUT d INT) +BEGIN +SET d= a + b + c + d; +END latin1 latin1_swedish_ci latin1_swedish_ci +DROP PROCEDURE add_proc; +# +# Call function from SELECT query +# SELECT > FUNCTION(IN) +# +CREATE FUNCTION add_func2(IN a INT, IN b INT) RETURNS INT +BEGIN +RETURN a + b; +END; +$$ +SET @a = 2; +SET @b = 3; +SELECT add_func2(@a, @b); +add_func2(@a, @b) +5 +DROP FUNCTION add_func2; +# +# Call function from SELECT query +# SELECT > FUNCTION(OUT) +# +CREATE FUNCTION add_func3(IN a INT, IN b INT, OUT c INT) RETURNS INT +BEGIN +SET c = 100; +RETURN a + b; +END; +$$ +SET @a = 2; +SET @b = 3; +SET @c = 0; +SET @res= add_func3(@a, @b, @c); +SELECT @res, @a, @b, @c; +@res @a @b @c +5 2 3 100 +SELECT add_func3(@a, @b, @c); +ERROR HY000: OUT or INOUT argument 3 for function add_func3 is not allowed here +DROP FUNCTION add_func3; +# +# Call function from SELECT query +# SELECT > FUNCTION(INOUT) +# +CREATE FUNCTION add_func4(IN a INT, IN b INT, OUT c INT, INOUT d INT) RETURNS INT +BEGIN +SET c = 100; +SET d = d + 1; +RETURN a + b; +END; +$$ +SET @a = 2; +SET @b = 3; +SET @c = 0; +SET @d = 9; +SET @res= add_func4(@a, @b, @c, @d); +SELECT @res, @a, @b, @c, @d; +@res @a @b @c @d +5 2 3 100 10 +SELECT add_func4(@a, @b, @c, @d); +ERROR HY000: OUT or INOUT argument 3 for function add_func4 is not allowed here +DROP FUNCTION add_func4; +# +# Call from procedure +# PROCEDURE(OUT) > FUNCTION(IN) +# +CREATE FUNCTION add_func2(IN a INT, IN b INT) RETURNS INT +BEGIN +RETURN a + b; +END; +$$ +CREATE PROCEDURE add_proc2(IN a INT, IN b INT, OUT c INT) +BEGIN +SET c = add_func2(a, b); +END; +$$ +SET @a = 2; +SET @b = 3; +SET @c = 0; +CALL add_proc2(@a, @b, @c); +SELECT @a, @b, @c; +@a @b @c +2 3 5 +DROP FUNCTION add_func2; +DROP PROCEDURE add_proc2; +# +# Call from procedure +# PROCEDURE(OUT) > FUNCTION(OUT) +# +CREATE FUNCTION add_func3(IN a INT, IN b INT, OUT c INT) RETURNS INT +BEGIN +SET c = 100; +RETURN a + b; +END; +$$ +CREATE PROCEDURE add_proc3(IN a INT, IN b INT, OUT c INT) +BEGIN +DECLARE res INT; +SET res = add_func3(a, b, c); +END; +$$ +SET @a = 2; +SET @b = 3; +SET @c = 0; +CALL add_proc3(@a, @b, @c); +SELECT @a, @b, @c; +@a @b @c +2 3 100 +DROP FUNCTION add_func3; +DROP PROCEDURE add_proc3; +# +# Call from procedure +# PROCEDURE(OUT) > FUNCTION(INOUT) +# +CREATE FUNCTION add_func4(IN a INT, IN b INT, OUT c INT, INOUT d INT) RETURNS INT +BEGIN +SET c = 100; +SET d = d + 1; +RETURN a + b; +END; +$$ +CREATE PROCEDURE add_proc4(IN a INT, IN b INT, OUT res INT) +BEGIN +DECLARE c INT; +DECLARE d INT; +SET d = 30; +SET res = add_func4(a, b, c, d); +SET res = c + d; +END; +$$ +SET @a = 2; +SET @b = 3; +SET @res = 0; +CALL add_proc4(@a, @b, @res); +SELECT @a, @b, @res; +@a @b @res +2 3 131 +DROP FUNCTION add_func4; +DROP PROCEDURE add_proc4; +# +# Call from procedure +# PROCEDURE(OUT) > PROCEDURE(OUT) +# +CREATE PROCEDURE add_proc(IN a INT, IN b INT, OUT c INT) +BEGIN +SET c = a + b; +END; +$$ +CREATE PROCEDURE test_proc1(IN a INT, IN b INT, OUT c INT) +BEGIN +CALL add_proc(a, b, c); +END; +$$ +SET @a = 2; +SET @b = 3; +SET @c = 0; +CALL test_proc1(@a, @b, @c); +SELECT @a, @b, @c; +@a @b @c +2 3 5 +DROP PROCEDURE add_proc; +DROP PROCEDURE test_proc1; +# +# Argument's order change +# PROCEDURE(a IN, b IN, c OUT) > FUNCTION(b IN, a IN, c OUT) +# +CREATE FUNCTION func_sub(IN b INT, IN a INT, OUT c INT) RETURNS INT +BEGIN +DECLARE res INT; +SET c = a - b; +SET res = a; +RETURN res; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, IN b INT, OUT c INT) +BEGIN +DECLARE res INT; +SET res = func_sub(b, a, c); +END; +$$ +SET @a = 2; +SET @b = 3; +SET @c = 0; +CALL proc_main(@a, @b, @c); +SELECT @a, @b, @c; +@a @b @c +2 3 -1 +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; +# +# Argument's order change +# PROCEDURE(a IN, b IN, c OUT) > FUNCTION(c OUT, b IN, a IN) +# +CREATE FUNCTION func_sub(OUT c INT, IN b INT, IN a INT) RETURNS INT +BEGIN +DECLARE res INT; +SET c = a - b; +SET res = a; +RETURN res; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, IN b INT, OUT c INT) +BEGIN +DECLARE res INT; +SET res = func_sub(c, b, a); +END; +$$ +SET @a = 2; +SET @b = 3; +SET @c = 0; +CALL proc_main(@a, @b, @c); +SELECT @a, @b, @c; +@a @b @c +2 3 -1 +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; +# +# Argument's order change +# PROCEDURE(a IN, b IN, c INOUT, d OUT) > FUNCTION(d OUT, a IN, b IN, c INOUT) +# +CREATE FUNCTION func_sub(OUT d INT, IN a INT, IN b INT, INOUT c INT) RETURNS INT +BEGIN +SET c = c + 6; +SET d = 10; +RETURN a - b; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, IN b INT, INOUT c INT, OUT d INT) +BEGIN +DECLARE res INT; +SET res = func_sub(d, a, b, c); +SET d = d + c + res; +END; +$$ +SET @a = 15; +SET @b = 5; +SET @c = 4; +SET @d= 0; +CALL proc_main(@a, @b, @c, @d); +SELECT @a, @b, @c, @d; +@a @b @c @d +15 5 10 30 +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; +# +# Argument's order change +# PROCEDURE(IN a INT, IN b INT, INOUT c INT, OUT d INT) > FUNCTION1(c INOUT INT, IN b INT) > FUNCTION2(d OUT INT, IN a INT) +# +CREATE FUNCTION func_sub1(INOUT c INT, IN b INT) RETURNS INT +BEGIN +SET c = c + b; +RETURN 0; +END; +$$ +CREATE FUNCTION func_sub2(OUT d INT, IN a INT) RETURNS INT +BEGIN +SET d = 5 + a; +RETURN 0; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, IN b INT, INOUT c INT, OUT d INT) +BEGIN +DECLARE res1 INT; +DECLARE res2 INT; +SET res1 = func_sub1(c, b); +SET res2 = func_sub2(d, a); +SET d = d + c; +END; +$$ +SET @a = 15; +SET @b = 6; +SET @c = 4; +SET @d= 0; +CALL proc_main(@a, @b, @c, @d); +SELECT @a, @b, @c, @d; +@a @b @c @d +15 6 10 30 +DROP FUNCTION func_sub1; +DROP FUNCTION func_sub2; +DROP PROCEDURE proc_main; +# +# Argument's order change +# FUNCTION1(a IN, b IN) > FUNCTION2(b IN, c OUT, a IN) +# +CREATE FUNCTION func_sub(IN b INT, OUT c INT, IN a INT) RETURNS INT +BEGIN +SET c = 100; +RETURN a + b; +END; +$$ +CREATE FUNCTION func_main(IN a INT, IN b INT) RETURNS INT +BEGIN +DECLARE c INT; +DECLARE res INT; +SET res = func_sub(b, c, a); +RETURN res + c; +END; +$$ +SET @a = 2; +SET @b = 3; +SELECT func_main(@a, @b); +func_main(@a, @b) +105 +DROP FUNCTION func_sub; +DROP FUNCTION func_main; +# +# Call procedure inside function +# FUNCTION1(a IN, b IN) > PROCEDURE(a IN, b IN, c OUT) +# +CREATE PROCEDURE proc_sub(IN a INT, IN b INT, OUT c INT) +BEGIN +SET c = a + b; +END; +$$ +CREATE FUNCTION func_main(IN b INT, IN a INT) RETURNS INT +BEGIN +DECLARE c INT; +CALL proc_sub(a, b, c); +RETURN c; +END; +$$ +SET @a = 2; +SET @b = 3; +SELECT func_main(@a, @b); +func_main(@a, @b) +5 +DROP PROCEDURE proc_sub; +DROP FUNCTION func_main; +# +# Call procedure inside function +# FUNCTION1(a IN, b IN) > PROCEDURE(a IN, b INOUT) +# +CREATE PROCEDURE proc_sub(IN a INT, INOUT b INT) +BEGIN +SET b = a + b; +END; +$$ +CREATE FUNCTION func_main(IN b INT, IN a INT) RETURNS INT +BEGIN +CALL proc_sub(a, b); +RETURN b; +END; +$$ +SET @a = 2; +SET @b = 3; +SELECT func_main(@a, @b); +func_main(@a, @b) +5 +DROP PROCEDURE proc_sub; +DROP FUNCTION func_main; +# +# Call procedure inside function +# FUNCTION1(a IN, b IN, c OUT) > PROCEDURE(a IN, b IN, c OUT) +# +CREATE PROCEDURE proc_sub(IN a INT, IN b INT, OUT c INT) +BEGIN +SET c = a + b; +END; +$$ +CREATE FUNCTION func_main(IN b INT, IN a INT, OUT c INT) RETURNS INT +BEGIN +DECLARE res INT; +CALL proc_sub(a, b, c); +RETURN 0; +END; +$$ +SET @a = 2; +SET @b = 3; +SET @c = 0; +DO func_main(@a, @b, @c); +SELECT @a, @b, @c; +@a @b @c +2 3 5 +SELECT func_main(@a, @b, @c); +ERROR HY000: OUT or INOUT argument 3 for function func_main is not allowed here +DROP PROCEDURE proc_sub; +DROP FUNCTION func_main; +# +# Call function from UPDATE query +# UPDATE <table> SET <column> = FUNCTION(a IN) +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE FUNCTION func(IN a INT) RETURNS INT +BEGIN +RETURN a * 10; +END; +$$ +SET @a = 5; +UPDATE Persons SET Age = func(@a) WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +DROP TABLE Persons; +DROP FUNCTION func; +# +# Call function from UPDATE query +# UPDATE <table> SET <column> = FUNCTION(a OUT) +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE FUNCTION func(OUT a INT) RETURNS INT +BEGIN +SET a = 5; +RETURN 80; +END; +$$ +SET @a = 0; +UPDATE Persons SET Age = func(@a) WHERE ID = 1; +ERROR HY000: OUT or INOUT argument 1 for function func is not allowed here +DROP TABLE Persons; +DROP FUNCTION func; +# +# Call function from INSERT query +# INSERT INTO <table> SELECT <val1>, <val2>, FUNCTION(a IN) +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE FUNCTION func(IN a INT) RETURNS INT +BEGIN +RETURN a * 10; +END; +$$ +SET @a = 4; +INSERT INTO Persons SELECT 4, 'DDD', func(@a); +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +DROP TABLE Persons; +DROP FUNCTION func; +# +# Call function from INSERT query +# INSERT INTO <table> SELECT <val1>, <val2>, FUNCTION(a OUT) +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE FUNCTION func(OUT a INT) RETURNS INT +BEGIN +SET a = 45; +RETURN 40; +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SET @a = 0; +INSERT INTO Persons SELECT 5, 'EEE', func(@a); +ERROR HY000: OUT or INOUT argument 1 for function func is not allowed here +DROP TABLE Persons; +DROP FUNCTION func; +# +# Call function from DELETE query +# DELETE FROM <table> WHERE <column> = FUNCTION(a IN) +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE FUNCTION func(IN a INT) RETURNS INT +BEGIN +RETURN a; +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +SET @a = 4; +DELETE FROM Persons WHERE ID = func(@a); +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +DROP TABLE Persons; +DROP FUNCTION func; +# +# Call function from DELETE query +# DELETE FROM <table> WHERE <column> = FUNCTION(a OUT) +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE FUNCTION func(OUT a INT) RETURNS INT +BEGIN +SET a = 40; +RETURN 4; +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +SET @a = 0; +DELETE FROM Persons WHERE ID = func(@a); +ERROR HY000: OUT or INOUT argument 1 for function func is not allowed here +DROP TABLE Persons; +DROP FUNCTION func; +# +# SELECT query inside function +# FUNCTION(a IN) > SELECT … FROM <table> +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE FUNCTION func_main(IN a INT) RETURNS INT +BEGIN +DECLARE c INT; +SELECT AGE INTO c FROM Persons WHERE ID = a; +RETURN c; +END; +$$ +SET @a = 3; +SELECT func_main(@a); +func_main(@a) +30 +SELECT * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +DROP TABLE Persons; +DROP FUNCTION func_main; +# +# SELECT query inside function +# FUNCTION(a OUT) > SELECT … FROM <table> +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE FUNCTION func_main(OUT a INT) RETURNS INT +BEGIN +SELECT AGE INTO a FROM Persons WHERE ID = 3; +RETURN 0; +END; +$$ +SET @a = 0; +SELECT func_main(@a); +ERROR HY000: OUT or INOUT argument 1 for function func_main is not allowed here +DROP TABLE Persons; +DROP FUNCTION func_main; +# +# SELECT query inside function +# FUNCTION(a INOUT) > SELECT … FROM <table> +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE FUNCTION func_main(INOUT a INT) RETURNS INT +BEGIN +SELECT AGE INTO a FROM Persons WHERE ID = a; +RETURN 0; +END; +$$ +SET @a = 1; +SELECT func_main(@a); +ERROR HY000: OUT or INOUT argument 1 for function func_main is not allowed here +DROP TABLE Persons; +DROP FUNCTION func_main; +# +# SELECT query inside function +# FUNCTION(a IN) > FUNCTION(a IN, b OUT) > SELECT … FROM <table> +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE FUNCTION func_sub(IN a INT, OUT b INT) RETURNS INT +BEGIN +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +$$ +CREATE FUNCTION func_main(IN a INT) RETURNS INT +BEGIN +DECLARE b INT; +DECLARE res INT; +SET res = func_sub(a, b); +RETURN b; +END; +$$ +SET @a = 2; +SELECT func_main(@a); +func_main(@a) +20 +SELECT * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP FUNCTION func_main; +# +# UPDATE query inside function +# FUNCTION(a IN) > UPDATE <table> SET … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); +CREATE FUNCTION func_main(IN a INT) RETURNS INT +BEGIN +DECLARE c INT; +UPDATE Persons SET AGE = 50 WHERE ID = a; +SELECT AGE INTO c FROM Persons WHERE ID = a; +RETURN c; +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 40 +SET @a = 5; +SELECT func_main(@a); +func_main(@a) +50 +SELECT * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 50 +DROP TABLE Persons; +DROP FUNCTION func_main; +# +# UPDATE query inside function +# FUNCTION(a IN, b OUT) > UPDATE <table> SET … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); +CREATE FUNCTION func_main(IN a INT, OUT b INT) RETURNS INT +BEGIN +UPDATE Persons SET AGE = 60 WHERE ID = a; +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +$$ +SET @a = 5; +SET @b = 0; +SELECT func_main(@a, @b); +ERROR HY000: OUT or INOUT argument 2 for function func_main is not allowed here +DROP TABLE Persons; +DROP FUNCTION func_main; +# +# UPDATE query inside function +# FUNCTION(a IN, b INOUT) > UPDATE <table> SET … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); +CREATE FUNCTION func_main(IN a INT, INOUT b INT) RETURNS INT +BEGIN +UPDATE Persons SET AGE = 60 WHERE ID = a; +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +$$ +SET @a = 5; +SET @b = 0; +SELECT func_main(@a, @b); +ERROR HY000: OUT or INOUT argument 2 for function func_main is not allowed here +DROP TABLE Persons; +DROP FUNCTION func_main; +# +# UPDATE query inside function +# FUNCTION(a IN) > FUNCTION(a IN, b OUT) > UPDATE <table> SET … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 80); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); +CREATE FUNCTION func_sub(IN a INT, OUT b INT) RETURNS INT +BEGIN +UPDATE Persons SET AGE = 10 WHERE ID = a; +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +$$ +CREATE FUNCTION func_main(IN a INT) RETURNS INT +BEGIN +DECLARE b INT; +DECLARE res INT; +SET res = func_sub(a, b); +RETURN b; +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 80 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 40 +SET @a = 1; +SELECT func_main(@a); +func_main(@a) +10 +SELECT * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 40 +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP FUNCTION func_main; +# +# INSERT query inside function +# FUNCTION(a IN) > INSERT INTO <table> VALUES … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 50); +CREATE FUNCTION func_main(IN a INT) RETURNS INT +BEGIN +DECLARE b INT; +INSERT INTO Persons VALUE (a, 'FFF', 60); +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN b; +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 50 +SET @a = 6; +SELECT func_main(@a); +func_main(@a) +60 +SELECT * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 50 +6 FFF 60 +DROP TABLE Persons; +DROP FUNCTION func_main; +# +# INSERT query inside function +# FUNCTION(a IN, b OUT) > INSERT INTO <table> VALUES … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 50); +CREATE FUNCTION func_main(IN a INT, OUT b INT) RETURNS INT +BEGIN +INSERT INTO Persons VALUE (a, 'FFF', 60); +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 50 +SET @a = 6; +SET @b = 0; +SELECT func_main(@a, @b); +ERROR HY000: OUT or INOUT argument 2 for function func_main is not allowed here +DROP TABLE Persons; +DROP FUNCTION func_main; +# +# INSERT query inside function +# FUNCTION(a IN, b INOUT) > INSERT INTO <table> VALUES … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); +CREATE FUNCTION func_main(IN a INT, INOUT b INT) RETURNS INT +BEGIN +INSERT INTO Persons VALUE (a, 'FFF', 60); +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 40 +SET @a = 6; +SET @b = 0; +SELECT func_main(@a, @b); +ERROR HY000: OUT or INOUT argument 2 for function func_main is not allowed here +DROP TABLE Persons; +DROP FUNCTION func_main; +# +# INSERT query inside function +# FUNCTION(a IN) > FUNCTION(a IN, b OUT) > INSERT INTO <table> VALUES … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); +CREATE FUNCTION func_sub(IN a INT, OUT b INT) RETURNS INT +BEGIN +INSERT INTO Persons VALUE (a, 'FFF', 60); +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +$$ +CREATE FUNCTION func_main(IN a INT) RETURNS INT +BEGIN +DECLARE b INT; +DECLARE res INT; +SET res = func_sub(a, b); +RETURN b; +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 40 +SET @a = 6; +SELECT func_main(@a); +func_main(@a) +60 +SELECT * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 40 +6 FFF 60 +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP FUNCTION func_main; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(IN) > SELECT FROM <table> … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE FUNCTION func_sub(IN a INT) RETURNS INT +BEGIN +DECLARE b INT; +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN b; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN +SET b = func_sub(a); +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +SET @a = 2; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT @b; +@b +20 +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(OUT) > SELECT FROM <table> … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE FUNCTION func_sub(IN a INT, OUT b INT) RETURNS INT +BEGIN +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN +DECLARE res INT; +SET res = func_sub(a, b); +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +SET @a = 1; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT @b; +@b +50 +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(INOUT) > SELECT FROM <table> … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE FUNCTION func_sub(IN a INT, INOUT c INT) RETURNS INT +BEGIN +DECLARE res INT; +SELECT AGE INTO res FROM Persons WHERE ID = a; +SET c = c * 100; +RETURN res; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN +DECLARE c INT; +DECLARE res INT; +SET c = 5; +SET res = func_sub(a, c); +SET b = c; +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +SET @a = 2; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT @b; +@b +500 +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(IN) > INSESRT INTO <table> … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE FUNCTION func_sub(IN a INT) RETURNS INT +BEGIN +INSERT INTO Persons VALUE (a, 'FFF', 50); +RETURN 0; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN +SET b = func_sub(a); +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +SET @a = 5; +SET @b = 1; +CALL proc_main(@a, @b); +SELECT @b; +@b +0 +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 50 +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(OUT) > INSESRT INTO <table> … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 50); +CREATE FUNCTION func_sub(IN a INT, OUT b INT) RETURNS INT +BEGIN +INSERT INTO Persons VALUE (a, 'GGG', 60); +RETURN 0; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN +DECLARE res INT; +SET res = func_sub(a, b); +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 50 +SET @a = 6; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 50 +6 GGG 60 +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(INOUT) > INSESRT INTO <table> … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 50); +INSERT INTO Persons VALUES (6, 'GGG', 60); +CREATE FUNCTION func_sub(IN a INT, INOUT c INT) RETURNS INT +BEGIN +DECLARE res INT; +INSERT INTO Persons VALUE (a, 'HHH', 70); +SET c = c * 100; +RETURN res; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN +DECLARE c INT; +DECLARE res INT; +SET c = 5; +SET res = func_sub(a, c); +SET b = c; +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 50 +6 GGG 60 +SET @a = 7; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT @b; +@b +500 +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 50 +6 GGG 60 +7 HHH 70 +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(IN) > UPDATE <table> SET … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 50); +INSERT INTO Persons VALUES (6, 'GGG', 60); +INSERT INTO Persons VALUES (7, 'HHH', 70); +CREATE FUNCTION func_sub(IN a INT) RETURNS INT +BEGIN +UPDATE Persons SET AGE = 100 WHERE ID = a; +RETURN 0; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN +SET b = func_sub(a); +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 50 +6 GGG 60 +7 HHH 70 +SET @a = 5; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 100 +6 GGG 60 +7 HHH 70 +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(OUT) > UPDATE <table> SET … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 100); +INSERT INTO Persons VALUES (6, 'GGG', 60); +INSERT INTO Persons VALUES (7, 'HHH', 70); +CREATE FUNCTION func_sub(IN a INT, OUT b INT) RETURNS INT +BEGIN +UPDATE Persons SET AGE = 100 WHERE ID = a; +SET b = 1; +RETURN 0; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN +DECLARE res INT; +SET res = func_sub(a, b); +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 100 +6 GGG 60 +7 HHH 70 +SET @a = 6; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT @b; +@b +1 +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 100 +6 GGG 100 +7 HHH 70 +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(INOUT) > UPDATE <table> SET … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 100); +INSERT INTO Persons VALUES (6, 'GGG', 100); +INSERT INTO Persons VALUES (7, 'HHH', 70); +CREATE FUNCTION func_sub(IN a INT, INOUT c INT) RETURNS INT +BEGIN +DECLARE res INT; +UPDATE Persons SET AGE = 100 WHERE ID = a; +SET c = c * 100; +RETURN res; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN +DECLARE c INT; +DECLARE res INT; +SET c = 5; +SET res = func_sub(a, c); +SET b = c; +END; +$$ +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 100 +6 GGG 100 +7 HHH 70 +SET @a = 7; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT @b; +@b +500 +SELECT * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 100 +6 GGG 100 +7 HHH 100 +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 20 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 20 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > FUNCTION(IN) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE FUNCTION func(IN a INT) RETURNS INT +BEGIN +UPDATE PersonsLog SET UpdateCount = UpdateCount+a; +RETURN 0; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN +DECLARE a INT; +DECLARE res INT; +SET a = 1; +SET res = 0; +SET res = func(a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 30 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 30 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP FUNCTION func; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > FUNCTION(OUT) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 40); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE FUNCTION func(IN age_in INT, OUT age_out INT) RETURNS INT +BEGIN +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +SET age_out = age_in + 1; +RETURN 0; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +BEFORE UPDATE ON Persons +FOR EACH ROW +BEGIN +DECLARE res INT DEFAULT (func(OLD.age, NEW.age)); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 40 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 50 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 41 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP FUNCTION func; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > FUNCTION(INOUT) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE FUNCTION func(INOUT a INT) RETURNS INT +BEGIN +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +SET a = 100; +RETURN 0; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN +DECLARE a INT; +DECLARE res INT; +SET a = 10; +SET res = 0; +SET res = func(a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 60 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 60 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP FUNCTION func; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(IN) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE PROCEDURE proc(IN a INT) +BEGIN +UPDATE PersonsLog SET UpdateCount = UpdateCount+a; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN +CALL proc(1); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 30 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 30 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP PROCEDURE proc; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE PROCEDURE proc(IN old_age INT, OUT new_age INT) +BEGIN +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +SET new_age=old_age+41; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +BEFORE UPDATE ON Persons +FOR EACH ROW +BEGIN +CALL proc(OLD.age, NEW.age); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 50 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 51 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP PROCEDURE proc; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(INOUT) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE PROCEDURE proc(INOUT a INT) +BEGIN +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +SET a = 51; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +BEFORE UPDATE ON Persons +FOR EACH ROW +BEGIN +CALL proc(NEW.age); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 50 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 51 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP PROCEDURE proc; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(IN) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE FUNCTION func(IN a INT) RETURNS INT +BEGIN +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +RETURN 0; +END; +$$ +CREATE PROCEDURE proc(OUT a INT) +BEGIN +DECLARE res INT; +SET a = 100; +SET res = func(a); +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN +CALL proc(@a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 60 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 60 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP FUNCTION func; +DROP PROCEDURE proc; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(OUT) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE FUNCTION func(OUT a INT) RETURNS INT +BEGIN +SET a = 200; +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +RETURN 0; +END; +$$ +CREATE PROCEDURE proc(OUT a INT) +BEGIN +DECLARE res INT; +SET a = 100; +SET res = func(a); +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN +CALL proc(@a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 80 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 80 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP FUNCTION func; +DROP PROCEDURE proc; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(INOUT) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE FUNCTION func(INOUT a INT) RETURNS INT +BEGIN +SET a = 200; +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +RETURN 0; +END; +$$ +CREATE PROCEDURE proc(OUT a INT) +BEGIN +DECLARE res INT; +SET a = 100; +SET res = func(a); +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN +CALL proc(@a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 90 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 90 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP FUNCTION func; +DROP PROCEDURE proc; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(OUT) > UPDATE TABLE2 with OUT argument (to check if OUT is returning by reference) +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE FUNCTION func(OUT a INT) RETURNS INT +BEGIN +SET a = 111; +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +RETURN 0; +END; +$$ +CREATE PROCEDURE proc(OUT a INT) +BEGIN +DECLARE res INT; +SET res = func(a); +UPDATE PersonsLog SET UpdateCount = a; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN +CALL proc(@a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 80 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 80 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +111 +DROP TRIGGER my_trigger; +DROP FUNCTION func; +DROP PROCEDURE proc; +DROP TABLE Persons; +DROP TABLE PersonsLog; diff --git a/mysql-test/main/sp-inout.test b/mysql-test/main/sp-inout.test new file mode 100644 index 00000000000..8f3f134b675 --- /dev/null +++ b/mysql-test/main/sp-inout.test @@ -0,0 +1,1964 @@ +--echo # +--echo # MDEV-10654 IN, OUT, INOUT parameters in CREATE FUNCTION +--echo # + + +--echo # +--echo # CREATE FUNCTION with IN, OUT, INOUT qualifiers +--echo # SHOW CREATE FUNCTION +--echo # + +DELIMITER $$; +CREATE FUNCTION add_func(IN a INT, IN b INT, OUT c INT, INOUT d INT) RETURNS INT +BEGIN + SET c= 100; + SET d= d + 1; + RETURN a + b; +END; +$$ +DELIMITER ;$$ + +SHOW CREATE FUNCTION add_func; +DROP FUNCTION add_func; + +--echo # +--echo # CREATE PROCEDURE with IN, OUT, INOUT qualifiers +--echo # SHOW CREATE PROCEDURE +--echo # + +DELIMITER $$; +CREATE PROCEDURE add_proc(IN a INT, IN b INT, INOUT c INT, OUT d INT) +BEGIN + SET d= a + b + c + d; +END; +$$ +DELIMITER ;$$ + +SHOW CREATE PROCEDURE add_proc; +DROP PROCEDURE add_proc; + +--echo # +--echo # Call function from SELECT query +--echo # SELECT > FUNCTION(IN) +--echo # + +DELIMITER $$; +CREATE FUNCTION add_func2(IN a INT, IN b INT) RETURNS INT +BEGIN + RETURN a + b; +END; +$$ +DELIMITER ;$$ + +SET @a = 2; +SET @b = 3; +SELECT add_func2(@a, @b); +DROP FUNCTION add_func2; + +--echo # +--echo # Call function from SELECT query +--echo # SELECT > FUNCTION(OUT) +--echo # + +DELIMITER $$; +CREATE FUNCTION add_func3(IN a INT, IN b INT, OUT c INT) RETURNS INT +BEGIN + SET c = 100; + RETURN a + b; +END; +$$ +DELIMITER ;$$ + +SET @a = 2; +SET @b = 3; +SET @c = 0; +SET @res= add_func3(@a, @b, @c); +SELECT @res, @a, @b, @c; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +SELECT add_func3(@a, @b, @c); +DROP FUNCTION add_func3; + +--echo # +--echo # Call function from SELECT query +--echo # SELECT > FUNCTION(INOUT) +--echo # + +DELIMITER $$; +CREATE FUNCTION add_func4(IN a INT, IN b INT, OUT c INT, INOUT d INT) RETURNS INT +BEGIN + SET c = 100; + SET d = d + 1; + RETURN a + b; +END; +$$ +DELIMITER ;$$ + +SET @a = 2; +SET @b = 3; +SET @c = 0; +SET @d = 9; +SET @res= add_func4(@a, @b, @c, @d); +SELECT @res, @a, @b, @c, @d; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +SELECT add_func4(@a, @b, @c, @d); +DROP FUNCTION add_func4; + +--echo # +--echo # Call from procedure +--echo # PROCEDURE(OUT) > FUNCTION(IN) +--echo # + +DELIMITER $$; +CREATE FUNCTION add_func2(IN a INT, IN b INT) RETURNS INT +BEGIN + RETURN a + b; +END; +$$ +CREATE PROCEDURE add_proc2(IN a INT, IN b INT, OUT c INT) +BEGIN + SET c = add_func2(a, b); +END; +$$ +DELIMITER ;$$ + +SET @a = 2; +SET @b = 3; +SET @c = 0; +CALL add_proc2(@a, @b, @c); +SELECT @a, @b, @c; +DROP FUNCTION add_func2; +DROP PROCEDURE add_proc2; + +--echo # +--echo # Call from procedure +--echo # PROCEDURE(OUT) > FUNCTION(OUT) +--echo # + +DELIMITER $$; +CREATE FUNCTION add_func3(IN a INT, IN b INT, OUT c INT) RETURNS INT +BEGIN + SET c = 100; + RETURN a + b; +END; +$$ +CREATE PROCEDURE add_proc3(IN a INT, IN b INT, OUT c INT) +BEGIN + DECLARE res INT; + SET res = add_func3(a, b, c); +END; +$$ +DELIMITER ;$$ + +SET @a = 2; +SET @b = 3; +SET @c = 0; +CALL add_proc3(@a, @b, @c); +SELECT @a, @b, @c; +DROP FUNCTION add_func3; +DROP PROCEDURE add_proc3; + +--echo # +--echo # Call from procedure +--echo # PROCEDURE(OUT) > FUNCTION(INOUT) +--echo # + +DELIMITER $$; +CREATE FUNCTION add_func4(IN a INT, IN b INT, OUT c INT, INOUT d INT) RETURNS INT +BEGIN + SET c = 100; + SET d = d + 1; + RETURN a + b; +END; +$$ +CREATE PROCEDURE add_proc4(IN a INT, IN b INT, OUT res INT) +BEGIN + DECLARE c INT; + DECLARE d INT; + SET d = 30; + SET res = add_func4(a, b, c, d); + SET res = c + d; +END; +$$ +DELIMITER ;$$ + +SET @a = 2; +SET @b = 3; +SET @res = 0; +CALL add_proc4(@a, @b, @res); +SELECT @a, @b, @res; +DROP FUNCTION add_func4; +DROP PROCEDURE add_proc4; + +--echo # +--echo # Call from procedure +--echo # PROCEDURE(OUT) > PROCEDURE(OUT) +--echo # + +DELIMITER $$; +CREATE PROCEDURE add_proc(IN a INT, IN b INT, OUT c INT) +BEGIN + SET c = a + b; +END; +$$ +CREATE PROCEDURE test_proc1(IN a INT, IN b INT, OUT c INT) +BEGIN + CALL add_proc(a, b, c); +END; +$$ +DELIMITER ;$$ + +SET @a = 2; +SET @b = 3; +SET @c = 0; +CALL test_proc1(@a, @b, @c); +SELECT @a, @b, @c; +DROP PROCEDURE add_proc; +DROP PROCEDURE test_proc1; + +--echo # +--echo # Argument's order change +--echo # PROCEDURE(a IN, b IN, c OUT) > FUNCTION(b IN, a IN, c OUT) +--echo # + +DELIMITER $$; +CREATE FUNCTION func_sub(IN b INT, IN a INT, OUT c INT) RETURNS INT +BEGIN + DECLARE res INT; + SET c = a - b; + SET res = a; + RETURN res; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, IN b INT, OUT c INT) +BEGIN + DECLARE res INT; + SET res = func_sub(b, a, c); +END; +$$ +DELIMITER ;$$ + +SET @a = 2; +SET @b = 3; +SET @c = 0; +CALL proc_main(@a, @b, @c); +SELECT @a, @b, @c; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; + +--echo # +--echo # Argument's order change +--echo # PROCEDURE(a IN, b IN, c OUT) > FUNCTION(c OUT, b IN, a IN) +--echo # + +DELIMITER $$; +CREATE FUNCTION func_sub(OUT c INT, IN b INT, IN a INT) RETURNS INT +BEGIN + DECLARE res INT; + SET c = a - b; + SET res = a; + RETURN res; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, IN b INT, OUT c INT) +BEGIN + DECLARE res INT; + SET res = func_sub(c, b, a); +END; +$$ +DELIMITER ;$$ + +SET @a = 2; +SET @b = 3; +SET @c = 0; +CALL proc_main(@a, @b, @c); +SELECT @a, @b, @c; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; + +--echo # +--echo # Argument's order change +--echo # PROCEDURE(a IN, b IN, c INOUT, d OUT) > FUNCTION(d OUT, a IN, b IN, c INOUT) +--echo # + +DELIMITER $$; +CREATE FUNCTION func_sub(OUT d INT, IN a INT, IN b INT, INOUT c INT) RETURNS INT +BEGIN + SET c = c + 6; + SET d = 10; + RETURN a - b; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, IN b INT, INOUT c INT, OUT d INT) +BEGIN + DECLARE res INT; + SET res = func_sub(d, a, b, c); + SET d = d + c + res; +END; +$$ +DELIMITER ;$$ + +SET @a = 15; +SET @b = 5; +SET @c = 4; +SET @d= 0; +CALL proc_main(@a, @b, @c, @d); +SELECT @a, @b, @c, @d; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; + +--echo # +--echo # Argument's order change +--echo # PROCEDURE(IN a INT, IN b INT, INOUT c INT, OUT d INT) > FUNCTION1(c INOUT INT, IN b INT) > FUNCTION2(d OUT INT, IN a INT) +--echo # + +DELIMITER $$; +CREATE FUNCTION func_sub1(INOUT c INT, IN b INT) RETURNS INT +BEGIN + SET c = c + b; + RETURN 0; +END; +$$ +CREATE FUNCTION func_sub2(OUT d INT, IN a INT) RETURNS INT +BEGIN + SET d = 5 + a; + RETURN 0; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, IN b INT, INOUT c INT, OUT d INT) +BEGIN + DECLARE res1 INT; + DECLARE res2 INT; + SET res1 = func_sub1(c, b); + SET res2 = func_sub2(d, a); + SET d = d + c; +END; +$$ +DELIMITER ;$$ + +SET @a = 15; +SET @b = 6; +SET @c = 4; +SET @d= 0; +CALL proc_main(@a, @b, @c, @d); +SELECT @a, @b, @c, @d; +DROP FUNCTION func_sub1; +DROP FUNCTION func_sub2; +DROP PROCEDURE proc_main; + +--echo # +--echo # Argument's order change +--echo # FUNCTION1(a IN, b IN) > FUNCTION2(b IN, c OUT, a IN) +--echo # + +DELIMITER $$; +CREATE FUNCTION func_sub(IN b INT, OUT c INT, IN a INT) RETURNS INT +BEGIN + SET c = 100; + RETURN a + b; +END; +$$ +CREATE FUNCTION func_main(IN a INT, IN b INT) RETURNS INT +BEGIN + DECLARE c INT; + DECLARE res INT; + SET res = func_sub(b, c, a); + RETURN res + c; +END; +$$ +DELIMITER ;$$ + +SET @a = 2; +SET @b = 3; +SELECT func_main(@a, @b); +DROP FUNCTION func_sub; +DROP FUNCTION func_main; + +--echo # +--echo # Call procedure inside function +--echo # FUNCTION1(a IN, b IN) > PROCEDURE(a IN, b IN, c OUT) +--echo # + +DELIMITER $$; +CREATE PROCEDURE proc_sub(IN a INT, IN b INT, OUT c INT) +BEGIN + SET c = a + b; +END; +$$ +CREATE FUNCTION func_main(IN b INT, IN a INT) RETURNS INT +BEGIN + DECLARE c INT; + CALL proc_sub(a, b, c); + RETURN c; +END; +$$ +DELIMITER ;$$ + +SET @a = 2; +SET @b = 3; +SELECT func_main(@a, @b); +DROP PROCEDURE proc_sub; +DROP FUNCTION func_main; + +--echo # +--echo # Call procedure inside function +--echo # FUNCTION1(a IN, b IN) > PROCEDURE(a IN, b INOUT) +--echo # + +DELIMITER $$; +CREATE PROCEDURE proc_sub(IN a INT, INOUT b INT) +BEGIN + SET b = a + b; +END; +$$ +CREATE FUNCTION func_main(IN b INT, IN a INT) RETURNS INT +BEGIN + CALL proc_sub(a, b); + RETURN b; +END; +$$ +DELIMITER ;$$ + +SET @a = 2; +SET @b = 3; +SELECT func_main(@a, @b); +DROP PROCEDURE proc_sub; +DROP FUNCTION func_main; + +--echo # +--echo # Call procedure inside function +--echo # FUNCTION1(a IN, b IN, c OUT) > PROCEDURE(a IN, b IN, c OUT) +--echo # + +DELIMITER $$; +CREATE PROCEDURE proc_sub(IN a INT, IN b INT, OUT c INT) +BEGIN + SET c = a + b; +END; +$$ +CREATE FUNCTION func_main(IN b INT, IN a INT, OUT c INT) RETURNS INT +BEGIN + DECLARE res INT; + CALL proc_sub(a, b, c); + RETURN 0; +END; +$$ +DELIMITER ;$$ + +SET @a = 2; +SET @b = 3; +SET @c = 0; +DO func_main(@a, @b, @c); +SELECT @a, @b, @c; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +SELECT func_main(@a, @b, @c); +DROP PROCEDURE proc_sub; +DROP FUNCTION func_main; + +--echo # +--echo # Call function from UPDATE query +--echo # UPDATE <table> SET <column> = FUNCTION(a IN) +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +DELIMITER $$; +CREATE FUNCTION func(IN a INT) RETURNS INT +BEGIN + RETURN a * 10; +END; +$$ +DELIMITER ;$$ + +SET @a = 5; +UPDATE Persons SET Age = func(@a) WHERE ID = 1; +SELECT * FROM Persons; +DROP TABLE Persons; +DROP FUNCTION func; + +--echo # +--echo # Call function from UPDATE query +--echo # UPDATE <table> SET <column> = FUNCTION(a OUT) +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +DELIMITER $$; +CREATE FUNCTION func(OUT a INT) RETURNS INT +BEGIN + SET a = 5; + RETURN 80; +END; +$$ +DELIMITER ;$$ + +SET @a = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +UPDATE Persons SET Age = func(@a) WHERE ID = 1; +DROP TABLE Persons; +DROP FUNCTION func; + +--echo # +--echo # Call function from INSERT query +--echo # INSERT INTO <table> SELECT <val1>, <val2>, FUNCTION(a IN) +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +DELIMITER $$; +CREATE FUNCTION func(IN a INT) RETURNS INT +BEGIN + RETURN a * 10; +END; +$$ +DELIMITER ;$$ + +SET @a = 4; +INSERT INTO Persons SELECT 4, 'DDD', func(@a); +SELECT * FROM Persons; +DROP TABLE Persons; +DROP FUNCTION func; + +--echo # +--echo # Call function from INSERT query +--echo # INSERT INTO <table> SELECT <val1>, <val2>, FUNCTION(a OUT) +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +DELIMITER $$; +CREATE FUNCTION func(OUT a INT) RETURNS INT +BEGIN + SET a = 45; + RETURN 40; +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SET @a = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +INSERT INTO Persons SELECT 5, 'EEE', func(@a); +DROP TABLE Persons; +DROP FUNCTION func; + +--echo # +--echo # Call function from DELETE query +--echo # DELETE FROM <table> WHERE <column> = FUNCTION(a IN) +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE FUNCTION func(IN a INT) RETURNS INT +BEGIN + RETURN a; +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SET @a = 4; +DELETE FROM Persons WHERE ID = func(@a); +SELECT * FROM Persons; +DROP TABLE Persons; +DROP FUNCTION func; + +--echo # +--echo # Call function from DELETE query +--echo # DELETE FROM <table> WHERE <column> = FUNCTION(a OUT) +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE FUNCTION func(OUT a INT) RETURNS INT +BEGIN + SET a = 40; + RETURN 4; +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SET @a = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +DELETE FROM Persons WHERE ID = func(@a); +DROP TABLE Persons; +DROP FUNCTION func; + +--echo # +--echo # SELECT query inside function +--echo # FUNCTION(a IN) > SELECT … FROM <table> +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE FUNCTION func_main(IN a INT) RETURNS INT +BEGIN + DECLARE c INT; + SELECT AGE INTO c FROM Persons WHERE ID = a; + RETURN c; +END; +$$ +DELIMITER ;$$ + +SET @a = 3; +SELECT func_main(@a); +SELECT * from Persons; +DROP TABLE Persons; +DROP FUNCTION func_main; + +--echo # +--echo # SELECT query inside function +--echo # FUNCTION(a OUT) > SELECT … FROM <table> +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE FUNCTION func_main(OUT a INT) RETURNS INT +BEGIN + SELECT AGE INTO a FROM Persons WHERE ID = 3; + RETURN 0; +END; +$$ +DELIMITER ;$$ + +SET @a = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +SELECT func_main(@a); +DROP TABLE Persons; +DROP FUNCTION func_main; + +--echo # +--echo # SELECT query inside function +--echo # FUNCTION(a INOUT) > SELECT … FROM <table> +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE FUNCTION func_main(INOUT a INT) RETURNS INT +BEGIN + SELECT AGE INTO a FROM Persons WHERE ID = a; + RETURN 0; +END; +$$ +DELIMITER ;$$ + +SET @a = 1; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +SELECT func_main(@a); +DROP TABLE Persons; +DROP FUNCTION func_main; + +--echo # +--echo # SELECT query inside function +--echo # FUNCTION(a IN) > FUNCTION(a IN, b OUT) > SELECT … FROM <table> +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE FUNCTION func_sub(IN a INT, OUT b INT) RETURNS INT +BEGIN + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; +END; +$$ +CREATE FUNCTION func_main(IN a INT) RETURNS INT +BEGIN + DECLARE b INT; + DECLARE res INT; + SET res = func_sub(a, b); + RETURN b; +END; +$$ +DELIMITER ;$$ + +SET @a = 2; +SELECT func_main(@a); +SELECT * from Persons; +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP FUNCTION func_main; + +--echo # +--echo # UPDATE query inside function +--echo # FUNCTION(a IN) > UPDATE <table> SET … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); + +DELIMITER $$; +CREATE FUNCTION func_main(IN a INT) RETURNS INT +BEGIN + DECLARE c INT; + UPDATE Persons SET AGE = 50 WHERE ID = a; + SELECT AGE INTO c FROM Persons WHERE ID = a; + RETURN c; +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 5; +SELECT func_main(@a); +SELECT * from Persons; +DROP TABLE Persons; +DROP FUNCTION func_main; + +--echo # +--echo # UPDATE query inside function +--echo # FUNCTION(a IN, b OUT) > UPDATE <table> SET … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); + +DELIMITER $$; +CREATE FUNCTION func_main(IN a INT, OUT b INT) RETURNS INT +BEGIN + UPDATE Persons SET AGE = 60 WHERE ID = a; + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; +END; +$$ +DELIMITER ;$$ + +SET @a = 5; +SET @b = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +SELECT func_main(@a, @b); +DROP TABLE Persons; +DROP FUNCTION func_main; + +--echo # +--echo # UPDATE query inside function +--echo # FUNCTION(a IN, b INOUT) > UPDATE <table> SET … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); + +DELIMITER $$; +CREATE FUNCTION func_main(IN a INT, INOUT b INT) RETURNS INT +BEGIN + UPDATE Persons SET AGE = 60 WHERE ID = a; + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; +END; +$$ +DELIMITER ;$$ + +SET @a = 5; +SET @b = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +SELECT func_main(@a, @b); +DROP TABLE Persons; +DROP FUNCTION func_main; + +--echo # +--echo # UPDATE query inside function +--echo # FUNCTION(a IN) > FUNCTION(a IN, b OUT) > UPDATE <table> SET … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 80); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); + +DELIMITER $$; +CREATE FUNCTION func_sub(IN a INT, OUT b INT) RETURNS INT +BEGIN + UPDATE Persons SET AGE = 10 WHERE ID = a; + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; +END; +$$ +CREATE FUNCTION func_main(IN a INT) RETURNS INT +BEGIN + DECLARE b INT; + DECLARE res INT; + SET res = func_sub(a, b); + RETURN b; +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 1; +SELECT func_main(@a); +SELECT * from Persons; +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP FUNCTION func_main; + + +--echo # +--echo # INSERT query inside function +--echo # FUNCTION(a IN) > INSERT INTO <table> VALUES … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 50); + +DELIMITER $$; +CREATE FUNCTION func_main(IN a INT) RETURNS INT +BEGIN + DECLARE b INT; + INSERT INTO Persons VALUE (a, 'FFF', 60); + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN b; +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 6; +SELECT func_main(@a); +SELECT * from Persons; +DROP TABLE Persons; +DROP FUNCTION func_main; + +--echo # +--echo # INSERT query inside function +--echo # FUNCTION(a IN, b OUT) > INSERT INTO <table> VALUES … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 50); + +DELIMITER $$; +CREATE FUNCTION func_main(IN a INT, OUT b INT) RETURNS INT +BEGIN + INSERT INTO Persons VALUE (a, 'FFF', 60); + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 6; +SET @b = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +SELECT func_main(@a, @b); +DROP TABLE Persons; +DROP FUNCTION func_main; + +--echo # +--echo # INSERT query inside function +--echo # FUNCTION(a IN, b INOUT) > INSERT INTO <table> VALUES … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); + +DELIMITER $$; +CREATE FUNCTION func_main(IN a INT, INOUT b INT) RETURNS INT +BEGIN + INSERT INTO Persons VALUE (a, 'FFF', 60); + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 6; +SET @b = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +SELECT func_main(@a, @b); +DROP TABLE Persons; +DROP FUNCTION func_main; + +--echo # +--echo # INSERT query inside function +--echo # FUNCTION(a IN) > FUNCTION(a IN, b OUT) > INSERT INTO <table> VALUES … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); + +DELIMITER $$; +CREATE FUNCTION func_sub(IN a INT, OUT b INT) RETURNS INT +BEGIN + INSERT INTO Persons VALUE (a, 'FFF', 60); + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; +END; +$$ +CREATE FUNCTION func_main(IN a INT) RETURNS INT +BEGIN + DECLARE b INT; + DECLARE res INT; + SET res = func_sub(a, b); + RETURN b; +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 6; +SELECT func_main(@a); +SELECT * from Persons; +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP FUNCTION func_main; + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(IN) > SELECT FROM <table> … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE FUNCTION func_sub(IN a INT) RETURNS INT +BEGIN + DECLARE b INT; + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN b; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN + SET b = func_sub(a); +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 2; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT @b; +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(OUT) > SELECT FROM <table> … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE FUNCTION func_sub(IN a INT, OUT b INT) RETURNS INT +BEGIN + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN + DECLARE res INT; + SET res = func_sub(a, b); +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 1; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT @b; +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(INOUT) > SELECT FROM <table> … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE FUNCTION func_sub(IN a INT, INOUT c INT) RETURNS INT +BEGIN + DECLARE res INT; + SELECT AGE INTO res FROM Persons WHERE ID = a; + SET c = c * 100; + RETURN res; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN + DECLARE c INT; + DECLARE res INT; + SET c = 5; + SET res = func_sub(a, c); + SET b = c; +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 2; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT @b; +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; + + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(IN) > INSESRT INTO <table> … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE FUNCTION func_sub(IN a INT) RETURNS INT +BEGIN + INSERT INTO Persons VALUE (a, 'FFF', 50); + RETURN 0; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN + SET b = func_sub(a); +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 5; +SET @b = 1; +CALL proc_main(@a, @b); +SELECT @b; +SELECT * from Persons; +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; + + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(OUT) > INSESRT INTO <table> … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 50); + +DELIMITER $$; +CREATE FUNCTION func_sub(IN a INT, OUT b INT) RETURNS INT +BEGIN + INSERT INTO Persons VALUE (a, 'GGG', 60); + RETURN 0; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN + DECLARE res INT; + SET res = func_sub(a, b); +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 6; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT * from Persons; +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; + + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(INOUT) > INSESRT INTO <table> … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 50); +INSERT INTO Persons VALUES (6, 'GGG', 60); + +DELIMITER $$; +CREATE FUNCTION func_sub(IN a INT, INOUT c INT) RETURNS INT +BEGIN + DECLARE res INT; + INSERT INTO Persons VALUE (a, 'HHH', 70); + SET c = c * 100; + RETURN res; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN + DECLARE c INT; + DECLARE res INT; + SET c = 5; + SET res = func_sub(a, c); + SET b = c; +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 7; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT @b; +SELECT * from Persons; +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; + + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(IN) > UPDATE <table> SET … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 50); +INSERT INTO Persons VALUES (6, 'GGG', 60); +INSERT INTO Persons VALUES (7, 'HHH', 70); + +DELIMITER $$; +CREATE FUNCTION func_sub(IN a INT) RETURNS INT +BEGIN + UPDATE Persons SET AGE = 100 WHERE ID = a; + RETURN 0; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN + SET b = func_sub(a); +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 5; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT * from Persons; +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(OUT) > UPDATE <table> SET … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 100); +INSERT INTO Persons VALUES (6, 'GGG', 60); +INSERT INTO Persons VALUES (7, 'HHH', 70); + +DELIMITER $$; +CREATE FUNCTION func_sub(IN a INT, OUT b INT) RETURNS INT +BEGIN + UPDATE Persons SET AGE = 100 WHERE ID = a; + SET b = 1; + RETURN 0; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN + DECLARE res INT; + SET res = func_sub(a, b); +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 6; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT @b; +SELECT * from Persons; +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; + + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(INOUT) > UPDATE <table> SET … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 100); +INSERT INTO Persons VALUES (6, 'GGG', 100); +INSERT INTO Persons VALUES (7, 'HHH', 70); + +DELIMITER $$; +CREATE FUNCTION func_sub(IN a INT, INOUT c INT) RETURNS INT +BEGIN + DECLARE res INT; + UPDATE Persons SET AGE = 100 WHERE ID = a; + SET c = c * 100; + RETURN res; +END; +$$ +CREATE PROCEDURE proc_main(IN a INT, OUT b INT) +BEGIN + DECLARE c INT; + DECLARE res INT; + SET c = 5; + SET res = func_sub(a, c); + SET b = c; +END; +$$ +DELIMITER ;$$ + +SELECT * from Persons; +SET @a = 7; +SET @b = 0; +CALL proc_main(@a, @b); +SELECT @b; +SELECT * from Persons; +DROP TABLE Persons; +DROP FUNCTION func_sub; +DROP PROCEDURE proc_main; + + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 20 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > FUNCTION(IN) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE FUNCTION func(IN a INT) RETURNS INT +BEGIN + UPDATE PersonsLog SET UpdateCount = UpdateCount+a; + RETURN 0; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN + DECLARE a INT; + DECLARE res INT; + SET a = 1; + SET res = 0; + SET res = func(a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 30 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP FUNCTION func; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > FUNCTION(OUT) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 40); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE FUNCTION func(IN age_in INT, OUT age_out INT) RETURNS INT +BEGIN + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + SET age_out = age_in + 1; + RETURN 0; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +BEFORE UPDATE ON Persons +FOR EACH ROW +BEGIN + DECLARE res INT DEFAULT (func(OLD.age, NEW.age)); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 50 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP FUNCTION func; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > FUNCTION(INOUT) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE FUNCTION func(INOUT a INT) RETURNS INT +BEGIN + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + SET a = 100; + RETURN 0; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN + DECLARE a INT; + DECLARE res INT; + SET a = 10; + SET res = 0; + SET res = func(a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 60 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP FUNCTION func; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(IN) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE PROCEDURE proc(IN a INT) +BEGIN + UPDATE PersonsLog SET UpdateCount = UpdateCount+a; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN + CALL proc(1); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 30 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP PROCEDURE proc; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE PROCEDURE proc(IN old_age INT, OUT new_age INT) +BEGIN + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + SET new_age=old_age+41; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +BEFORE UPDATE ON Persons +FOR EACH ROW +BEGIN + CALL proc(OLD.age, NEW.age); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 50 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP PROCEDURE proc; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(INOUT) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE PROCEDURE proc(INOUT a INT) +BEGIN + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + SET a = 51; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +BEFORE UPDATE ON Persons +FOR EACH ROW +BEGIN + CALL proc(NEW.age); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 50 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP PROCEDURE proc; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(IN) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE FUNCTION func(IN a INT) RETURNS INT +BEGIN + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + RETURN 0; +END; +$$ +CREATE PROCEDURE proc(OUT a INT) +BEGIN + DECLARE res INT; + SET a = 100; + SET res = func(a); +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN + CALL proc(@a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 60 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP FUNCTION func; +DROP PROCEDURE proc; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(OUT) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE FUNCTION func(OUT a INT) RETURNS INT +BEGIN + SET a = 200; + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + RETURN 0; +END; +$$ +CREATE PROCEDURE proc(OUT a INT) +BEGIN + DECLARE res INT; + SET a = 100; + SET res = func(a); +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN + CALL proc(@a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 80 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP FUNCTION func; +DROP PROCEDURE proc; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(INOUT) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE FUNCTION func(INOUT a INT) RETURNS INT +BEGIN + SET a = 200; + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + RETURN 0; +END; +$$ +CREATE PROCEDURE proc(OUT a INT) +BEGIN + DECLARE res INT; + SET a = 100; + SET res = func(a); +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN + CALL proc(@a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 90 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP FUNCTION func; +DROP PROCEDURE proc; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(OUT) > UPDATE TABLE2 with OUT argument (to check if OUT is returning by reference) +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE FUNCTION func(OUT a INT) RETURNS INT +BEGIN + SET a = 111; + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + RETURN 0; +END; +$$ +CREATE PROCEDURE proc(OUT a INT) +BEGIN + DECLARE res INT; + SET res = func(a); + UPDATE PersonsLog SET UpdateCount = a; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN + CALL proc(@a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 80 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP FUNCTION func; +DROP PROCEDURE proc; +DROP TABLE Persons; +DROP TABLE PersonsLog; diff --git a/mysql-test/main/statistics.result b/mysql-test/main/statistics.result index 8677b992b03..5ecb439bacc 100644 --- a/mysql-test/main/statistics.result +++ b/mysql-test/main/statistics.result @@ -1,9 +1,11 @@ -drop table if exists t1,t2; +set @SINGLE_PREC_TYPE='single_prec_hb'; +set @DOUBLE_PREC_TYPE='double_prec_hb'; +set @DEFAULT_HIST_TYPE='double_prec_hb'; set @save_use_stat_tables=@@use_stat_tables; set @save_histogram_size=@@global.histogram_size; set @@global.histogram_size=0,@@local.histogram_size=0; -set @save_hist_type=@@histogram_type; -set histogram_type='single_prec_hb'; +set @save_hist_type=@DEFAULT_HIST_TYPE; +set histogram_type=@SINGLE_PREC_TYPE; DELETE FROM mysql.table_stats; DELETE FROM mysql.column_stats; DELETE FROM mysql.index_stats; @@ -220,18 +222,19 @@ test.t1 analyze status Table is already up to date SELECT db_name, table_name, column_name, min_value, max_value, nulls_ratio, avg_frequency, -hist_size, hist_type, HEX(histogram) -FROM mysql.column_stats; -db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram) -test t1 a 0 49 0.0000 1.0000 4 SINGLE_PREC_HB 2E62A1D0 -test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 SINGLE_PREC_HB 003FBFFF -test t1 c aaaa dddddddd 0.1250 7.0000 4 SINGLE_PREC_HB 0055AAFF -test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 SINGLE_PREC_HB 001919FF -test t1 e 0.01 0.112 0.2250 6.2000 4 SINGLE_PREC_HB 000564E1 -test t1 f 1 5 0.2000 6.4000 4 SINGLE_PREC_HB 3F7FBFBF +hist_size, hist_type, decode_histogram(hist_type,histogram) +FROM mysql.column_stats +ORDER BY db_name, table_name, column_name; +db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type decode_histogram(hist_type,histogram) +test t1 a 0 49 0.0000 1.0000 4 SINGLE_PREC_HB 0.180,0.204,0.247,0.184,0.184 +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 SINGLE_PREC_HB 0.000,0.247,0.502,0.251,0.000 +test t1 c aaaa dddddddd 0.1250 7.0000 4 SINGLE_PREC_HB 0.000,0.333,0.333,0.333,0.000 +test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 SINGLE_PREC_HB 0.000,0.098,0.000,0.902,0.000 +test t1 e 0.01 0.112 0.2250 6.2000 4 SINGLE_PREC_HB 0.000,0.020,0.373,0.490,0.118 +test t1 f 1 5 0.2000 6.4000 4 SINGLE_PREC_HB 0.247,0.251,0.251,0.000,0.251 DELETE FROM mysql.column_stats; set histogram_size=8; -set histogram_type='DOUBLE_PREC_HB'; +set histogram_type=@DOUBLE_PREC_TYPE; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected @@ -239,18 +242,19 @@ test.t1 analyze status Table is already up to date SELECT db_name, table_name, column_name, min_value, max_value, nulls_ratio, avg_frequency, -hist_size, hist_type, HEX(histogram) -FROM mysql.column_stats; -db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram) -test t1 a 0 49 0.0000 1.0000 8 DOUBLE_PREC_HB 052F4363F4A1F9D0 -test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 8 DOUBLE_PREC_HB 0000FF3FFFBFFFFF -test t1 c aaaa dddddddd 0.1250 7.0000 8 DOUBLE_PREC_HB 00005555AAAAFFFF -test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 8 DOUBLE_PREC_HB 0000031A031AFFFF -test t1 e 0.01 0.112 0.2250 6.2000 8 DOUBLE_PREC_HB 000005056464E1E1 -test t1 f 1 5 0.2000 6.4000 8 DOUBLE_PREC_HB FF3FFF7FFFBFFFBF +hist_size, hist_type, decode_histogram(hist_type,histogram) +FROM mysql.column_stats +ORDER BY db_name, table_name, column_name; +db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type decode_histogram(hist_type,histogram) +test t1 a 0 49 0.0000 1.0000 8 DOUBLE_PREC_HB 0.18367,0.20407,0.24489,0.18367,0.18369 +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 8 DOUBLE_PREC_HB 0.00000,0.24999,0.50001,0.25000,0.00000 +test t1 c aaaa dddddddd 0.1250 7.0000 8 DOUBLE_PREC_HB 0.00000,0.33333,0.33333,0.33333,0.00000 +test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 8 DOUBLE_PREC_HB 0.00000,0.10161,0.00000,0.89839,0.00000 +test t1 e 0.01 0.112 0.2250 6.2000 8 DOUBLE_PREC_HB 0.00000,0.01961,0.37255,0.49020,0.11765 +test t1 f 1 5 0.2000 6.4000 8 DOUBLE_PREC_HB 0.24999,0.25000,0.25000,0.00000,0.25000 DELETE FROM mysql.column_stats; set histogram_size= 0; -set histogram_type='single_prec_hb'; +set histogram_type=@SINGLE_PREC_TYPE; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected @@ -1476,13 +1480,13 @@ WORLD_INNODB COUNTRYLANGUAGE Percentage 1 2.7640 use world; set use_stat_tables='preferably'; set histogram_size=100; -set histogram_type='SINGLE_PREC_HB'; +set histogram_type=@SINGLE_PREC_TYPE; ANALYZE TABLE CountryLanguage; set histogram_size=254; -set histogram_type='DOUBLE_PREC_HB'; +set histogram_type=@DOUBLE_PREC_TYPE; ANALYZE TABLE City; FLUSH TABLES; -select UPPER(db_name),UPPER(table_name),UPPER(column_name),min_value,max_value,nulls_ratio,avg_length,avg_frequency,hist_size,hist_type,hex(histogram),decode_histogram(hist_type,histogram) from mysql.column_stats where UPPER(db_name)='WORLD' and UPPER(table_name)='COUNTRYLANGUAGE' and UPPER(column_name) = 'PERCENTAGE';; +select UPPER(db_name),UPPER(table_name),UPPER(column_name),min_value,max_value,nulls_ratio,avg_length,avg_frequency,hist_size,hist_type,decode_histogram(hist_type,histogram) from mysql.column_stats where UPPER(db_name)='WORLD' and UPPER(table_name)='COUNTRYLANGUAGE' and UPPER(column_name) = 'PERCENTAGE';; UPPER(db_name) WORLD UPPER(table_name) COUNTRYLANGUAGE UPPER(column_name) PERCENTAGE @@ -1493,9 +1497,8 @@ avg_length 4.0000 avg_frequency 2.7640 hist_size 100 hist_type SINGLE_PREC_HB -hex(histogram) 0000000000000000000000000101010101010101010202020303030304040404050505050606070707080809090A0A0B0C0D0D0E0E0F10111213131415161718191B1C1E202224292A2E33373B4850575F6A76818C9AA7B9C4CFDADFE5EBF0F4F8FAFCFF decode_histogram(hist_type,histogram) 0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.004,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.004,0.000,0.000,0.004,0.000,0.000,0.000,0.004,0.000,0.000,0.000,0.004,0.000,0.000,0.000,0.004,0.000,0.004,0.000,0.000,0.004,0.000,0.004,0.000,0.004,0.000,0.004,0.004,0.004,0.000,0.004,0.000,0.004,0.004,0.004,0.004,0.004,0.000,0.004,0.004,0.004,0.004,0.004,0.004,0.008,0.004,0.008,0.008,0.008,0.008,0.020,0.004,0.016,0.020,0.016,0.016,0.051,0.031,0.027,0.031,0.043,0.047,0.043,0.043,0.055,0.051,0.071,0.043,0.043,0.043,0.020,0.024,0.024,0.020,0.016,0.016,0.008,0.008,0.012,0.000 -select UPPER(db_name),UPPER(table_name),UPPER(column_name),min_value,max_value,nulls_ratio,avg_length,avg_frequency,hist_size,hist_type,hex(histogram),decode_histogram(hist_type,histogram) from mysql.column_stats where UPPER(db_name)='WORLD' and UPPER(table_name)='CITY' and UPPER(column_name) = 'POPULATION';; +select UPPER(db_name),UPPER(table_name),UPPER(column_name),min_value,max_value,nulls_ratio,avg_length,avg_frequency,hist_size,hist_type,decode_histogram(hist_type,histogram) from mysql.column_stats where UPPER(db_name)='WORLD' and UPPER(table_name)='CITY' and UPPER(column_name) = 'POPULATION';; UPPER(db_name) WORLD UPPER(table_name) CITY UPPER(column_name) POPULATION @@ -1506,9 +1509,8 @@ avg_length 4.0000 avg_frequency 1.0467 hist_size 254 hist_type DOUBLE_PREC_HB -hex(histogram) 1F00A1002B023002350238023F02430249024E02520258025D02630268026E02720276027B02800285028C02920297029D02A102A802AC02B402BC02C402CC02D302DA02E302EA02F102F802010305030C03120319031F03290333033D0343034F03590363036D037803840390039A03A603B303C303D103E003F203020412042404330440045304600472047F049104A204B804C804DE04F2040A0526053F0558056F058E05B305D905F4051306380667068406AB06DA06020731075C079407C507F8072E085E08A508DF0824096909CC092E0A760AD50A400BA90B150CAD0C310D240E130F0E103B11B9126B14F0166B192F1CB71FFF240630483FC567 decode_histogram(hist_type,histogram) 0.00047,0.00198,0.00601,0.00008,0.00008,0.00005,0.00011,0.00006,0.00009,0.00008,0.00006,0.00009,0.00008,0.00009,0.00008,0.00009,0.00006,0.00006,0.00008,0.00008,0.00008,0.00011,0.00009,0.00008,0.00009,0.00006,0.00011,0.00006,0.00012,0.00012,0.00012,0.00012,0.00011,0.00011,0.00014,0.00011,0.00011,0.00011,0.00014,0.00006,0.00011,0.00009,0.00011,0.00009,0.00015,0.00015,0.00015,0.00009,0.00018,0.00015,0.00015,0.00015,0.00017,0.00018,0.00018,0.00015,0.00018,0.00020,0.00024,0.00021,0.00023,0.00027,0.00024,0.00024,0.00027,0.00023,0.00020,0.00029,0.00020,0.00027,0.00020,0.00027,0.00026,0.00034,0.00024,0.00034,0.00031,0.00037,0.00043,0.00038,0.00038,0.00035,0.00047,0.00056,0.00058,0.00041,0.00047,0.00056,0.00072,0.00044,0.00060,0.00072,0.00061,0.00072,0.00066,0.00085,0.00075,0.00078,0.00082,0.00073,0.00108,0.00089,0.00105,0.00105,0.00151,0.00150,0.00110,0.00145,0.00163,0.00160,0.00165,0.00232,0.00201,0.00371,0.00365,0.00383,0.00459,0.00583,0.00662,0.00984,0.00969,0.01080,0.01379,0.02063,0.04308,0.05960,0.15816,0.59464 -set histogram_type='single_prec_hb'; +set histogram_type=@SINGLE_PREC_TYPE; set histogram_size=0; use test; DROP DATABASE world; @@ -1575,10 +1577,11 @@ test.t1 analyze status OK select db_name, table_name, column_name, min_value, max_value, nulls_ratio, avg_frequency, -hist_size, hist_type, HEX(histogram) -FROM mysql.column_stats; -db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram) -test t1 a 1 3 0.0000 1.0000 10 SINGLE_PREC_HB 0000007F7F7F7FFFFFFF +hist_size, hist_type, decode_histogram(hist_type,histogram) +FROM mysql.column_stats +ORDER BY db_name, table_name, column_name; +db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type decode_histogram(hist_type,histogram) +test t1 a 1 3 0.0000 1.0000 10 SINGLE_PREC_HB 0.000,0.000,0.000,0.498,0.000,0.000,0.000,0.502,0.000,0.000,0.000 set histogram_size=default; drop table t1; # @@ -1588,7 +1591,7 @@ drop table t1; create table t1 ( a int); insert into t1 values (1),(2),(3),(4),(5); set histogram_size=10; -set histogram_type='double_prec_hb'; +set histogram_type=@DOUBLE_PREC_TYPE; show variables like 'histogram%'; Variable_name Value histogram_size 10 @@ -1600,12 +1603,13 @@ test.t1 analyze status OK select db_name, table_name, column_name, min_value, max_value, nulls_ratio, avg_frequency, -hist_size, hist_type, HEX(histogram) -FROM mysql.column_stats; -db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram) -test t1 a 1 5 0.0000 1.0000 10 DOUBLE_PREC_HB 0000FF3FFF7FFFBFFFFF +hist_size, hist_type, decode_histogram(hist_type,histogram) +FROM mysql.column_stats +ORDER BY db_name, table_name, column_name; +db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type decode_histogram(hist_type,histogram) +test t1 a 1 5 0.0000 1.0000 10 DOUBLE_PREC_HB 0.00000,0.24999,0.25000,0.25000,0.25000,0.00000 set histogram_size=0; -set histogram_type='single_prec_hb'; +set histogram_type=@SINGLE_PREC_TYPE; drop table t1; # # Bug mdev-4369: histogram for a column with many distinct values @@ -1641,10 +1645,10 @@ test.t2 analyze status OK select db_name, table_name, column_name, min_value, max_value, nulls_ratio, avg_frequency, -hist_size, hist_type, HEX(histogram) +hist_size, hist_type, decode_histogram(hist_type,histogram) FROM mysql.column_stats; -db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram) -test t2 id 1 1024 0.0000 8.0000 63 SINGLE_PREC_HB 03070B0F13171B1F23272B2F33373B3F43474B4F53575B5F63676B6F73777B7F83878B8F93979B9FA3A7ABAFB3B7BBBFC3C7CBCFD3D7DBDFE3E7EBEFF3F7FB +db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type decode_histogram(hist_type,histogram) +test t2 id 1 1024 0.0000 8.0000 63 SINGLE_PREC_HB 0.012,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016,0.016 set histogram_size=0; drop table t1, t2; set use_stat_tables=@save_use_stat_tables; @@ -1662,9 +1666,9 @@ Level Code Message select db_name, table_name, column_name, HEX(min_value), HEX(max_value), nulls_ratio, avg_frequency, -hist_size, hist_type, HEX(histogram) +hist_size, hist_type, decode_histogram(hist_type,histogram) FROM mysql.column_stats; -db_name table_name column_name HEX(min_value) HEX(max_value) nulls_ratio avg_frequency hist_size hist_type HEX(histogram) +db_name table_name column_name HEX(min_value) HEX(max_value) nulls_ratio avg_frequency hist_size hist_type decode_histogram(hist_type,histogram) test t1 a D879626AF872675F73E662F8 D879626AF872675F73E662F8 0.0000 1.0000 0 NULL NULL drop table t1; # @@ -1760,12 +1764,12 @@ set use_stat_tables=@save_use_stat_tables; # # MDEV-10134 Add full support for DEFAULT # -CREATE TABLE t1 (a BLOB, b TEXT DEFAULT DECODE_HISTOGRAM('SINGLE_PREC_HB',a)); +CREATE TABLE t1 (a BLOB, b TEXT DEFAULT DECODE_HISTOGRAM(@SINGLE_PREC_TYPE,a)); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `a` blob DEFAULT NULL, - `b` text DEFAULT decode_histogram('SINGLE_PREC_HB',`a`) + `b` text DEFAULT decode_histogram(@`SINGLE_PREC_TYPE`,`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 (a) VALUES (0x0000000000000000000000000101010101010101010202020303030304040404050505050606070707080809090A0A0B0C0D0D0E0E0F10111213131415161718191B1C1E202224292A2E33373B4850575F6A76818C9AA7B9C4CFDADFE5EBF0F4F8FAFCFF); SELECT b FROM t1; @@ -1878,6 +1882,7 @@ t1 id 1 17384 0.0000 4.0000 14.0000 0.15705,0.15711,0.21463,0.15705,0.15711,0.15 explain select * from t1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 229376 +drop table t0; drop table t1; set analyze_sample_percentage=@save_analyze_sample_percentage; set histogram_size=@save_histogram_size; diff --git a/mysql-test/main/statistics.test b/mysql-test/main/statistics.test index 8d9ef79b69f..525836abba8 100644 --- a/mysql-test/main/statistics.test +++ b/mysql-test/main/statistics.test @@ -1,15 +1,22 @@ --source include/no_valgrind_without_big.inc --source include/have_stat_tables.inc --source include/have_innodb.inc ---disable_warnings -drop table if exists t1,t2; ---enable_warnings + +set @SINGLE_PREC_TYPE='single_prec_hb'; +set @DOUBLE_PREC_TYPE='double_prec_hb'; +set @DEFAULT_HIST_TYPE='double_prec_hb'; + +if ($histogram_type_override) { + eval set @SINGLE_PREC_TYPE=$histogram_type_override; + eval set @DOUBLE_PREC_TYPE=$histogram_type_override; + eval set @DEFAULT_HIST_TYPE=$histogram_type_override; +} set @save_use_stat_tables=@@use_stat_tables; set @save_histogram_size=@@global.histogram_size; set @@global.histogram_size=0,@@local.histogram_size=0; -set @save_hist_type=@@histogram_type; -set histogram_type='single_prec_hb'; +set @save_hist_type=@DEFAULT_HIST_TYPE; +set histogram_type=@SINGLE_PREC_TYPE; DELETE FROM mysql.table_stats; --sorted_result @@ -82,6 +89,7 @@ SELECT * FROM mysql.index_stats; SELECT COUNT(*) FROM t1; + SELECT * FROM mysql.column_stats WHERE db_name='test' AND table_name='t1' AND column_name='a'; SELECT MIN(t1.a), MAX(t1.a), @@ -178,30 +186,32 @@ DELETE FROM mysql.column_stats; set histogram_size=4; ANALYZE TABLE t1; ---sorted_result +--source include/histogram_replaces.inc SELECT db_name, table_name, column_name, min_value, max_value, nulls_ratio, avg_frequency, - hist_size, hist_type, HEX(histogram) - FROM mysql.column_stats; + hist_size, hist_type, decode_histogram(hist_type,histogram) +FROM mysql.column_stats +ORDER BY db_name, table_name, column_name; DELETE FROM mysql.column_stats; set histogram_size=8; -set histogram_type='DOUBLE_PREC_HB'; +set histogram_type=@DOUBLE_PREC_TYPE; ANALYZE TABLE t1; ---sorted_result +--source include/histogram_replaces.inc SELECT db_name, table_name, column_name, min_value, max_value, nulls_ratio, avg_frequency, - hist_size, hist_type, HEX(histogram) - FROM mysql.column_stats; + hist_size, hist_type, decode_histogram(hist_type,histogram) +FROM mysql.column_stats +ORDER BY db_name, table_name, column_name; DELETE FROM mysql.column_stats; set histogram_size= 0; -set histogram_type='single_prec_hb'; +set histogram_type=@SINGLE_PREC_TYPE; ANALYZE TABLE t1; @@ -653,20 +663,22 @@ use world; set use_stat_tables='preferably'; --disable_result_log set histogram_size=100; -set histogram_type='SINGLE_PREC_HB'; +set histogram_type=@SINGLE_PREC_TYPE; ANALYZE TABLE CountryLanguage; set histogram_size=254; -set histogram_type='DOUBLE_PREC_HB'; +set histogram_type=@DOUBLE_PREC_TYPE; ANALYZE TABLE City; FLUSH TABLES; --enable_result_log --disable_view_protocol ---query_vertical select UPPER(db_name),UPPER(table_name),UPPER(column_name),min_value,max_value,nulls_ratio,avg_length,avg_frequency,hist_size,hist_type,hex(histogram),decode_histogram(hist_type,histogram) from mysql.column_stats where UPPER(db_name)='WORLD' and UPPER(table_name)='COUNTRYLANGUAGE' and UPPER(column_name) = 'PERCENTAGE'; ---query_vertical select UPPER(db_name),UPPER(table_name),UPPER(column_name),min_value,max_value,nulls_ratio,avg_length,avg_frequency,hist_size,hist_type,hex(histogram),decode_histogram(hist_type,histogram) from mysql.column_stats where UPPER(db_name)='WORLD' and UPPER(table_name)='CITY' and UPPER(column_name) = 'POPULATION'; +--source include/histogram_replaces.inc +--query_vertical select UPPER(db_name),UPPER(table_name),UPPER(column_name),min_value,max_value,nulls_ratio,avg_length,avg_frequency,hist_size,hist_type,decode_histogram(hist_type,histogram) from mysql.column_stats where UPPER(db_name)='WORLD' and UPPER(table_name)='COUNTRYLANGUAGE' and UPPER(column_name) = 'PERCENTAGE'; +--source include/histogram_replaces.inc +--query_vertical select UPPER(db_name),UPPER(table_name),UPPER(column_name),min_value,max_value,nulls_ratio,avg_length,avg_frequency,hist_size,hist_type,decode_histogram(hist_type,histogram) from mysql.column_stats where UPPER(db_name)='WORLD' and UPPER(table_name)='CITY' and UPPER(column_name) = 'POPULATION'; --enable_view_protocol -set histogram_type='single_prec_hb'; +set histogram_type=@SINGLE_PREC_TYPE; set histogram_size=0; use test; @@ -710,11 +722,13 @@ set histogram_size=10; analyze table t1 persistent for all; +--source include/histogram_replaces.inc select db_name, table_name, column_name, min_value, max_value, nulls_ratio, avg_frequency, - hist_size, hist_type, HEX(histogram) - FROM mysql.column_stats; + hist_size, hist_type, decode_histogram(hist_type,histogram) +FROM mysql.column_stats +ORDER BY db_name, table_name, column_name; set histogram_size=default; @@ -729,20 +743,22 @@ create table t1 ( a int); insert into t1 values (1),(2),(3),(4),(5); set histogram_size=10; -set histogram_type='double_prec_hb'; +set histogram_type=@DOUBLE_PREC_TYPE; show variables like 'histogram%'; analyze table t1 persistent for all; +--source include/histogram_replaces.inc select db_name, table_name, column_name, min_value, max_value, nulls_ratio, avg_frequency, - hist_size, hist_type, HEX(histogram) - FROM mysql.column_stats; + hist_size, hist_type, decode_histogram(hist_type,histogram) +FROM mysql.column_stats +ORDER BY db_name, table_name, column_name; set histogram_size=0; -set histogram_type='single_prec_hb'; +set histogram_type=@SINGLE_PREC_TYPE; drop table t1; @@ -779,10 +795,11 @@ set histogram_size=63; analyze table t2 persistent for all; +--source include/histogram_replaces.inc select db_name, table_name, column_name, min_value, max_value, nulls_ratio, avg_frequency, - hist_size, hist_type, HEX(histogram) + hist_size, hist_type, decode_histogram(hist_type,histogram) FROM mysql.column_stats; set histogram_size=0; @@ -800,10 +817,11 @@ insert into t1 values(unhex('D879626AF872675F73E662F8')); analyze table t1 persistent for all; show warnings; +--source include/histogram_replaces.inc select db_name, table_name, column_name, HEX(min_value), HEX(max_value), nulls_ratio, avg_frequency, - hist_size, hist_type, HEX(histogram) + hist_size, hist_type, decode_histogram(hist_type,histogram) FROM mysql.column_stats; drop table t1; @@ -913,11 +931,14 @@ set use_stat_tables=@save_use_stat_tables; --echo # MDEV-10134 Add full support for DEFAULT --echo # -CREATE TABLE t1 (a BLOB, b TEXT DEFAULT DECODE_HISTOGRAM('SINGLE_PREC_HB',a)); +# disable for JSON histograms +if (!$histogram_type_override) { +CREATE TABLE t1 (a BLOB, b TEXT DEFAULT DECODE_HISTOGRAM(@SINGLE_PREC_TYPE,a)); SHOW CREATE TABLE t1; INSERT INTO t1 (a) VALUES (0x0000000000000000000000000101010101010101010202020303030304040404050505050606070707080809090A0A0B0C0D0D0E0E0F10111213131415161718191B1C1E202224292A2E33373B4850575F6A76818C9AA7B9C4CFDADFE5EBF0F4F8FAFCFF); SELECT b FROM t1; DROP TABLE t1; +} --echo # --echo # End of 10.2 tests @@ -964,6 +985,7 @@ INSERT INTO t1 SELECT id+9192 FROM t1; --echo # This query will should show a full table scan analysis. --echo # ANALYZE TABLE t1; +--source include/histogram_replaces.inc select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency, DECODE_HISTOGRAM(hist_type, histogram) from mysql.column_stats; @@ -974,6 +996,7 @@ set analyze_sample_percentage=0.1; --echo # This query will show an innacurate avg_frequency value. --echo # ANALYZE TABLE t1; +--source include/histogram_replaces.inc select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency, DECODE_HISTOGRAM(hist_type, histogram) from mysql.column_stats; @@ -983,6 +1006,7 @@ from mysql.column_stats; --echo # set analyze_sample_percentage=25; ANALYZE TABLE t1; +--source include/histogram_replaces.inc select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency, DECODE_HISTOGRAM(hist_type, histogram) from mysql.column_stats; @@ -993,6 +1017,7 @@ set analyze_sample_percentage=0; --echo # Test self adjusting sampling level. --echo # ANALYZE TABLE t1; +--source include/histogram_replaces.inc select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency, DECODE_HISTOGRAM(hist_type, histogram) from mysql.column_stats; @@ -1004,12 +1029,13 @@ explain select * from t1; set analyze_sample_percentage=100; ANALYZE TABLE t1; +--source include/histogram_replaces.inc select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency, DECODE_HISTOGRAM(hist_type, histogram) from mysql.column_stats; explain select * from t1; - +drop table t0; drop table t1; set analyze_sample_percentage=@save_analyze_sample_percentage; set histogram_size=@save_histogram_size; diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result new file mode 100644 index 00000000000..748287152b1 --- /dev/null +++ b/mysql-test/main/statistics_json.result @@ -0,0 +1,8354 @@ +# +# Test that we can store JSON arrays in histogram field mysql.column_stats when histogram_type=JSON +# +set @SINGLE_PREC_TYPE='single_prec_hb'; +set @DOUBLE_PREC_TYPE='double_prec_hb'; +set @DEFAULT_HIST_TYPE='double_prec_hb'; +set @SINGLE_PREC_TYPE='JSON_HB'; +set @DOUBLE_PREC_TYPE='JSON_HB'; +set @DEFAULT_HIST_TYPE='JSON_HB'; +set @save_use_stat_tables=@@use_stat_tables; +set @save_histogram_size=@@global.histogram_size; +set @@global.histogram_size=0,@@local.histogram_size=0; +set @save_hist_type=@DEFAULT_HIST_TYPE; +set histogram_type=@SINGLE_PREC_TYPE; +DELETE FROM mysql.table_stats; +DELETE FROM mysql.column_stats; +DELETE FROM mysql.index_stats; +set use_stat_tables='preferably'; +CREATE TABLE t1 ( +a int NOT NULL PRIMARY KEY, +b varchar(32), +c char(16), +d date, +e double, +f bit(3), +INDEX idx1 (b, e), +INDEX idx2 (c, d), +INDEX idx3 (d), +INDEX idx4 (e, b, d) +) ENGINE= MYISAM; +INSERT INTO t1 VALUES +(0, NULL, NULL, NULL, NULL, NULL), +(7, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'dddddddd', '1990-05-15', 0.1, b'100'), +(17, 'vvvvvvvvvvvvv', 'aaaa', '1989-03-12', 0.01, b'101'), +(1, 'vvvvvvvvvvvvv', NULL, '1989-03-12', 0.01, b'100'), +(12, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'dddddddd', '1999-07-23', 0.112, b'001'), +(23, 'vvvvvvvvvvvvv', 'dddddddd', '1999-07-23', 0.1, b'100'), +(8, 'vvvvvvvvvvvvv', 'aaaa', '1999-07-23', 0.1, b'100'), +(22, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'aaaa', '1989-03-12', 0.112, b'001'), +(31, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'aaaa', '1999-07-23', 0.01, b'001'), +(10, NULL, 'aaaa', NULL, 0.01, b'010'), +(5, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'dddddddd', '1999-07-23', 0.1, b'100'), +(15, 'vvvvvvvvvvvvv', 'ccccccccc', '1990-05-15', 0.1, b'010'), +(30, NULL, 'bbbbbb', NULL, NULL, b'100'), +(38, 'zzzzzzzzzzzzzzzzzz', 'bbbbbb', NULL, NULL, NULL), +(18, 'zzzzzzzzzzzzzzzzzz', 'ccccccccc', '1990-05-15', 0.01, b'010'), +(9, 'yyy', 'bbbbbb', '1998-08-28', 0.01, NULL), +(29, 'vvvvvvvvvvvvv', 'dddddddd', '1999-07-23', 0.012, b'010'), +(3, 'yyy', 'dddddddd', '1990-05-15', 0.112, b'010'), +(39, 'zzzzzzzzzzzzzzzzzz', 'bbbbbb', NULL, 0.01, b'100'), +(14, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'ccccccccc', '1990-05-15', 0.1, b'100'), +(40, 'zzzzzzzzzzzzzzzzzz', 'bbbbbb', '1989-03-12', NULL, NULL), +(44, NULL, 'aaaa', '1989-03-12', NULL, b'010'), +(19, 'vvvvvvvvvvvvv', 'ccccccccc', '1990-05-15', 0.012, b'011'), +(21, 'zzzzzzzzzzzzzzzzzz', 'dddddddd', '1989-03-12', 0.112, b'100'), +(45, NULL, NULL, '1989-03-12', NULL, b'011'), +(2, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'ccccccccc', '1990-05-15', 0.1, b'001'), +(35, 'yyy', 'aaaa', '1990-05-15', 0.05, b'011'), +(4, 'vvvvvvvvvvvvv', 'dddddddd', '1999-07-23', 0.01, b'101'), +(47, NULL, 'aaaa', '1990-05-15', 0.05, b'010'), +(42, NULL, 'ccccccccc', '1989-03-12', 0.01, b'010'), +(32, NULL, 'bbbbbb', '1990-05-15', 0.01, b'011'), +(49, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww' , 'aaaa', '1990-05-15', NULL, NULL), +(43, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww' , 'bbbbbb', '1990-05-15', NULL, b'100'), +(37, 'yyy', NULL, '1989-03-12', 0.05, b'011'), +(41, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'ccccccccc', '1990-05-15', 0.05, NULL), +(34, 'yyy', NULL, NULL, NULL, NULL), +(33, 'zzzzzzzzzzzzzzzzzz', 'dddddddd', '1989-03-12', 0.05, b'011'), +(24, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'dddddddd', '1990-05-15', 0.01, b'101'), +(11, 'yyy', 'ccccccccc', '1999-07-23', 0.1, NULL), +(25, 'zzzzzzzzzzzzzzzzzz', 'bbb', '1989-03-12', 0.01, b'101'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +SELECT * FROM mysql.table_stats; +db_name table_name cardinality +test t1 40 +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx1 1 6.4000 +test t1 idx1 2 1.6875 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +SELECT COUNT(*) FROM t1; +COUNT(*) +40 +SELECT * FROM mysql.column_stats +WHERE db_name='test' AND table_name='t1' AND column_name='a'; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +SELECT MIN(t1.a), MAX(t1.a), +(SELECT COUNT(*) FROM t1 WHERE t1.b IS NULL) / +(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.a)", +(SELECT COUNT(t1.a) FROM t1) / +(SELECT COUNT(DISTINCT t1.a) FROM t1) AS "AVG_FREQUENCY(t1.a)" +FROM t1; +MIN(t1.a) MAX(t1.a) NULLS_RATIO(t1.a) AVG_FREQUENCY(t1.a) +0 49 0.2000 1.0000 +SELECT * FROM mysql.column_stats +WHERE db_name='test' AND table_name='t1' AND column_name='b'; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +SELECT MIN(t1.b), MAX(t1.b), +(SELECT COUNT(*) FROM t1 WHERE t1.b IS NULL) / +(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.b)", +(SELECT COUNT(t1.b) FROM t1) / +(SELECT COUNT(DISTINCT t1.b) FROM t1) AS "AVG_FREQUENCY(t1.b)" +FROM t1; +MIN(t1.b) MAX(t1.b) NULLS_RATIO(t1.b) AVG_FREQUENCY(t1.b) +vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 +SELECT * FROM mysql.column_stats +WHERE db_name='test' AND table_name='t1' AND column_name='c'; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +SELECT MIN(t1.c), MAX(t1.c), +(SELECT COUNT(*) FROM t1 WHERE t1.c IS NULL) / +(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.c)", +(SELECT COUNT(t1.c) FROM t1) / +(SELECT COUNT(DISTINCT t1.c) FROM t1) AS "AVG_FREQUENCY(t1.c)" +FROM t1; +MIN(t1.c) MAX(t1.c) NULLS_RATIO(t1.c) AVG_FREQUENCY(t1.c) +aaaa dddddddd 0.1250 7.0000 +SELECT * FROM mysql.column_stats +WHERE db_name='test' AND table_name='t1' AND column_name='d'; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +SELECT MIN(t1.d), MAX(t1.d), +(SELECT COUNT(*) FROM t1 WHERE t1.d IS NULL) / +(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.d)", +(SELECT COUNT(t1.d) FROM t1) / +(SELECT COUNT(DISTINCT t1.d) FROM t1) AS "AVG_FREQUENCY(t1.d)" +FROM t1; +MIN(t1.d) MAX(t1.d) NULLS_RATIO(t1.d) AVG_FREQUENCY(t1.d) +1989-03-12 1999-07-23 0.1500 8.5000 +SELECT * FROM mysql.column_stats +WHERE db_name='test' AND table_name='t1' AND column_name='e'; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +SELECT MIN(t1.e), MAX(t1.e), +(SELECT COUNT(*) FROM t1 WHERE t1.e IS NULL) / +(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.e)", +(SELECT COUNT(t1.e) FROM t1) / +(SELECT COUNT(DISTINCT t1.e) FROM t1) AS "AVG_FREQUENCY(t1.e)" +FROM t1; +MIN(t1.e) MAX(t1.e) NULLS_RATIO(t1.e) AVG_FREQUENCY(t1.e) +0.01 0.112 0.2250 6.2000 +SELECT * FROM mysql.index_stats +WHERE db_name='test' AND table_name='t1' AND index_name='idx1'; +db_name table_name index_name prefix_arity avg_frequency +test t1 idx1 1 6.4000 +test t1 idx1 2 1.6875 +SELECT +(SELECT COUNT(*) FROM t1 WHERE t1.b IS NOT NULL) / +(SELECT COUNT(DISTINCT t1.b) FROM t1 WHERE t1.b IS NOT NULL) +AS 'ARITY 1', +(SELECT COUNT(*) FROM t1 WHERE t1.b IS NOT NULL AND t1.e IS NOT NULL) / +(SELECT COUNT(DISTINCT t1.b, t1.e) FROM t1 +WHERE t1.b IS NOT NULL AND t1.e IS NOT NULL) +AS 'ARITY 2'; +ARITY 1 ARITY 2 +6.4000 1.6875 +SELECT * FROM mysql.index_stats +WHERE db_name='test' AND table_name='t1' AND index_name='idx2'; +db_name table_name index_name prefix_arity avg_frequency +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +SELECT +(SELECT COUNT(*) FROM t1 WHERE t1.c IS NOT NULL) / +(SELECT COUNT(DISTINCT t1.c) FROM t1 WHERE t1.c IS NOT NULL) +AS 'ARITY 1', +(SELECT COUNT(*) FROM t1 WHERE t1.c IS NOT NULL AND t1.d IS NOT NULL) / +(SELECT COUNT(DISTINCT t1.c, t1.d) FROM t1 +WHERE t1.c IS NOT NULL AND t1.d IS NOT NULL) +AS 'ARITY 2'; +ARITY 1 ARITY 2 +7.0000 2.3846 +SELECT * FROM mysql.index_stats +WHERE db_name='test' AND table_name='t1' AND index_name='idx3'; +db_name table_name index_name prefix_arity avg_frequency +test t1 idx3 1 8.5000 +SELECT +(SELECT COUNT(*) FROM t1 WHERE t1.d IS NOT NULL) / +(SELECT COUNT(DISTINCT t1.d) FROM t1 WHERE t1.d IS NOT NULL) +AS 'ARITY 1'; +ARITY 1 +8.5000 +SELECT * FROM mysql.index_stats +WHERE db_name='test' AND table_name='t1' AND index_name='idx4'; +db_name table_name index_name prefix_arity avg_frequency +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +SELECT +(SELECT COUNT(*) FROM t1 WHERE t1.e IS NOT NULL) / +(SELECT COUNT(DISTINCT t1.e) FROM t1 WHERE t1.e IS NOT NULL) +AS 'ARITY 1', +(SELECT COUNT(*) FROM t1 WHERE t1.e IS NOT NULL AND t1.b IS NOT NULL) / +(SELECT COUNT(DISTINCT t1.e, t1.b) FROM t1 +WHERE t1.e IS NOT NULL AND t1.b IS NOT NULL) +AS 'ARITY 2', +(SELECT COUNT(*) FROM t1 +WHERE t1.e IS NOT NULL AND t1.b IS NOT NULL AND t1.d IS NOT NULL) / +(SELECT COUNT(DISTINCT t1.e, t1.b, t1.d) FROM t1 +WHERE t1.e IS NOT NULL AND t1.b IS NOT NULL AND t1.d IS NOT NULL) +AS 'ARITY 3'; +ARITY 1 ARITY 2 ARITY 3 +6.2000 1.6875 1.1304 +DELETE FROM mysql.column_stats; +set histogram_size=4; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +SELECT db_name, table_name, column_name, +min_value, max_value, +nulls_ratio, avg_frequency, +hist_size, hist_type, decode_histogram(hist_type,histogram) +FROM mysql.column_stats +ORDER BY db_name, table_name, column_name; +db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type decode_histogram(hist_type,histogram) +test t1 a 0 49 0.0000 1.0000 4 JSON_HB { + "target_histogram_size": 4, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "0", + "size": 0.275, + "ndv": 11 + }, + { + "start": "12", + "size": 0.275, + "ndv": 11 + }, + { + "start": "29", + "size": 0.275, + "ndv": 11 + }, + { + "start": "41", + "end": "49", + "size": 0.175, + "ndv": 7 + } + ] +} +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 JSON_HB { + "target_histogram_size": 4, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "vvvvvvvvvvvvv", + "size": 0.28125, + "ndv": 2 + }, + { + "start": "wwwwwwwwwwwwwwwwwwwwwwwwwwww", + "size": 0.28125, + "ndv": 2 + }, + { + "start": "xxxxxxxxxxxxxxxxxxxxxxxxxx", + "size": 0.28125, + "ndv": 3 + }, + { + "start": "zzzzzzzzzzzzzzzzzz", + "end": "zzzzzzzzzzzzzzzzzz", + "size": 0.15625, + "ndv": 1 + } + ] +} +test t1 c aaaa dddddddd 0.1250 7.0000 4 JSON_HB { + "target_histogram_size": 4, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "aaaa", + "size": 0.257142857, + "ndv": 1 + }, + { + "start": "bbb", + "size": 0.257142857, + "ndv": 3 + }, + { + "start": "ccccccccc", + "size": 0.257142857, + "ndv": 2 + }, + { + "start": "dddddddd", + "end": "dddddddd", + "size": 0.228571429, + "ndv": 1 + } + ] +} +test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 3 JSON_HB { + "target_histogram_size": 4, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "1989-03-12", + "size": 0.323529412, + "ndv": 1 + }, + { + "start": "1990-05-15", + "size": 0.411764706, + "ndv": 1 + }, + { + "start": "1998-08-28", + "end": "1999-07-23", + "size": 0.264705882, + "ndv": 2 + } + ] +} +test t1 e 0.01 0.112 0.2250 6.2000 4 JSON_HB { + "target_histogram_size": 4, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "0.01", + "size": 0.387096774, + "ndv": 1 + }, + { + "start": "0.012", + "size": 0.258064516, + "ndv": 3 + }, + { + "start": "0.1", + "size": 0.258064516, + "ndv": 2 + }, + { + "start": "0.112", + "end": "0.112", + "size": 0.096774194, + "ndv": 1 + } + ] +} +test t1 f 1 5 0.2000 6.4000 4 JSON_HB { + "target_histogram_size": 4, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start_hex": "01", + "size": 0.28125, + "ndv": 2 + }, + { + "start_hex": "02", + "size": 0.28125, + "ndv": 2 + }, + { + "start_hex": "04", + "size": 0.3125, + "ndv": 1 + }, + { + "start_hex": "05", + "end_hex": "05", + "size": 0.125, + "ndv": 1 + } + ] +} +DELETE FROM mysql.column_stats; +set histogram_size=8; +set histogram_type=@DOUBLE_PREC_TYPE; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +SELECT db_name, table_name, column_name, +min_value, max_value, +nulls_ratio, avg_frequency, +hist_size, hist_type, decode_histogram(hist_type,histogram) +FROM mysql.column_stats +ORDER BY db_name, table_name, column_name; +db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type decode_histogram(hist_type,histogram) +test t1 a 0 49 0.0000 1.0000 7 JSON_HB { + "target_histogram_size": 8, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "0", + "size": 0.15, + "ndv": 6 + }, + { + "start": "7", + "size": 0.15, + "ndv": 6 + }, + { + "start": "14", + "size": 0.15, + "ndv": 6 + }, + { + "start": "22", + "size": 0.15, + "ndv": 6 + }, + { + "start": "31", + "size": 0.15, + "ndv": 6 + }, + { + "start": "38", + "size": 0.15, + "ndv": 6 + }, + { + "start": "44", + "end": "49", + "size": 0.1, + "ndv": 4 + } + ] +} +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 5 JSON_HB { + "target_histogram_size": 8, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "vvvvvvvvvvvvv", + "size": 0.25, + "ndv": 1 + }, + { + "start": "wwwwwwwwwwwwwwwwwwwwwwwwwwww", + "size": 0.21875, + "ndv": 1 + }, + { + "start": "xxxxxxxxxxxxxxxxxxxxxxxxxx", + "size": 0.125, + "ndv": 1 + }, + { + "start": "yyy", + "size": 0.1875, + "ndv": 1 + }, + { + "start": "zzzzzzzzzzzzzzzzzz", + "end": "zzzzzzzzzzzzzzzzzz", + "size": 0.21875, + "ndv": 1 + } + ] +} +test t1 c aaaa dddddddd 0.1250 7.0000 5 JSON_HB { + "target_histogram_size": 8, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "aaaa", + "size": 0.257142857, + "ndv": 1 + }, + { + "start": "bbb", + "size": 0.142857143, + "ndv": 2 + }, + { + "start": "bbbbbb", + "size": 0.085714286, + "ndv": 1 + }, + { + "start": "ccccccccc", + "size": 0.228571429, + "ndv": 1 + }, + { + "start": "dddddddd", + "end": "dddddddd", + "size": 0.285714286, + "ndv": 1 + } + ] +} +test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 JSON_HB { + "target_histogram_size": 8, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "1989-03-12", + "size": 0.323529412, + "ndv": 1 + }, + { + "start": "1990-05-15", + "size": 0.411764706, + "ndv": 1 + }, + { + "start": "1998-08-28", + "size": 0.147058824, + "ndv": 2 + }, + { + "start": "1999-07-23", + "end": "1999-07-23", + "size": 0.117647059, + "ndv": 1 + } + ] +} +test t1 e 0.01 0.112 0.2250 6.2000 5 JSON_HB { + "target_histogram_size": 8, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "0.01", + "size": 0.387096774, + "ndv": 1 + }, + { + "start": "0.012", + "size": 0.129032258, + "ndv": 2 + }, + { + "start": "0.05", + "size": 0.096774194, + "ndv": 1 + }, + { + "start": "0.1", + "size": 0.258064516, + "ndv": 1 + }, + { + "start": "0.112", + "end": "0.112", + "size": 0.129032258, + "ndv": 1 + } + ] +} +test t1 f 1 5 0.2000 6.4000 5 JSON_HB { + "target_histogram_size": 8, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start_hex": "01", + "size": 0.125, + "ndv": 1 + }, + { + "start_hex": "02", + "size": 0.25, + "ndv": 1 + }, + { + "start_hex": "03", + "size": 0.1875, + "ndv": 1 + }, + { + "start_hex": "04", + "size": 0.3125, + "ndv": 1 + }, + { + "start_hex": "05", + "end_hex": "05", + "size": 0.125, + "ndv": 1 + } + ] +} +DELETE FROM mysql.column_stats; +set histogram_size= 0; +set histogram_type=@SINGLE_PREC_TYPE; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +CREATE TABLE t3 ( +a int NOT NULL PRIMARY KEY, +b varchar(32), +c char(16), +INDEX idx (c) +) ENGINE=MYISAM; +INSERT INTO t3 VALUES +(0, NULL, NULL), +(7, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'dddddddd'), +(17, 'vvvvvvvvvvvvv', 'aaaa'), +(1, 'vvvvvvvvvvvvv', NULL), +(12, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'dddddddd'), +(23, 'vvvvvvvvvvvvv', 'dddddddd'), +(8, 'vvvvvvvvvvvvv', 'aaaa'), +(22, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'aaaa'), +(31, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'aaaa'), +(10, NULL, 'aaaa'), +(5, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'dddddddd'), +(15, 'vvvvvvvvvvvvv', 'ccccccccc'), +(30, NULL, 'bbbbbb'), +(38, 'zzzzzzzzzzzzzzzzzz', 'bbbbbb'), +(18, 'zzzzzzzzzzzzzzzzzz', 'ccccccccc'), +(9, 'yyy', 'bbbbbb'), +(29, 'vvvvvvvvvvvvv', 'dddddddd'); +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status Engine-independent statistics collected +test.t3 analyze status OK +SELECT * FROM mysql.table_stats; +db_name table_name cardinality +test t1 40 +test t3 17 +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +test t3 a 0 38 0.0000 4.0000 1.0000 0 NULL NULL +test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000 0 NULL NULL +test t3 c aaaa dddddddd 0.1176 6.4000 3.7500 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx1 1 6.4000 +test t1 idx1 2 1.6875 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +test t3 PRIMARY 1 1.0000 +test t3 idx 1 3.7500 +ALTER TABLE t1 RENAME TO s1; +SELECT * FROM mysql.table_stats; +db_name table_name cardinality +test s1 40 +test t3 17 +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test s1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test s1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test s1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test s1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test s1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test s1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +test t3 a 0 38 0.0000 4.0000 1.0000 0 NULL NULL +test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000 0 NULL NULL +test t3 c aaaa dddddddd 0.1176 6.4000 3.7500 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test s1 PRIMARY 1 1.0000 +test s1 idx1 1 6.4000 +test s1 idx1 2 1.6875 +test s1 idx2 1 7.0000 +test s1 idx2 2 2.3846 +test s1 idx3 1 8.5000 +test s1 idx4 1 6.2000 +test s1 idx4 2 1.6875 +test s1 idx4 3 1.1304 +test t3 PRIMARY 1 1.0000 +test t3 idx 1 3.7500 +RENAME TABLE s1 TO t1; +SELECT * FROM mysql.table_stats; +db_name table_name cardinality +test t1 40 +test t3 17 +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +test t3 a 0 38 0.0000 4.0000 1.0000 0 NULL NULL +test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000 0 NULL NULL +test t3 c aaaa dddddddd 0.1176 6.4000 3.7500 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx1 1 6.4000 +test t1 idx1 2 1.6875 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +test t3 PRIMARY 1 1.0000 +test t3 idx 1 3.7500 +DROP TABLE t3; +SELECT * FROM mysql.table_stats; +db_name table_name cardinality +test t1 40 +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx1 1 6.4000 +test t1 idx1 2 1.6875 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +CREATE TEMPORARY TABLE t0 ( +a int NOT NULL PRIMARY KEY, +b varchar(32) +); +INSERT INTO t0 SELECT a,b FROM t1; +ALTER TABLE t1 CHANGE COLUMN b x varchar(32), +CHANGE COLUMN e y double; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `x` varchar(32) DEFAULT NULL, + `c` char(16) DEFAULT NULL, + `d` date DEFAULT NULL, + `y` double DEFAULT NULL, + `f` bit(3) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx1` (`x`,`y`), + KEY `idx2` (`c`,`d`), + KEY `idx3` (`d`), + KEY `idx4` (`y`,`x`,`d`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +test t1 x vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t1 y 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +ALTER TABLE t1 CHANGE COLUMN x b varchar(32), +CHANGE COLUMN y e double; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` varchar(32) DEFAULT NULL, + `c` char(16) DEFAULT NULL, + `d` date DEFAULT NULL, + `e` double DEFAULT NULL, + `f` bit(3) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx1` (`b`,`e`), + KEY `idx2` (`c`,`d`), + KEY `idx3` (`d`), + KEY `idx4` (`e`,`b`,`d`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +ALTER TABLE t1 RENAME TO s1, CHANGE COLUMN b x varchar(32); +SHOW CREATE TABLE s1; +Table Create Table +s1 CREATE TABLE `s1` ( + `a` int(11) NOT NULL, + `x` varchar(32) DEFAULT NULL, + `c` char(16) DEFAULT NULL, + `d` date DEFAULT NULL, + `e` double DEFAULT NULL, + `f` bit(3) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx1` (`x`,`e`), + KEY `idx2` (`c`,`d`), + KEY `idx3` (`d`), + KEY `idx4` (`e`,`x`,`d`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM mysql.table_stats; +db_name table_name cardinality +test s1 40 +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test s1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test s1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test s1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test s1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test s1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +test s1 x vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test s1 PRIMARY 1 1.0000 +test s1 idx1 1 6.4000 +test s1 idx1 2 1.6875 +test s1 idx2 1 7.0000 +test s1 idx2 2 2.3846 +test s1 idx3 1 8.5000 +test s1 idx4 1 6.2000 +test s1 idx4 2 1.6875 +test s1 idx4 3 1.1304 +ALTER TABLE s1 RENAME TO t1, CHANGE COLUMN x b varchar(32); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` varchar(32) DEFAULT NULL, + `c` char(16) DEFAULT NULL, + `d` date DEFAULT NULL, + `e` double DEFAULT NULL, + `f` bit(3) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx1` (`b`,`e`), + KEY `idx2` (`c`,`d`), + KEY `idx3` (`d`), + KEY `idx4` (`e`,`b`,`d`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM mysql.table_stats; +db_name table_name cardinality +test t1 40 +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx1 1 6.4000 +test t1 idx1 2 1.6875 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +ALTER TABLE t1 CHANGE COLUMN b x varchar(30); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `x` varchar(30) DEFAULT NULL, + `c` char(16) DEFAULT NULL, + `d` date DEFAULT NULL, + `e` double DEFAULT NULL, + `f` bit(3) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx1` (`x`,`e`), + KEY `idx2` (`c`,`d`), + KEY `idx3` (`d`), + KEY `idx4` (`e`,`x`,`d`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +ALTER TABLE t1 CHANGE COLUMN x b varchar(32); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` varchar(32) DEFAULT NULL, + `c` char(16) DEFAULT NULL, + `d` date DEFAULT NULL, + `e` double DEFAULT NULL, + `f` bit(3) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx1` (`b`,`e`), + KEY `idx2` (`c`,`d`), + KEY `idx3` (`d`), + KEY `idx4` (`e`,`b`,`d`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx4); +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx1 1 6.4000 +test t1 idx1 2 1.6875 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/save_column_stats' + FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' + FROM mysql.column_stats WHERE column_name='b'; +SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/save_index_stats' + FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' + FROM mysql.index_stats WHERE index_name IN ('idx1', 'idx4'); +ALTER TABLE t1 CHANGE COLUMN b x varchar(30); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `x` varchar(30) DEFAULT NULL, + `c` char(16) DEFAULT NULL, + `d` date DEFAULT NULL, + `e` double DEFAULT NULL, + `f` bit(3) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx1` (`x`,`e`), + KEY `idx2` (`c`,`d`), + KEY `idx3` (`d`), + KEY `idx4` (`e`,`x`,`d`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +ALTER TABLE t1 CHANGE COLUMN x b varchar(32); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` varchar(32) DEFAULT NULL, + `c` char(16) DEFAULT NULL, + `d` date DEFAULT NULL, + `e` double DEFAULT NULL, + `f` bit(3) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx1` (`b`,`e`), + KEY `idx2` (`c`,`d`), + KEY `idx3` (`d`), + KEY `idx4` (`e`,`b`,`d`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/save_column_stats' + INTO TABLE mysql.column_stats +FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'; +LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/save_index_stats' + INTO TABLE mysql.index_stats +FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'; +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx1 1 6.4000 +test t1 idx1 2 1.6875 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +ALTER TABLE t1 DROP COLUMN b; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `c` char(16) DEFAULT NULL, + `d` date DEFAULT NULL, + `e` double DEFAULT NULL, + `f` bit(3) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx1` (`e`), + KEY `idx2` (`c`,`d`), + KEY `idx3` (`d`), + KEY `idx4` (`e`,`d`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +DROP INDEX idx2 ON t1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `c` char(16) DEFAULT NULL, + `d` date DEFAULT NULL, + `e` double DEFAULT NULL, + `f` bit(3) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx1` (`e`), + KEY `idx3` (`d`), + KEY `idx4` (`e`,`d`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx3 1 8.5000 +DROP INDEX idx1 ON t1; +DROP INDEX idx4 ON t1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `c` char(16) DEFAULT NULL, + `d` date DEFAULT NULL, + `e` double DEFAULT NULL, + `f` bit(3) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx3` (`d`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +ALTER TABLE t1 ADD COLUMN b varchar(32); +CREATE INDEX idx1 ON t1(b, e); +CREATE INDEX idx2 ON t1(c, d); +CREATE INDEX idx4 ON t1(e, b, d); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `c` char(16) DEFAULT NULL, + `d` date DEFAULT NULL, + `e` double DEFAULT NULL, + `f` bit(3) DEFAULT NULL, + `b` varchar(32) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx3` (`d`), + KEY `idx1` (`b`,`e`), + KEY `idx2` (`c`,`d`), + KEY `idx4` (`e`,`b`,`d`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx3 1 8.5000 +ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4); +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 b NULL NULL 1.0000 NULL NULL 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx1 1 NULL +test t1 idx1 2 NULL +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +test t1 idx4 1 6.2000 +test t1 idx4 2 NULL +test t1 idx4 3 NULL +UPDATE t1 SET b=(SELECT b FROM t0 WHERE t0.a= t1.a); +ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4); +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx1 1 6.4000 +test t1 idx1 2 1.6875 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +ALTER TABLE t1 DROP COLUMN b, +DROP INDEX idx1, DROP INDEX idx2, DROP INDEX idx4; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `c` char(16) DEFAULT NULL, + `d` date DEFAULT NULL, + `e` double DEFAULT NULL, + `f` bit(3) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx3` (`d`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx3 1 8.5000 +ALTER TABLE t1 ADD COLUMN b varchar(32); +ALTER TABLE t1 +ADD INDEX idx1 (b, e), ADD INDEX idx2 (c, d), ADD INDEX idx4 (e, b, d); +UPDATE t1 SET b=(SELECT b FROM t0 WHERE t0.a= t1.a); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `c` char(16) DEFAULT NULL, + `d` date DEFAULT NULL, + `e` double DEFAULT NULL, + `f` bit(3) DEFAULT NULL, + `b` varchar(32) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx3` (`d`), + KEY `idx1` (`b`,`e`), + KEY `idx2` (`c`,`d`), + KEY `idx4` (`e`,`b`,`d`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx3 1 8.5000 +ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4); +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx1 1 6.4000 +test t1 idx1 2 1.6875 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +DELETE FROM mysql.table_stats; +DELETE FROM mysql.column_stats; +DELETE FROM mysql.index_stats; +ANALYZE TABLE t1 PERSISTENT FOR COLUMNS() INDEXES(); +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +SELECT * FROM mysql.table_stats; +db_name table_name cardinality +test t1 40 +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(c,e,b) INDEXES(idx2,idx4); +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +SELECT * FROM mysql.table_stats; +db_name table_name cardinality +test t1 40 +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +DELETE FROM mysql.index_stats WHERE table_name='t1' AND index_name='primary'; +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +ANALYZE TABLE t1 PERSISTENT FOR COLUMNS() INDEXES(primary); +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +DELETE FROM mysql.table_stats; +DELETE FROM mysql.column_stats; +DELETE FROM mysql.index_stats; +ANALYZE TABLE t1 PERSISTENT FOR COLUMNS ALL INDEXES ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +SELECT * FROM mysql.table_stats; +db_name table_name cardinality +test t1 40 +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx1 1 6.4000 +test t1 idx1 2 1.6875 +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 ENGINE=InnoDB; +INSERT INTO t2 SELECT * FROM t1; +set optimizer_switch='extended_keys=off'; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +SELECT * FROM mysql.table_stats; +db_name table_name cardinality +test t1 40 +test t2 40 +SELECT * FROM mysql.column_stats ORDER BY column_name, table_name; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t2 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t2 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t2 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t2 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t2 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +test t2 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t2 PRIMARY 1 1.0000 +test t1 idx1 1 6.4000 +test t2 idx1 1 6.4000 +test t1 idx1 2 1.6875 +test t2 idx1 2 1.6875 +test t1 idx2 1 7.0000 +test t2 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t2 idx2 2 2.3846 +test t1 idx3 1 8.5000 +test t2 idx3 1 8.5000 +test t1 idx4 1 6.2000 +test t2 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t2 idx4 2 1.6875 +test t1 idx4 3 1.1304 +test t2 idx4 3 1.1304 +DELETE FROM mysql.table_stats; +DELETE FROM mysql.column_stats; +DELETE FROM mysql.index_stats; +set optimizer_switch='extended_keys=on'; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +SELECT * FROM mysql.table_stats; +db_name table_name cardinality +test t2 40 +SELECT * FROM mysql.column_stats ORDER BY column_name; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t2 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t2 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL +test t2 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t2 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t2 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t2 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name; +db_name table_name index_name prefix_arity avg_frequency +test t2 PRIMARY 1 1.0000 +test t2 idx1 1 6.4000 +test t2 idx1 2 1.6875 +test t2 idx1 3 1.0000 +test t2 idx2 1 7.0000 +test t2 idx2 2 2.3846 +test t2 idx2 3 1.0000 +test t2 idx3 1 8.5000 +test t2 idx3 2 1.0000 +test t2 idx4 1 6.2000 +test t2 idx4 2 1.6875 +test t2 idx4 3 1.1304 +test t2 idx4 4 1.0000 +ALTER TABLE t2 DROP PRIMARY KEY, DROP INDEX idx1; +SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name; +db_name table_name index_name prefix_arity avg_frequency +test t2 idx2 1 7.0000 +test t2 idx2 2 2.3846 +test t2 idx3 1 8.5000 +test t2 idx4 1 6.2000 +test t2 idx4 2 1.6875 +test t2 idx4 3 1.1304 +UPDATE t2 SET b=0 WHERE b IS NULL; +ALTER TABLE t2 ADD PRIMARY KEY (a,b); +SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name; +db_name table_name index_name prefix_arity avg_frequency +test t2 idx2 1 7.0000 +test t2 idx2 2 2.3846 +test t2 idx3 1 8.5000 +test t2 idx4 1 6.2000 +test t2 idx4 2 1.6875 +test t2 idx4 3 1.1304 +ANALYZE TABLE t2 PERSISTENT FOR COLUMNS() INDEXES ALL; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name; +db_name table_name index_name prefix_arity avg_frequency +test t2 PRIMARY 1 1.0000 +test t2 PRIMARY 2 1.0000 +test t2 idx2 1 7.0000 +test t2 idx2 2 2.3846 +test t2 idx2 3 1.0000 +test t2 idx2 4 1.0000 +test t2 idx3 1 8.5000 +test t2 idx3 2 1.0000 +test t2 idx3 3 1.0000 +test t2 idx4 1 6.2000 +test t2 idx4 2 1.7222 +test t2 idx4 3 1.1154 +test t2 idx4 4 1.0000 +ALTER TABLE t2 CHANGE COLUMN b b varchar(30); +SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name; +db_name table_name index_name prefix_arity avg_frequency +test t2 idx2 1 7.0000 +test t2 idx2 2 2.3846 +test t2 idx3 1 8.5000 +ANALYZE TABLE t2 PERSISTENT FOR COLUMNS ALL INDEXES ALL; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name; +db_name table_name index_name prefix_arity avg_frequency +test t2 PRIMARY 1 1.0000 +test t2 PRIMARY 2 1.0000 +test t2 idx2 1 7.0000 +test t2 idx2 2 2.3846 +test t2 idx2 3 1.0000 +test t2 idx2 4 1.0000 +test t2 idx3 1 8.5000 +test t2 idx3 2 1.0000 +test t2 idx3 3 1.0000 +test t2 idx4 1 6.2000 +test t2 idx4 2 1.7222 +test t2 idx4 3 1.1154 +test t2 idx4 4 1.0000 +ALTER TABLE t2 CHANGE COLUMN b b varchar(32); +SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name; +db_name table_name index_name prefix_arity avg_frequency +test t2 PRIMARY 1 1.0000 +test t2 PRIMARY 2 1.0000 +test t2 idx2 1 7.0000 +test t2 idx2 2 2.3846 +test t2 idx2 3 1.0000 +test t2 idx2 4 1.0000 +test t2 idx3 1 8.5000 +test t2 idx3 2 1.0000 +test t2 idx3 3 1.0000 +test t2 idx4 1 6.2000 +test t2 idx4 2 1.7222 +test t2 idx4 3 1.1154 +test t2 idx4 4 1.0000 +ANALYZE TABLE t2 PERSISTENT FOR COLUMNS ALL INDEXES ALL; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name; +db_name table_name index_name prefix_arity avg_frequency +test t2 PRIMARY 1 1.0000 +test t2 PRIMARY 2 1.0000 +test t2 idx2 1 7.0000 +test t2 idx2 2 2.3846 +test t2 idx2 3 1.0000 +test t2 idx2 4 1.0000 +test t2 idx3 1 8.5000 +test t2 idx3 2 1.0000 +test t2 idx3 3 1.0000 +test t2 idx4 1 6.2000 +test t2 idx4 2 1.7222 +test t2 idx4 3 1.1154 +test t2 idx4 4 1.0000 +ALTER TABLE t2 DROP COLUMN b, DROP PRIMARY KEY, ADD PRIMARY KEY(a); +SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name; +db_name table_name index_name prefix_arity avg_frequency +test t2 idx2 1 7.0000 +test t2 idx2 2 2.3846 +test t2 idx3 1 8.5000 +ANALYZE TABLE t2 PERSISTENT FOR COLUMNS() INDEXES ALL; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name; +db_name table_name index_name prefix_arity avg_frequency +test t2 PRIMARY 1 1.0000 +test t2 idx2 1 7.0000 +test t2 idx2 2 2.3846 +test t2 idx2 3 1.0000 +test t2 idx3 1 8.5000 +test t2 idx3 2 1.0000 +test t2 idx4 1 6.2000 +test t2 idx4 2 2.2308 +test t2 idx4 3 1.0000 +set optimizer_switch='extended_keys=off'; +ALTER TABLE t1 +DROP INDEX idx1, +DROP INDEX idx4; +ALTER TABLE t1 +MODIFY COLUMN b text, +ADD INDEX idx1 (b(4), e), +ADD INDEX idx4 (e, b(4), d); +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t2 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t2 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t2 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t2 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t2 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t2 PRIMARY 1 1.0000 +test t2 idx2 1 7.0000 +test t2 idx2 2 2.3846 +test t2 idx2 3 1.0000 +test t2 idx3 1 8.5000 +test t2 idx3 2 1.0000 +test t2 idx4 1 6.2000 +test t2 idx4 2 2.2308 +test t2 idx4 3 1.0000 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze Warning Engine-independent statistics are not collected for column 'b' +test.t1 analyze status OK +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +test t2 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t2 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t2 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t2 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t2 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx1 1 NULL +test t1 idx1 2 NULL +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +test t1 idx4 1 6.2000 +test t1 idx4 2 NULL +test t1 idx4 3 NULL +test t2 PRIMARY 1 1.0000 +test t2 idx2 1 7.0000 +test t2 idx2 2 2.3846 +test t2 idx2 3 1.0000 +test t2 idx3 1 8.5000 +test t2 idx3 2 1.0000 +test t2 idx4 1 6.2000 +test t2 idx4 2 2.2308 +test t2 idx4 3 1.0000 +DELETE FROM mysql.table_stats; +DELETE FROM mysql.column_stats; +DELETE FROM mysql.index_stats; +ANALYZE TABLE mysql.column_stats PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +mysql.column_stats analyze error Invalid argument +ANALYZE TABLE mysql.column_stats; +Table Op Msg_type Msg_text +mysql.column_stats analyze status OK +SELECT * FROM mysql.table_stats; +db_name table_name cardinality +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +set use_stat_tables='never'; +ANALYZE TABLE t1 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze Warning Engine-independent statistics are not collected for column 'b' +test.t1 analyze status Table is already up to date +SELECT * FROM mysql.table_stats; +db_name table_name cardinality +test t1 40 +SELECT * FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL +test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL +test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL +test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL +test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL +SELECT * FROM mysql.index_stats; +db_name table_name index_name prefix_arity avg_frequency +test t1 PRIMARY 1 1.0000 +test t1 idx1 1 NULL +test t1 idx1 2 NULL +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx3 1 8.5000 +test t1 idx4 1 6.2000 +test t1 idx4 2 NULL +test t1 idx4 3 NULL +DELETE FROM mysql.table_stats; +DELETE FROM mysql.column_stats; +DELETE FROM mysql.index_stats; +ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(); +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze Warning Engine-independent statistics are not collected for column 'b' +test.t1 analyze status Table is already up to date +ANALYZE TABLE t1 PERSISTENT FOR columns(a,b) INDEXES(); +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze Warning Engine-independent statistics are not collected for column 'b' +test.t1 analyze status Table is already up to date +ANALYZE TABLE t1 PERSISTENT FOR columns(b) indexes(idx2); +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze Warning Engine-independent statistics are not collected for column 'b' +test.t1 analyze status Table is already up to date +ANALYZE TABLE t1 PERSISTENT FOR columns() indexes(idx2); +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +DELETE FROM mysql.table_stats; +DELETE FROM mysql.column_stats; +DELETE FROM mysql.index_stats; +DROP TABLE t1,t2; +set names utf8; +CREATE DATABASE world; +use world; +CREATE TABLE Country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name) +) CHARACTER SET utf8 COLLATE utf8_bin; +CREATE TABLE City ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) CHARACTER SET utf8 COLLATE utf8_bin; +CREATE TABLE CountryLanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) CHARACTER SET utf8 COLLATE utf8_bin; +set use_stat_tables='preferably'; +ANALYZE TABLE Country, City, CountryLanguage; +SELECT UPPER(db_name), UPPER(table_name), cardinality +FROM mysql.table_stats; +UPPER(db_name) UPPER(table_name) cardinality +WORLD CITY 4079 +WORLD COUNTRY 239 +WORLD COUNTRYLANGUAGE 984 +SELECT UPPER(db_name), UPPER(table_name), +column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency +FROM mysql.column_stats; +UPPER(db_name) UPPER(table_name) column_name min_value max_value nulls_ratio avg_length avg_frequency +WORLD CITY Country ABW ZWE 0.0000 3.0000 17.5819 +WORLD CITY ID 1 4079 0.0000 4.0000 1.0000 +WORLD CITY Name A Coruña (La Coruña) Ãœrgenc 0.0000 8.6416 1.0195 +WORLD CITY Population 42 10500000 0.0000 4.0000 1.0467 +WORLD COUNTRY Capital 1 4074 0.0293 4.0000 1.0000 +WORLD COUNTRY Code ABW ZWE 0.0000 3.0000 1.0000 +WORLD COUNTRY Name Afghanistan Zimbabwe 0.0000 10.1088 1.0000 +WORLD COUNTRY Population 0 1277558000 0.0000 4.0000 1.0575 +WORLD COUNTRY SurfaceArea 0.40 17075400.00 0.0000 4.0000 1.0042 +WORLD COUNTRYLANGUAGE Country ABW ZWE 0.0000 3.0000 4.2232 +WORLD COUNTRYLANGUAGE Language Abhyasi [South]Mande 0.0000 7.1778 2.1532 +WORLD COUNTRYLANGUAGE Percentage 0.0 99.9 0.0000 4.0000 2.7640 +SELECT UPPER(db_name), UPPER(table_name), +index_name, prefix_arity, avg_frequency +FROM mysql.index_stats; +UPPER(db_name) UPPER(table_name) index_name prefix_arity avg_frequency +WORLD CITY Country 1 17.5819 +WORLD CITY PRIMARY 1 1.0000 +WORLD CITY Population 1 1.0467 +WORLD COUNTRY Name 1 1.0000 +WORLD COUNTRY PRIMARY 1 1.0000 +WORLD COUNTRYLANGUAGE PRIMARY 1 4.2232 +WORLD COUNTRYLANGUAGE PRIMARY 2 1.0000 +WORLD COUNTRYLANGUAGE Percentage 1 2.7640 +use test; +set use_stat_tables='never'; +CREATE DATABASE world_innodb; +use world_innodb; +CREATE TABLE Country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name) +) CHARACTER SET utf8 COLLATE utf8_bin; +CREATE TABLE City ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) CHARACTER SET utf8 COLLATE utf8_bin; +CREATE TABLE CountryLanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) CHARACTER SET utf8 COLLATE utf8_bin; +ALTER TABLE Country ENGINE=InnoDB; +ALTER TABLE City ENGINE=InnoDB; +ALTER TABLE CountryLanguage ENGINE=InnoDB; +set use_stat_tables='preferably'; +ANALYZE TABLE Country, City, CountryLanguage; +SELECT UPPER(db_name), UPPER(table_name), cardinality +FROM mysql.table_stats; +UPPER(db_name) UPPER(table_name) cardinality +WORLD CITY 4079 +WORLD COUNTRY 239 +WORLD COUNTRYLANGUAGE 984 +WORLD_INNODB CITY 4079 +WORLD_INNODB COUNTRY 239 +WORLD_INNODB COUNTRYLANGUAGE 984 +SELECT UPPER(db_name), UPPER(table_name), +column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency +FROM mysql.column_stats; +UPPER(db_name) UPPER(table_name) column_name min_value max_value nulls_ratio avg_length avg_frequency +WORLD CITY Country ABW ZWE 0.0000 3.0000 17.5819 +WORLD CITY ID 1 4079 0.0000 4.0000 1.0000 +WORLD CITY Name A Coruña (La Coruña) Ãœrgenc 0.0000 8.6416 1.0195 +WORLD CITY Population 42 10500000 0.0000 4.0000 1.0467 +WORLD COUNTRY Capital 1 4074 0.0293 4.0000 1.0000 +WORLD COUNTRY Code ABW ZWE 0.0000 3.0000 1.0000 +WORLD COUNTRY Name Afghanistan Zimbabwe 0.0000 10.1088 1.0000 +WORLD COUNTRY Population 0 1277558000 0.0000 4.0000 1.0575 +WORLD COUNTRY SurfaceArea 0.40 17075400.00 0.0000 4.0000 1.0042 +WORLD COUNTRYLANGUAGE Country ABW ZWE 0.0000 3.0000 4.2232 +WORLD COUNTRYLANGUAGE Language Abhyasi [South]Mande 0.0000 7.1778 2.1532 +WORLD COUNTRYLANGUAGE Percentage 0.0 99.9 0.0000 4.0000 2.7640 +WORLD_INNODB CITY Country ABW ZWE 0.0000 3.0000 17.5819 +WORLD_INNODB CITY ID 1 4079 0.0000 4.0000 1.0000 +WORLD_INNODB CITY Name A Coruña (La Coruña) Ãœrgenc 0.0000 8.6416 1.0195 +WORLD_INNODB CITY Population 42 10500000 0.0000 4.0000 1.0467 +WORLD_INNODB COUNTRY Capital 1 4074 0.0293 4.0000 1.0000 +WORLD_INNODB COUNTRY Code ABW ZWE 0.0000 3.0000 1.0000 +WORLD_INNODB COUNTRY Name Afghanistan Zimbabwe 0.0000 10.1088 1.0000 +WORLD_INNODB COUNTRY Population 0 1277558000 0.0000 4.0000 1.0575 +WORLD_INNODB COUNTRY SurfaceArea 0.40 17075400.00 0.0000 4.0000 1.0042 +WORLD_INNODB COUNTRYLANGUAGE Country ABW ZWE 0.0000 3.0000 4.2232 +WORLD_INNODB COUNTRYLANGUAGE Language Abhyasi [South]Mande 0.0000 7.1778 2.1532 +WORLD_INNODB COUNTRYLANGUAGE Percentage 0.0 99.9 0.0000 4.0000 2.7640 +SELECT UPPER(db_name), UPPER(table_name), +index_name, prefix_arity, avg_frequency +FROM mysql.index_stats; +UPPER(db_name) UPPER(table_name) index_name prefix_arity avg_frequency +WORLD CITY Country 1 17.5819 +WORLD CITY PRIMARY 1 1.0000 +WORLD CITY Population 1 1.0467 +WORLD COUNTRY Name 1 1.0000 +WORLD COUNTRY PRIMARY 1 1.0000 +WORLD COUNTRYLANGUAGE PRIMARY 1 4.2232 +WORLD COUNTRYLANGUAGE PRIMARY 2 1.0000 +WORLD COUNTRYLANGUAGE Percentage 1 2.7640 +WORLD_INNODB CITY Country 1 17.5819 +WORLD_INNODB CITY PRIMARY 1 1.0000 +WORLD_INNODB CITY Population 1 1.0467 +WORLD_INNODB COUNTRY Name 1 1.0000 +WORLD_INNODB COUNTRY PRIMARY 1 1.0000 +WORLD_INNODB COUNTRYLANGUAGE PRIMARY 1 4.2232 +WORLD_INNODB COUNTRYLANGUAGE PRIMARY 2 1.0000 +WORLD_INNODB COUNTRYLANGUAGE Percentage 1 2.7640 +use world; +set use_stat_tables='preferably'; +set histogram_size=100; +set histogram_type=@SINGLE_PREC_TYPE; +ANALYZE TABLE CountryLanguage; +set histogram_size=254; +set histogram_type=@DOUBLE_PREC_TYPE; +ANALYZE TABLE City; +FLUSH TABLES; +select UPPER(db_name),UPPER(table_name),UPPER(column_name),min_value,max_value,nulls_ratio,avg_length,avg_frequency,hist_size,hist_type,decode_histogram(hist_type,histogram) from mysql.column_stats where UPPER(db_name)='WORLD' and UPPER(table_name)='COUNTRYLANGUAGE' and UPPER(column_name) = 'PERCENTAGE';; +UPPER(db_name) WORLD +UPPER(table_name) COUNTRYLANGUAGE +UPPER(column_name) PERCENTAGE +min_value 0.0 +max_value 99.9 +nulls_ratio 0.0000 +avg_length 4.0000 +avg_frequency 2.7640 +hist_size 85 +hist_type JSON_HB +decode_histogram(hist_type,histogram) { + "target_histogram_size": 100, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "0.0", + "size": 0.066056911, + "ndv": 1 + }, + { + "start": "0.1", + "size": 0.020325203, + "ndv": 1 + }, + { + "start": "0.2", + "size": 0.022357724, + "ndv": 1 + }, + { + "start": "0.3", + "size": 0.017276423, + "ndv": 1 + }, + { + "start": "0.4", + "size": 0.025406504, + "ndv": 1 + }, + { + "start": "0.5", + "size": 0.020325203, + "ndv": 1 + }, + { + "start": "0.6", + "size": 0.020325203, + "ndv": 1 + }, + { + "start": "0.7", + "size": 0.017276423, + "ndv": 1 + }, + { + "start": "0.8", + "size": 0.010162602, + "ndv": 1 + }, + { + "start": "0.9", + "size": 0.010162602, + "ndv": 1 + }, + { + "start": "1.0", + "size": 0.010162602, + "ndv": 2 + }, + { + "start": "1.1", + "size": 0.010162602, + "ndv": 2 + }, + { + "start": "1.3", + "size": 0.012195122, + "ndv": 1 + }, + { + "start": "1.4", + "size": 0.015243902, + "ndv": 1 + }, + { + "start": "1.5", + "size": 0.005081301, + "ndv": 1 + }, + { + "start": "1.6", + "size": 0.015243902, + "ndv": 1 + }, + { + "start": "1.7", + "size": 0.010162602, + "ndv": 1 + }, + { + "start": "1.8", + "size": 0.010162602, + "ndv": 2 + }, + { + "start": "1.9", + "size": 0.010162602, + "ndv": 2 + }, + { + "start": "2.0", + "size": 0.010162602, + "ndv": 3 + }, + { + "start": "2.2", + "size": 0.010162602, + "ndv": 2 + }, + { + "start": "2.3", + "size": 0.010162602, + "ndv": 2 + }, + { + "start": "2.4", + "size": 0.010162602, + "ndv": 2 + }, + { + "start": "2.5", + "size": 0.010162602, + "ndv": 2 + }, + { + "start": "2.7", + "size": 0.010162602, + "ndv": 2 + }, + { + "start": "2.8", + "size": 0.010162602, + "ndv": 3 + }, + { + "start": "3.0", + "size": 0.010162602, + "ndv": 2 + }, + { + "start": "3.2", + "size": 0.010162602, + "ndv": 2 + }, + { + "start": "3.3", + "size": 0.010162602, + "ndv": 3 + }, + { + "start": "3.5", + "size": 0.010162602, + "ndv": 3 + }, + { + "start": "3.7", + "size": 0.010162602, + "ndv": 2 + }, + { + "start": "3.8", + "size": 0.010162602, + "ndv": 4 + }, + { + "start": "4.1", + "size": 0.010162602, + "ndv": 3 + }, + { + "start": "4.4", + "size": 0.010162602, + "ndv": 4 + }, + { + "start": "4.8", + "size": 0.010162602, + "ndv": 2 + }, + { + "start": "4.9", + "size": 0.010162602, + "ndv": 5 + }, + { + "start": "5.3", + "size": 0.010162602, + "ndv": 3 + }, + { + "start": "5.5", + "size": 0.010162602, + "ndv": 3 + }, + { + "start": "5.7", + "size": 0.010162602, + "ndv": 4 + }, + { + "start": "6.0", + "size": 0.010162602, + "ndv": 5 + }, + { + "start": "6.4", + "size": 0.010162602, + "ndv": 4 + }, + { + "start": "6.7", + "size": 0.010162602, + "ndv": 5 + }, + { + "start": "7.2", + "size": 0.010162602, + "ndv": 3 + }, + { + "start": "7.4", + "size": 0.010162602, + "ndv": 3 + }, + { + "start": "7.7", + "size": 0.010162602, + "ndv": 3 + }, + { + "start": "8.0", + "size": 0.010162602, + "ndv": 4 + }, + { + "start": "8.5", + "size": 0.010162602, + "ndv": 3 + }, + { + "start": "8.7", + "size": 0.010162602, + "ndv": 4 + }, + { + "start": "9.1", + "size": 0.010162602, + "ndv": 4 + }, + { + "start": "9.5", + "size": 0.010162602, + "ndv": 4 + }, + { + "start": "10.1", + "size": 0.010162602, + "ndv": 6 + }, + { + "start": "10.8", + "size": 0.010162602, + "ndv": 6 + }, + { + "start": "11.4", + "size": 0.010162602, + "ndv": 7 + }, + { + "start": "12.1", + "size": 0.010162602, + "ndv": 6 + }, + { + "start": "12.8", + "size": 0.010162602, + "ndv": 8 + }, + { + "start": "13.8", + "size": 0.010162602, + "ndv": 6 + }, + { + "start": "14.6", + "size": 0.010162602, + "ndv": 7 + }, + { + "start": "16.1", + "size": 0.010162602, + "ndv": 7 + }, + { + "start": "17.1", + "size": 0.010162602, + "ndv": 8 + }, + { + "start": "19.0", + "size": 0.010162602, + "ndv": 7 + }, + { + "start": "20.3", + "size": 0.010162602, + "ndv": 8 + }, + { + "start": "22.7", + "size": 0.010162602, + "ndv": 7 + }, + { + "start": "23.8", + "size": 0.010162602, + "ndv": 9 + }, + { + "start": "29.7", + "size": 0.010162602, + "ndv": 7 + }, + { + "start": "32.1", + "size": 0.010162602, + "ndv": 9 + }, + { + "start": "34.8", + "size": 0.010162602, + "ndv": 8 + }, + { + "start": "39.9", + "size": 0.010162602, + "ndv": 9 + }, + { + "start": "44.6", + "size": 0.010162602, + "ndv": 10 + }, + { + "start": "49.1", + "size": 0.010162602, + "ndv": 9 + }, + { + "start": "52.0", + "size": 0.010162602, + "ndv": 8 + }, + { + "start": "58.4", + "size": 0.010162602, + "ndv": 10 + }, + { + "start": "64.7", + "size": 0.010162602, + "ndv": 9 + }, + { + "start": "69.9", + "size": 0.010162602, + "ndv": 10 + }, + { + "start": "76.7", + "size": 0.010162602, + "ndv": 7 + }, + { + "start": "80.0", + "size": 0.010162602, + "ndv": 8 + }, + { + "start": "85.0", + "size": 0.010162602, + "ndv": 7 + }, + { + "start": "87.0", + "size": 0.010162602, + "ndv": 9 + }, + { + "start": "89.5", + "size": 0.010162602, + "ndv": 8 + }, + { + "start": "92.0", + "size": 0.010162602, + "ndv": 7 + }, + { + "start": "93.6", + "size": 0.010162602, + "ndv": 8 + }, + { + "start": "95.7", + "size": 0.010162602, + "ndv": 7 + }, + { + "start": "96.9", + "size": 0.010162602, + "ndv": 7 + }, + { + "start": "98.0", + "size": 0.010162602, + "ndv": 7 + }, + { + "start": "99.0", + "size": 0.006097561, + "ndv": 4 + }, + { + "start": "99.9", + "end": "99.9", + "size": 0.015243902, + "ndv": 1 + } + ] +} +select UPPER(db_name),UPPER(table_name),UPPER(column_name),min_value,max_value,nulls_ratio,avg_length,avg_frequency,hist_size,hist_type,decode_histogram(hist_type,histogram) from mysql.column_stats where UPPER(db_name)='WORLD' and UPPER(table_name)='CITY' and UPPER(column_name) = 'POPULATION';; +UPPER(db_name) WORLD +UPPER(table_name) CITY +UPPER(column_name) POPULATION +min_value 42 +max_value 10500000 +nulls_ratio 0.0000 +avg_length 4.0000 +avg_frequency 1.0467 +hist_size 240 +hist_type JSON_HB +decode_histogram(hist_type,histogram) { + "target_histogram_size": 254, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "42", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "1636", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "5808", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "16243", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "29034", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "71000", + "size": 0.004167688, + "ndv": 15 + }, + { + "start": "89200", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "89447", + "size": 0.004167688, + "ndv": 10 + }, + { + "start": "90000", + "size": 0.004167688, + "ndv": 11 + }, + { + "start": "90500", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "90814", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "91100", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "91700", + "size": 0.004167688, + "ndv": 13 + }, + { + "start": "92044", + "size": 0.004167688, + "ndv": 14 + }, + { + "start": "92574", + "size": 0.004167688, + "ndv": 13 + }, + { + "start": "92988", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "93342", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "93900", + "size": 0.004167688, + "ndv": 13 + }, + { + "start": "94200", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "94700", + "size": 0.004167688, + "ndv": 14 + }, + { + "start": "95052", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "95521", + "size": 0.004167688, + "ndv": 15 + }, + { + "start": "96100", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "96626", + "size": 0.004167688, + "ndv": 15 + }, + { + "start": "96938", + "size": 0.004167688, + "ndv": 14 + }, + { + "start": "97300", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "97929", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "98293", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "98640", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "99300", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "99781", + "size": 0.004167688, + "ndv": 14 + }, + { + "start": "100118", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "100490", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "100924", + "size": 0.004167688, + "ndv": 12 + }, + { + "start": "101295", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "101660", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "102121", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "102379", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "102820", + "size": 0.004167688, + "ndv": 15 + }, + { + "start": "103300", + "size": 0.004167688, + "ndv": 14 + }, + { + "start": "103653", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "104400", + "size": 0.004167688, + "ndv": 15 + }, + { + "start": "105080", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "105530", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "106000", + "size": 0.004167688, + "ndv": 15 + }, + { + "start": "106400", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "106996", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "107329", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "107770", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "108254", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "108600", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "109225", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "109600", + "size": 0.004167688, + "ndv": 14 + }, + { + "start": "110034", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "110700", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "111454", + "size": 0.004167688, + "ndv": 12 + }, + { + "start": "112007", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "112673", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "113494", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "114065", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "114815", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "115483", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "116132", + "size": 0.004167688, + "ndv": 15 + }, + { + "start": "116695", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "117258", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "118080", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "118815", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "119391", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "119990", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "120700", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "121197", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "121842", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "122400", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "123273", + "size": 0.004167688, + "ndv": 15 + }, + { + "start": "123776", + "size": 0.004167688, + "ndv": 14 + }, + { + "start": "124072", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "124600", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "125236", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "125700", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "126282", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "126872", + "size": 0.004167688, + "ndv": 14 + }, + { + "start": "127350", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "127898", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "128651", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "129688", + "size": 0.004167688, + "ndv": 13 + }, + { + "start": "130215", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "131149", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "132127", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "132820", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "133443", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "133936", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "134835", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "136062", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "137000", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "137700", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "138418", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "139357", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "140169", + "size": 0.004167688, + "ndv": 13 + }, + { + "start": "141132", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "142170", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "142990", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "144126", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "145150", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "146105", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "147124", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "147939", + "size": 0.004167688, + "ndv": 14 + }, + { + "start": "148867", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "149900", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "151000", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "152194", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "153344", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "154980", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "155941", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "157358", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "158720", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "160359", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "161500", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "163100", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "164367", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "165583", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "167183", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "168953", + "size": 0.004167688, + "ndv": 15 + }, + { + "start": "170123", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "171363", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "172648", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "173878", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "174984", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "176576", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "178200", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "179258", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "180400", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "182148", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "183261", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "184500", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "185951", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "187557", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "189036", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "190255", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "192509", + "size": 0.004167688, + "ndv": 15 + }, + { + "start": "194100", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "195468", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "197000", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "199000", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "200901", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "202451", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "204900", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "206338", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "208054", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "211068", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "213271", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "215373", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "217499", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "219761", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "222030", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "224044", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "226573", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "229212", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "232811", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "235760", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "239124", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "241769", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "243825", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "246535", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "249200", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "253587", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "255617", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "259537", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "262947", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "265211", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "269393", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "272058", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "275990", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "278829", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "282197", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "286848", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "291000", + "size": 0.004167688, + "ndv": 15 + }, + { + "start": "294125", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "299118", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "301504", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "305699", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "311200", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "315083", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "319373", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "324662", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "328711", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "332800", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "337966", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "342200", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "348100", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "353400", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "358663", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "362470", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "366712", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "375000", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "381725", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "386236", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "395402", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "403151", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "411542", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "419000", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "425579", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "433180", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "441649", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "450180", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "459884", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "469533", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "476668", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "483155", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "495540", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "510000", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "520000", + "size": 0.004167688, + "ndv": 15 + }, + { + "start": "530965", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "554636", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "568855", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "587211", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "606932", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "624269", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "650100", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "669181", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "701827", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "728060", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "762000", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "794246", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "830000", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "879000", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "947483", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "1002239", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "1060257", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "1119117", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "1186926", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "1248700", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "1346176", + "size": 0.004167688, + "ndv": 16 + }, + { + "start": "1458483", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "1615369", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "1861265", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "2117500", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "2500000", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "2896016", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "4017733", + "size": 0.004167688, + "ndv": 17 + }, + { + "start": "6758845", + "end": "10500000", + "size": 0.00392253, + "ndv": 16 + } + ] +} +set histogram_type=@SINGLE_PREC_TYPE; +set histogram_size=0; +use test; +DROP DATABASE world; +SELECT UPPER(db_name), UPPER(table_name), cardinality +FROM mysql.table_stats; +UPPER(db_name) UPPER(table_name) cardinality +WORLD_INNODB CITY 4079 +WORLD_INNODB COUNTRY 239 +WORLD_INNODB COUNTRYLANGUAGE 984 +SELECT UPPER(db_name), UPPER(table_name), +column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency +FROM mysql.column_stats; +UPPER(db_name) UPPER(table_name) column_name min_value max_value nulls_ratio avg_length avg_frequency +WORLD_INNODB CITY Country ABW ZWE 0.0000 3.0000 17.5819 +WORLD_INNODB CITY ID 1 4079 0.0000 4.0000 1.0000 +WORLD_INNODB CITY Name A Coruña (La Coruña) Ãœrgenc 0.0000 8.6416 1.0195 +WORLD_INNODB CITY Population 42 10500000 0.0000 4.0000 1.0467 +WORLD_INNODB COUNTRY Capital 1 4074 0.0293 4.0000 1.0000 +WORLD_INNODB COUNTRY Code ABW ZWE 0.0000 3.0000 1.0000 +WORLD_INNODB COUNTRY Name Afghanistan Zimbabwe 0.0000 10.1088 1.0000 +WORLD_INNODB COUNTRY Population 0 1277558000 0.0000 4.0000 1.0575 +WORLD_INNODB COUNTRY SurfaceArea 0.40 17075400.00 0.0000 4.0000 1.0042 +WORLD_INNODB COUNTRYLANGUAGE Country ABW ZWE 0.0000 3.0000 4.2232 +WORLD_INNODB COUNTRYLANGUAGE Language Abhyasi [South]Mande 0.0000 7.1778 2.1532 +WORLD_INNODB COUNTRYLANGUAGE Percentage 0.0 99.9 0.0000 4.0000 2.7640 +SELECT UPPER(db_name), UPPER(table_name), +index_name, prefix_arity, avg_frequency +FROM mysql.index_stats; +UPPER(db_name) UPPER(table_name) index_name prefix_arity avg_frequency +WORLD_INNODB CITY Country 1 17.5819 +WORLD_INNODB CITY PRIMARY 1 1.0000 +WORLD_INNODB CITY Population 1 1.0467 +WORLD_INNODB COUNTRY Name 1 1.0000 +WORLD_INNODB COUNTRY PRIMARY 1 1.0000 +WORLD_INNODB COUNTRYLANGUAGE PRIMARY 1 4.2232 +WORLD_INNODB COUNTRYLANGUAGE PRIMARY 2 1.0000 +WORLD_INNODB COUNTRYLANGUAGE Percentage 1 2.7640 +DROP DATABASE world_innodb; +SELECT UPPER(db_name), UPPER(table_name), cardinality +FROM mysql.table_stats; +UPPER(db_name) UPPER(table_name) cardinality +SELECT UPPER(db_name), UPPER(table_name), +column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency +FROM mysql.column_stats; +UPPER(db_name) UPPER(table_name) column_name min_value max_value nulls_ratio avg_length avg_frequency +SELECT UPPER(db_name), UPPER(table_name), +index_name, prefix_arity, avg_frequency +FROM mysql.index_stats; +UPPER(db_name) UPPER(table_name) index_name prefix_arity avg_frequency +DELETE FROM mysql.table_stats; +DELETE FROM mysql.column_stats; +DELETE FROM mysql.index_stats; +# +# Bug mdev-4357: empty string as a value of the HIST_SIZE column +# from mysql.column_stats +# +create table t1 (a int); +insert into t1 values (1),(2),(3); +set histogram_size=10; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +select db_name, table_name, column_name, +min_value, max_value, +nulls_ratio, avg_frequency, +hist_size, hist_type, decode_histogram(hist_type,histogram) +FROM mysql.column_stats +ORDER BY db_name, table_name, column_name; +db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type decode_histogram(hist_type,histogram) +test t1 a 1 3 0.0000 1.0000 3 JSON_HB { + "target_histogram_size": 10, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "1", + "size": 0.333333333, + "ndv": 1 + }, + { + "start": "2", + "size": 0.333333333, + "ndv": 1 + }, + { + "start": "3", + "end": "3", + "size": 0.333333333, + "ndv": 1 + } + ] +} +set histogram_size=default; +drop table t1; +# +# Bug mdev-4359: wrong setting of the HIST_SIZE column +# (see also mdev-4357) from mysql.column_stats +# +create table t1 ( a int); +insert into t1 values (1),(2),(3),(4),(5); +set histogram_size=10; +set histogram_type=@DOUBLE_PREC_TYPE; +show variables like 'histogram%'; +Variable_name Value +histogram_size 10 +histogram_type JSON_HB +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +select db_name, table_name, column_name, +min_value, max_value, +nulls_ratio, avg_frequency, +hist_size, hist_type, decode_histogram(hist_type,histogram) +FROM mysql.column_stats +ORDER BY db_name, table_name, column_name; +db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type decode_histogram(hist_type,histogram) +test t1 a 1 5 0.0000 1.0000 5 JSON_HB { + "target_histogram_size": 10, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "1", + "size": 0.2, + "ndv": 1 + }, + { + "start": "2", + "size": 0.2, + "ndv": 1 + }, + { + "start": "3", + "size": 0.2, + "ndv": 1 + }, + { + "start": "4", + "size": 0.2, + "ndv": 1 + }, + { + "start": "5", + "end": "5", + "size": 0.2, + "ndv": 1 + } + ] +} +set histogram_size=0; +set histogram_type=@SINGLE_PREC_TYPE; +drop table t1; +# +# Bug mdev-4369: histogram for a column with many distinct values +# +CREATE TABLE t1 (id int); +CREATE TABLE t2 (id int); +INSERT INTO t1 (id) VALUES (1), (1), (1),(1); +INSERT INTO t1 (id) SELECT id FROM t1; +INSERT INTO t1 SELECT id+1 FROM t1; +INSERT INTO t1 SELECT id+2 FROM t1; +INSERT INTO t1 SELECT id+4 FROM t1; +INSERT INTO t1 SELECT id+8 FROM t1; +INSERT INTO t1 SELECT id+16 FROM t1; +INSERT INTO t1 SELECT id+32 FROM t1; +INSERT INTO t1 SELECT id+64 FROM t1; +INSERT INTO t1 SELECT id+128 FROM t1; +INSERT INTO t1 SELECT id+256 FROM t1; +INSERT INTO t1 SELECT id+512 FROM t1; +INSERT INTO t2 SELECT id FROM t1 ORDER BY id*rand(); +SELECT COUNT(*) FROM t2; +COUNT(*) +8192 +SELECT COUNT(DISTINCT id) FROM t2; +COUNT(DISTINCT id) +1024 +set @@tmp_table_size=1024*16; +set @@max_heap_table_size=1024*16; +set histogram_size=63; +analyze table t2 persistent for all; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +select db_name, table_name, column_name, +min_value, max_value, +nulls_ratio, avg_frequency, +hist_size, hist_type, decode_histogram(hist_type,histogram) +FROM mysql.column_stats; +db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type decode_histogram(hist_type,histogram) +test t2 id 1 1024 0.0000 8.0000 63 JSON_HB { + "target_histogram_size": 63, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "1", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "17", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "33", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "50", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "66", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "82", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "99", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "115", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "132", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "148", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "164", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "181", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "197", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "213", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "230", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "246", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "263", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "279", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "295", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "312", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "328", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "344", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "361", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "377", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "394", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "410", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "426", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "443", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "459", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "475", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "492", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "508", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "525", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "541", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "557", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "574", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "590", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "606", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "623", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "639", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "656", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "672", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "688", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "705", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "721", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "737", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "754", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "770", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "787", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "803", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "819", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "836", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "852", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "868", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "885", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "901", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "918", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "934", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "950", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "967", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "983", + "size": 0.015991211, + "ndv": 17 + }, + { + "start": "999", + "size": 0.015991211, + "ndv": 18 + }, + { + "start": "1016", + "end": "1024", + "size": 0.008544922, + "ndv": 9 + } + ] +} +set histogram_size=0; +drop table t1, t2; +set use_stat_tables=@save_use_stat_tables; +# +# Bug MDEV-7383: min/max value for a column not utf8 compatible +# +create table t1 (a varchar(100)) engine=MyISAM; +insert into t1 values(unhex('D879626AF872675F73E662F8')); +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +show warnings; +Level Code Message +select db_name, table_name, column_name, +HEX(min_value), HEX(max_value), +nulls_ratio, avg_frequency, +hist_size, hist_type, decode_histogram(hist_type,histogram) +FROM mysql.column_stats; +db_name table_name column_name HEX(min_value) HEX(max_value) nulls_ratio avg_frequency hist_size hist_type decode_histogram(hist_type,histogram) +test t1 a D879626AF872675F73E662F8 D879626AF872675F73E662F8 0.0000 1.0000 0 NULL NULL +drop table t1; +# +# MDEB-9744: session optimizer_use_condition_selectivity=5 causing SQL Error (1918): +# Encountered illegal value '' when converting to DECIMAL +# +set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; +set optimizer_use_condition_selectivity=3, use_stat_tables=preferably; +create table t1 (id int(10),cost decimal(9,2)) engine=innodb; +ANALYZE TABLE t1 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +create temporary table t2 (id int); +insert into t2 (id) select id from t1 where cost > 0; +select * from t2; +id +set use_stat_tables=@save_use_stat_tables; +set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +drop table t1,t2; +# +# MDEV-16507: statistics for temporary tables should not be used +# +SET +@save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; +SET @@use_stat_tables = preferably ; +SET @@optimizer_use_condition_selectivity = 4; +CREATE TABLE t1 ( +TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +ON UPDATE CURRENT_TIMESTAMP +); +SET @had_t1_table= @@warning_count != 0; +CREATE TEMPORARY TABLE tmp_t1 LIKE t1; +INSERT INTO tmp_t1 VALUES (now()); +INSERT INTO t1 SELECT * FROM tmp_t1 WHERE @had_t1_table=0; +DROP TABLE t1; +SET +use_stat_tables=@save_use_stat_tables; +SET +optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +# End of 10.0 tests +# +# MDEV-9590: Always print "Engine-independent statistic" warnings and +# might be filtering columns unintentionally from engines +# +set use_stat_tables='NEVER'; +create table t1 (test blob); +show variables like 'use_stat_tables'; +Variable_name Value +use_stat_tables NEVER +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +drop table t1; +# +# MDEV-10435 crash with bad stat tables +# +set use_stat_tables='preferably'; +call mtr.add_suppression("Column count of mysql.table_stats is wrong. Expected 3, found 1. The table is probably corrupted"); +rename table mysql.table_stats to test.table_stats; +flush tables; +create table t1 (a int); +rename table t1 to t2, t3 to t4; +ERROR 42S02: Table 'test.t3' doesn't exist +drop table t1; +rename table test.table_stats to mysql.table_stats; +rename table mysql.table_stats to test.table_stats; +create table mysql.table_stats (a int); +flush tables; +create table t1 (a int); +rename table t1 to t2, t3 to t4; +ERROR 42S02: Table 'test.t3' doesn't exist +drop table t1, mysql.table_stats; +rename table test.table_stats to mysql.table_stats; +# +# MDEV-19334: bool is_eits_usable(Field*): Assertion `field->table->stats_is_read' failed. +# +create temporary table t1(a int); +insert into t1 values (1),(2),(3); +set use_stat_tables=preferably; +set @optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; +set optimizer_use_condition_selectivity=4; +select * from t1 where a >= 2; +a +2 +3 +drop table t1; +set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +set use_stat_tables=@save_use_stat_tables; +# +# Start of 10.2 tests +# +# +# MDEV-10134 Add full support for DEFAULT +# +# +# End of 10.2 tests +# +set histogram_size=@save_histogram_size, histogram_type=@save_hist_type; +# +# Start of 10.4 tests +# +# +# Test analyze_sample_percentage system variable. +# +set @save_use_stat_tables=@@use_stat_tables; +set @save_analyze_sample_percentage=@@analyze_sample_percentage; +set session rand_seed1=42; +set session rand_seed2=62; +set use_stat_tables=PREFERABLY; +set histogram_size=10; +CREATE TABLE t1 (id int); +INSERT INTO t1 (id) VALUES (1), (1), (1), (1), (1), (1), (1); +INSERT INTO t1 (id) SELECT id FROM t1; +INSERT INTO t1 SELECT id+1 FROM t1; +INSERT INTO t1 SELECT id+2 FROM t1; +INSERT INTO t1 SELECT id+4 FROM t1; +INSERT INTO t1 SELECT id+8 FROM t1; +INSERT INTO t1 SELECT id+16 FROM t1; +INSERT INTO t1 SELECT id+32 FROM t1; +INSERT INTO t1 SELECT id+64 FROM t1; +INSERT INTO t1 SELECT id+128 FROM t1; +INSERT INTO t1 SELECT id+256 FROM t1; +INSERT INTO t1 SELECT id+512 FROM t1; +INSERT INTO t1 SELECT id+1024 FROM t1; +INSERT INTO t1 SELECT id+2048 FROM t1; +INSERT INTO t1 SELECT id+4096 FROM t1; +INSERT INTO t1 SELECT id+9192 FROM t1; +# +# This query will should show a full table scan analysis. +# +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency, +DECODE_HISTOGRAM(hist_type, histogram) +from mysql.column_stats; +table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram) +t1 id 1 17384 0.0000 4.0000 14.0000 { + "target_histogram_size": 10, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "1", + "size": 0.100001744, + "ndv": 1639 + }, + { + "start": "1639", + "size": 0.100001744, + "ndv": 1639 + }, + { + "start": "3277", + "size": 0.100001744, + "ndv": 1640 + }, + { + "start": "4916", + "size": 0.100001744, + "ndv": 1639 + }, + { + "start": "6554", + "size": 0.100001744, + "ndv": 1640 + }, + { + "start": "9193", + "size": 0.100001744, + "ndv": 1639 + }, + { + "start": "10831", + "size": 0.100001744, + "ndv": 1639 + }, + { + "start": "12470", + "size": 0.100001744, + "ndv": 1639 + }, + { + "start": "14108", + "size": 0.100001744, + "ndv": 1639 + }, + { + "start": "15746", + "end": "17384", + "size": 0.099984305, + "ndv": 1639 + } + ] +} +set analyze_sample_percentage=0.1; +# +# This query will show an innacurate avg_frequency value. +# +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency, +DECODE_HISTOGRAM(hist_type, histogram) +from mysql.column_stats; +table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram) +t1 id 111 17026 0.0000 4.0000 10.4739 { + "target_histogram_size": 10, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "111", + "size": 0.103773585, + "ndv": 21 + }, + { + "start": "1074", + "size": 0.103773585, + "ndv": 22 + }, + { + "start": "2504", + "size": 0.103773585, + "ndv": 22 + }, + { + "start": "4395", + "size": 0.103773585, + "ndv": 22 + }, + { + "start": "6165", + "size": 0.103773585, + "ndv": 22 + }, + { + "start": "8082", + "size": 0.103773585, + "ndv": 22 + }, + { + "start": "10671", + "size": 0.103773585, + "ndv": 22 + }, + { + "start": "12738", + "size": 0.103773585, + "ndv": 22 + }, + { + "start": "14487", + "size": 0.103773585, + "ndv": 22 + }, + { + "start": "15785", + "end": "17026", + "size": 0.066037736, + "ndv": 14 + } + ] +} +# +# This query will show a better avg_frequency value. +# +set analyze_sample_percentage=25; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency, +DECODE_HISTOGRAM(hist_type, histogram) +from mysql.column_stats; +table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram) +t1 id 1 17384 0.0000 4.0000 14.0401 { + "target_histogram_size": 10, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "1", + "size": 0.100015657, + "ndv": 1591 + }, + { + "start": "1624", + "size": 0.100015657, + "ndv": 1599 + }, + { + "start": "3252", + "size": 0.100015657, + "ndv": 1587 + }, + { + "start": "4868", + "size": 0.100015657, + "ndv": 1594 + }, + { + "start": "6483", + "size": 0.100015657, + "ndv": 1632 + }, + { + "start": "8153", + "size": 0.100015657, + "ndv": 1607 + }, + { + "start": "10791", + "size": 0.100015657, + "ndv": 1619 + }, + { + "start": "12435", + "size": 0.100015657, + "ndv": 1627 + }, + { + "start": "14080", + "size": 0.100015657, + "ndv": 1613 + }, + { + "start": "15727", + "end": "17384", + "size": 0.099859084, + "ndv": 1622 + } + ] +} +set analyze_sample_percentage=0; +# +# Test self adjusting sampling level. +# +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency, +DECODE_HISTOGRAM(hist_type, histogram) +from mysql.column_stats; +table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram) +t1 id 1 17384 0.0000 4.0000 13.9812 { + "target_histogram_size": 10, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "1", + "size": 0.100007372, + "ndv": 1651 + }, + { + "start": "1651", + "size": 0.100007372, + "ndv": 1656 + }, + { + "start": "3306", + "size": 0.100007372, + "ndv": 1643 + }, + { + "start": "4949", + "size": 0.100007372, + "ndv": 1648 + }, + { + "start": "6597", + "size": 0.100007372, + "ndv": 1644 + }, + { + "start": "9240", + "size": 0.100007372, + "ndv": 1624 + }, + { + "start": "10864", + "size": 0.100007372, + "ndv": 1633 + }, + { + "start": "12496", + "size": 0.100007372, + "ndv": 1619 + }, + { + "start": "14114", + "size": 0.100007372, + "ndv": 1645 + }, + { + "start": "15758", + "end": "17384", + "size": 0.099933656, + "ndv": 1627 + } + ] +} +# +# Test record estimation is working properly. +# +select count(*) from t1; +count(*) +229376 +explain select * from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 229060 +set analyze_sample_percentage=100; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency, +DECODE_HISTOGRAM(hist_type, histogram) +from mysql.column_stats; +table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram) +t1 id 1 17384 0.0000 4.0000 14.0000 { + "target_histogram_size": 10, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "1", + "size": 0.100001744, + "ndv": 1639 + }, + { + "start": "1639", + "size": 0.100001744, + "ndv": 1639 + }, + { + "start": "3277", + "size": 0.100001744, + "ndv": 1640 + }, + { + "start": "4916", + "size": 0.100001744, + "ndv": 1639 + }, + { + "start": "6554", + "size": 0.100001744, + "ndv": 1640 + }, + { + "start": "9193", + "size": 0.100001744, + "ndv": 1639 + }, + { + "start": "10831", + "size": 0.100001744, + "ndv": 1639 + }, + { + "start": "12470", + "size": 0.100001744, + "ndv": 1639 + }, + { + "start": "14108", + "size": 0.100001744, + "ndv": 1639 + }, + { + "start": "15746", + "end": "17384", + "size": 0.099984305, + "ndv": 1639 + } + ] +} +explain select * from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 229376 +drop table t0; +drop table t1; +set analyze_sample_percentage=@save_analyze_sample_percentage; +set histogram_size=@save_histogram_size; +set use_stat_tables=@save_use_stat_tables; +set @@global.histogram_size=@save_histogram_size; +drop table if exists t1; +set @save_histogram_type=@@histogram_type; +set @save_histogram_size=@@histogram_size; +call mtr.add_suppression("Failed to parse histogram for table .*"); +create table ten(a int primary key); +insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +set histogram_size=100; +set histogram_type='double_prec_hb'; +create table t1_bin (a varchar(255)); +insert into t1_bin select concat('a-', a) from ten; +analyze table t1_bin persistent for all; +Table Op Msg_type Msg_text +test.t1_bin analyze status Engine-independent statistics collected +test.t1_bin analyze status OK +select hex(histogram) from mysql.column_stats where table_name='t1_bin'; +hex(histogram) +00000000000000000000711C711C711C711C711CE338E338E338E338E33855555555555555555555C671C671C671C671C671388E388E388E388E388EAAAAAAAAAAAAAAAAAAAA1BC71BC71BC71BC71BC78DE38DE38DE38DE38DE3FFFFFFFFFFFFFFFFFFFF +explain extended select * from t1_bin where a between 'a-3a' and 'zzzzzzzzz'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_bin ALL NULL NULL NULL NULL 10 58.82 Using where +Warnings: +Note 1003 select `test`.`t1_bin`.`a` AS `a` from `test`.`t1_bin` where `test`.`t1_bin`.`a` between 'a-3a' and 'zzzzzzzzz' +analyze select * from t1_bin where a between 'a-3a' and 'zzzzzzzzz'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1_bin ALL NULL NULL NULL NULL 10 10.00 58.82 60.00 Using where +set histogram_type=json_hb; +create table t1_json (a varchar(255)); +insert into t1_json select concat('a-', a) from ten; +analyze table t1_json persistent for all; +Table Op Msg_type Msg_text +test.t1_json analyze status Engine-independent statistics collected +test.t1_json analyze status OK +select * from mysql.column_stats where table_name='t1_json'; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1_json a a-0 a-9 0.0000 3.0000 1.0000 10 JSON_HB { + "target_histogram_size": 100, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "a-0", + "size": 0.1, + "ndv": 1 + }, + { + "start": "a-1", + "size": 0.1, + "ndv": 1 + }, + { + "start": "a-2", + "size": 0.1, + "ndv": 1 + }, + { + "start": "a-3", + "size": 0.1, + "ndv": 1 + }, + { + "start": "a-4", + "size": 0.1, + "ndv": 1 + }, + { + "start": "a-5", + "size": 0.1, + "ndv": 1 + }, + { + "start": "a-6", + "size": 0.1, + "ndv": 1 + }, + { + "start": "a-7", + "size": 0.1, + "ndv": 1 + }, + { + "start": "a-8", + "size": 0.1, + "ndv": 1 + }, + { + "start": "a-9", + "end": "a-9", + "size": 0.1, + "ndv": 1 + } + ] +} +explain extended select * from t1_json where a between 'a-3a' and 'zzzzzzzzz'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 select `test`.`t1_json`.`a` AS `a` from `test`.`t1_json` where `test`.`t1_json`.`a` between 'a-3a' and 'zzzzzzzzz' +analyze select * from t1_json where a between 'a-3a' and 'zzzzzzzzz'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 10.00 60.00 60.00 Using where +explain extended select * from t1_json where a < 'b-1a'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 select `test`.`t1_json`.`a` AS `a` from `test`.`t1_json` where `test`.`t1_json`.`a` < 'b-1a' +analyze select * from t1_json where a > 'zzzzzzzzz'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 10.00 0.00 0.00 Using where +drop table ten; +UPDATE mysql.column_stats +SET histogram='["not-what-you-expect"]' WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 +Warnings: +Warning 4186 Failed to parse histogram for table test.t1_json: Root JSON element must be a JSON object at offset 1. +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":"not-histogram"}' WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 +Warnings: +Warning 4186 Failed to parse histogram for table test.t1_json: histogram_hb must contain an array at offset 32. +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":["not-a-bucket"]}' +WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 +Warnings: +Warning 4186 Failed to parse histogram for table test.t1_json: Expected an object in the buckets array at offset 32. +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":[{"no-expected-members":1}]}' +WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 +Warnings: +Warning 4186 Failed to parse histogram for table test.t1_json: "start" element not present at offset 42. +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":[{"start":{}}]}' +WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 +Warnings: +Warning 4186 Failed to parse histogram for table test.t1_json: String or number expected at offset 27. +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":[{"start":"aaa", "size":"not-an-integer"}]}' +WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 +Warnings: +Warning 4186 Failed to parse histogram for table test.t1_json: "ndv" element not present at offset 57. +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":[{"start":"aaa", "size":0.25}]}' +WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 +Warnings: +Warning 4186 Failed to parse histogram for table test.t1_json: "ndv" element not present at offset 45. +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":[{"start":"aaa", "size":0.25, "ndv":1}]}' +WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":[]}' +WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 +Warnings: +Warning 4186 Failed to parse histogram for table test.t1_json: Histogram must have at least one bucket at offset 19. +create table t2 ( +city varchar(100) +); +set histogram_size=50; +insert into t2 select 'Moscow' from seq_1_to_99; +insert into t2 select 'Helsinki' from seq_1_to_2; +set histogram_type=json_hb; +analyze table t2 persistent for all; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +explain extended select * from t2 where city = 'Moscow'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 101 98.02 Using where +Warnings: +Note 1003 select `test`.`t2`.`city` AS `city` from `test`.`t2` where `test`.`t2`.`city` = 'Moscow' +analyze select * from t2 where city = 'Moscow'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 101 101.00 98.02 98.02 Using where +explain extended select * from t2 where city = 'Helsinki'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 101 1.98 Using where +Warnings: +Note 1003 select `test`.`t2`.`city` AS `city` from `test`.`t2` where `test`.`t2`.`city` = 'Helsinki' +analyze select * from t2 where city = 'helsinki'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 101 101.00 1.98 1.98 Using where +explain extended select * from t2 where city < 'Lagos'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 101 1.98 Using where +Warnings: +Note 1003 select `test`.`t2`.`city` AS `city` from `test`.`t2` where `test`.`t2`.`city` < 'Lagos' +drop table t1_bin; +drop table t1_json; +drop table t2; +DELETE FROM mysql.column_stats; +create schema world; +use world; +set histogram_type='JSON_HB'; +set histogram_size=50; +ANALYZE TABLE Country, City, CountryLanguage persistent for all; +SELECT column_name, min_value, max_value, hist_size, hist_type, histogram FROM mysql.column_stats; +column_name min_value max_value hist_size hist_type histogram +Code ABW ZWE 48 JSON_HB { + "target_histogram_size": 50, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "ABW", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "AND", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "ASM", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "AUT", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "BFA", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "BIH", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "BRA", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "BWA", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "CHL", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "COG", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "CRI", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "CZE", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "DOM", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "ESH", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "FJI", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "GAB", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "GIN", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "GRC", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "GUM", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "HRV", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "IOT", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "ISR", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "KAZ", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "KNA", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "LBR", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "LSO", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "MAR", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "MEX", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "MMR", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "MSR", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "MYT", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "NGA", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "NPL", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "PAN", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "PNG", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "PRY", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "ROM", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "SEN", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "SLB", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "SPM", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "SWE", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "TCD", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "TKM", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "TUR", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "UKR", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "VAT", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "VNM", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "YUG", + "end": "ZWE", + "size": 0.016736402, + "ndv": 4 + } + ] +} +Country ABW ZWE 39 JSON_HB { + "target_histogram_size": 50, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "ABW", + "size": 0.020102966, + "ndv": 11 + }, + { + "start": "ATG", + "size": 0.020102966, + "ndv": 14 + }, + { + "start": "BLR", + "size": 0.006619269, + "ndv": 4 + }, + { + "start": "BRA", + "size": 0.061289532, + "ndv": 1 + }, + { + "start": "BRB", + "size": 0.020102966, + "ndv": 9 + }, + { + "start": "CHL", + "size": 0.002206423, + "ndv": 1 + }, + { + "start": "CHN", + "size": 0.0889924, + "ndv": 1 + }, + { + "start": "CIV", + "size": 0.020102966, + "ndv": 10 + }, + { + "start": "CUB", + "size": 0.020102966, + "ndv": 6 + }, + { + "start": "DEU", + "size": 0.020102966, + "ndv": 8 + }, + { + "start": "EGY", + "size": 0.020102966, + "ndv": 4 + }, + { + "start": "ESP", + "size": 0.020102966, + "ndv": 11 + }, + { + "start": "GBR", + "size": 0.020102966, + "ndv": 3 + }, + { + "start": "GIB", + "size": 0.020102966, + "ndv": 19 + }, + { + "start": "IDN", + "size": 0.012503064, + "ndv": 1 + }, + { + "start": "IND", + "size": 0.083598921, + "ndv": 1 + }, + { + "start": "IRL", + "size": 0.020102966, + "ndv": 3 + }, + { + "start": "IRQ", + "size": 0.020102966, + "ndv": 6 + }, + { + "start": "JOR", + "size": 2.451581e-4, + "ndv": 1 + }, + { + "start": "JPN", + "size": 0.060799215, + "ndv": 1 + }, + { + "start": "KAZ", + "size": 0.020102966, + "ndv": 7 + }, + { + "start": "KOR", + "size": 0.020102966, + "ndv": 16 + }, + { + "start": "MDA", + "size": 0.002451581, + "ndv": 3 + }, + { + "start": "MEX", + "size": 0.042412356, + "ndv": 1 + }, + { + "start": "MHL", + "size": 0.020102966, + "ndv": 20 + }, + { + "start": "NGA", + "size": 0.020102966, + "ndv": 4 + }, + { + "start": "NLD", + "size": 0.020102966, + "ndv": 7 + }, + { + "start": "PAK", + "size": 0.007354744, + "ndv": 4 + }, + { + "start": "PHL", + "size": 0.033341505, + "ndv": 1 + }, + { + "start": "PLW", + "size": 0.020102966, + "ndv": 8 + }, + { + "start": "PSE", + "size": 0.008580534, + "ndv": 5 + }, + { + "start": "RUS", + "size": 0.046334886, + "ndv": 1 + }, + { + "start": "RWA", + "size": 0.020102966, + "ndv": 18 + }, + { + "start": "SWE", + "size": 0.020102966, + "ndv": 16 + }, + { + "start": "TUR", + "size": 0.020102966, + "ndv": 4 + }, + { + "start": "TZA", + "size": 0.015199804, + "ndv": 4 + }, + { + "start": "USA", + "size": 0.067173327, + "ndv": 1 + }, + { + "start": "UZB", + "size": 0.020102966, + "ndv": 7 + }, + { + "start": "VNM", + "end": "ZWE", + "size": 0.018632018, + "ndv": 9 + } + ] +} +Name Afghanistan Zimbabwe 48 JSON_HB { + "target_histogram_size": 50, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "Afghanistan", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Angola", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Armenia", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Bahamas", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Belgium", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Bolivia", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "British Indian Ocean Territory", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Cambodia", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Central African Republic", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Cocos (Keeling) Islands", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Cook Islands", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Czech Republic", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Dominican Republic", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Equatorial Guinea", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Faroe Islands", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "French Polynesia", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Germany", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Grenada", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Guinea-Bissau", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Honduras", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Indonesia", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Italy", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Kenya", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Latvia", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Liechtenstein", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Madagascar", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Malta", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Mayotte", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Mongolia", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Namibia", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "New Caledonia", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Niue", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Oman", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Papua New Guinea", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Poland", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Russian Federation", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Saint Lucia", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Sao Tome and Principe", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Singapore", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "South Africa", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Sudan", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Switzerland", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Thailand", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Tunisia", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Uganda", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "United States Minor Outlying Islands", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Vietnam", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "Yemen", + "end": "Zimbabwe", + "size": 0.016736402, + "ndv": 4 + } + ] +} +SurfaceArea 0.40 17075400.00 48 JSON_HB { + "target_histogram_size": 50, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "0.40", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "16.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "49.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "96.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "181.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "242.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "314.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "373.00", + "size": 0.020920502, + "ndv": 4 + }, + { + "start": "455.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "618.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "726.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "1102.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "2510.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "4033.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "8875.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "11295.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "17364.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "21041.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "26338.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "28896.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "36125.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "45227.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "51197.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "65301.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "75517.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "88946.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "102173.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "111369.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "120538.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "147181.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "185180.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "236800.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "245857.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "283561.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "323250.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "342000.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "438317.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "475442.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "551500.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "622984.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "756626.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "883749.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "1098581.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "1246700.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "1648195.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "2166090.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "2780400.00", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "9572900.00", + "end": "17075400.00", + "size": 0.016736402, + "ndv": 4 + } + ] +} +Population 0 1277558000 48 JSON_HB { + "target_histogram_size": 50, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "0", + "size": 0.029288703, + "ndv": 1 + }, + { + "start": "50", + "size": 0.020920502, + "ndv": 4 + }, + { + "start": "2000", + "size": 0.020920502, + "ndv": 4 + }, + { + "start": "7000", + "size": 0.020920502, + "ndv": 4 + }, + { + "start": "15000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "25000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "38000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "68000", + "size": 0.020920502, + "ndv": 4 + }, + { + "start": "78000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "103000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "154000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "214000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "279000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "380200", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "444000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "599000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "817000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "1213000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "1622000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "2124000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "2583000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "3101000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "3520000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "3850000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "4380000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "4699000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "5083000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "5496000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "6276000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "7430000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "8190900", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "9169000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "10097000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "10640000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "11234000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "12878000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "15942000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "18886000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "22244000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "23930000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "28351000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "33517000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "42321000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "57680000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "66591000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "82164700", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "146934000", + "size": 0.020920502, + "ndv": 5 + }, + { + "start": "1013662000", + "end": "1277558000", + "size": 0.008368201, + "ndv": 2 + } + ] +} +Capital 1 4074 47 JSON_HB { + "target_histogram_size": 50, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "1", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "54", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "65", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "144", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "179", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "194", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "537", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "553", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "586", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "652", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "764", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "905", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "919", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "928", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "939", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "1449", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "1530", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "1792", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "1864", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "2256", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "2317", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "2413", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "2437", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "2447", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "2460", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "2484", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "2511", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "2695", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "2726", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "2754", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "2821", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "2885", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "2919", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "3014", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "3048", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "3067", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "3171", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "3207", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "3217", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "3248", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "3315", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "3336", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "3419", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "3483", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "3520", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "3580", + "size": 0.021551724, + "ndv": 5 + }, + { + "start": "4068", + "end": "4074", + "size": 0.00862069, + "ndv": 2 + } + ] +} +ID 1 4079 50 JSON_HB { + "target_histogram_size": 50, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "1", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "83", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "165", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "247", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "329", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "411", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "493", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "575", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "657", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "739", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "821", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "903", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "985", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "1067", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "1149", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "1231", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "1313", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "1395", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "1477", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "1559", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "1641", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "1723", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "1805", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "1887", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "1969", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "2051", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "2133", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "2215", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "2297", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "2379", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "2461", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "2543", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "2625", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "2707", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "2789", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "2871", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "2953", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "3035", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "3117", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "3199", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "3281", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "3363", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "3445", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "3527", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "3609", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "3691", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "3773", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "3855", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "3937", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "4019", + "end": "4079", + "size": 0.014954646, + "ndv": 61 + } + ] +} +Name A Coruña (La Coruña) Ãœrgenc 50 JSON_HB { + "target_histogram_size": 50, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "A Coruña (La Coruña)", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "AlmerÃa", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Araras", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "Bakersfield", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Bayamo", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "Bilaspur", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "Bridgeport", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "Cambridge", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "Chatsworth", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "Cizah", + "size": 0.020102966, + "ndv": 78 + }, + { + "start": "Da Nang", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Djougou", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Emeishan", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "Freiburg im Breisgau", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "Giugliano in Campania", + "size": 0.020102966, + "ndv": 79 + }, + { + "start": "Györ", + "size": 0.020102966, + "ndv": 79 + }, + { + "start": "Herat", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Hyesan", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "Itabira", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "Jiangyou", + "size": 0.020102966, + "ndv": 79 + }, + { + "start": "Kamjanets-Podilskyi", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Khouribga", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Koudougou", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "Lahore", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "Linköping", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "Machilipatnam (Masulipatam)", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "Marikina", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Miami Beach", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "Moscow", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Nanded (Nander)", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Nizni Tagil", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "Okazaki", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "Pak Kret", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "Petah Tiqwa", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Porto-Novo", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Qomsheh", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "Rimini", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Salamanca", + "size": 0.020102966, + "ndv": 70 + }, + { + "start": "Sanaa", + "size": 0.020102966, + "ndv": 78 + }, + { + "start": "Secunderabad", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "Silay", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "Subotica", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Tagum", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Tema", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "Tongling", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Udine", + "size": 0.020102966, + "ndv": 79 + }, + { + "start": "Verona", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "Wichita Falls", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "Yibin", + "size": 0.020102966, + "ndv": 79 + }, + { + "start": "Zixing", + "end": "Ãœrgenc", + "size": 0.014954646, + "ndv": 61 + } + ] +} +Population 42 10500000 50 JSON_HB { + "target_histogram_size": 50, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "42", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "56601", + "size": 0.020102966, + "ndv": 64 + }, + { + "start": "90674", + "size": 0.020102966, + "ndv": 70 + }, + { + "start": "92700", + "size": 0.020102966, + "ndv": 76 + }, + { + "start": "94800", + "size": 0.020102966, + "ndv": 74 + }, + { + "start": "96984", + "size": 0.020102966, + "ndv": 75 + }, + { + "start": "99296", + "size": 0.020102966, + "ndv": 73 + }, + { + "start": "101144", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "103211", + "size": 0.020102966, + "ndv": 73 + }, + { + "start": "105700", + "size": 0.020102966, + "ndv": 77 + }, + { + "start": "107800", + "size": 0.020102966, + "ndv": 76 + }, + { + "start": "110048", + "size": 0.020102966, + "ndv": 76 + }, + { + "start": "113336", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "116485", + "size": 0.020102966, + "ndv": 79 + }, + { + "start": "119675", + "size": 0.020102966, + "ndv": 77 + }, + { + "start": "122700", + "size": 0.020102966, + "ndv": 77 + }, + { + "start": "125300", + "size": 0.020102966, + "ndv": 77 + }, + { + "start": "127898", + "size": 0.020102966, + "ndv": 77 + }, + { + "start": "131831", + "size": 0.020102966, + "ndv": 79 + }, + { + "start": "135621", + "size": 0.020102966, + "ndv": 79 + }, + { + "start": "139712", + "size": 0.020102966, + "ndv": 75 + }, + { + "start": "144282", + "size": 0.020102966, + "ndv": 77 + }, + { + "start": "149000", + "size": 0.020102966, + "ndv": 79 + }, + { + "start": "154976", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "161191", + "size": 0.020102966, + "ndv": 78 + }, + { + "start": "167795", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "174381", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "180650", + "size": 0.020102966, + "ndv": 79 + }, + { + "start": "187691", + "size": 0.020102966, + "ndv": 76 + }, + { + "start": "195400", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "203500", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "214901", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "224897", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "239810", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "253587", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "268013", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "285114", + "size": 0.020102966, + "ndv": 77 + }, + { + "start": "303346", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "325790", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "348845", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "374945", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "410000", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "445555", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "487148", + "size": 0.020102966, + "ndv": 79 + }, + { + "start": "559249", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "651154", + "size": 0.020102966, + "ndv": 82 + }, + { + "start": "791926", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "1040000", + "size": 0.020102966, + "ndv": 80 + }, + { + "start": "1398800", + "size": 0.020102966, + "ndv": 81 + }, + { + "start": "2641312", + "end": "10500000", + "size": 0.014954646, + "ndv": 61 + } + ] +} +Country ABW ZWE 50 JSON_HB { + "target_histogram_size": 50, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "ABW", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "ALB", + "size": 0.020325203, + "ndv": 8 + }, + { + "start": "ATG", + "size": 0.020325203, + "ndv": 4 + }, + { + "start": "AZE", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "BFA", + "size": 0.020325203, + "ndv": 7 + }, + { + "start": "BLR", + "size": 0.020325203, + "ndv": 7 + }, + { + "start": "BRN", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "CAN", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "CHN", + "size": 0.020325203, + "ndv": 3 + }, + { + "start": "CMR", + "size": 0.020325203, + "ndv": 3 + }, + { + "start": "COK", + "size": 0.020325203, + "ndv": 7 + }, + { + "start": "CXR", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "DJI", + "size": 0.020325203, + "ndv": 8 + }, + { + "start": "ERI", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "ETH", + "size": 0.020325203, + "ndv": 7 + }, + { + "start": "FSM", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "GHA", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "GNB", + "size": 0.020325203, + "ndv": 8 + }, + { + "start": "GUM", + "size": 0.020325203, + "ndv": 7 + }, + { + "start": "HUN", + "size": 0.020325203, + "ndv": 3 + }, + { + "start": "IND", + "size": 0.020325203, + "ndv": 4 + }, + { + "start": "IRQ", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "JOR", + "size": 0.020325203, + "ndv": 4 + }, + { + "start": "KEN", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "KWT", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "LCA", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "LVA", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "MDA", + "size": 0.020325203, + "ndv": 7 + }, + { + "start": "MLI", + "size": 0.020325203, + "ndv": 4 + }, + { + "start": "MNP", + "size": 0.020325203, + "ndv": 3 + }, + { + "start": "MRT", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "MYS", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "NFK", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "NLD", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "OMN", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "PHL", + "size": 0.020325203, + "ndv": 4 + }, + { + "start": "PRI", + "size": 0.020325203, + "ndv": 8 + }, + { + "start": "REU", + "size": 0.020325203, + "ndv": 4 + }, + { + "start": "RWA", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "SGP", + "size": 0.020325203, + "ndv": 8 + }, + { + "start": "SPM", + "size": 0.020325203, + "ndv": 7 + }, + { + "start": "SWZ", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "TGO", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "TON", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "TZA", + "size": 0.020325203, + "ndv": 2 + }, + { + "start": "UGA", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "USA", + "size": 0.020325203, + "ndv": 8 + }, + { + "start": "VNM", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "YUG", + "size": 0.020325203, + "ndv": 3 + }, + { + "start": "ZWE", + "end": "ZWE", + "size": 0.004065041, + "ndv": 1 + } + ] +} +Language Abhyasi [South]Mande 48 JSON_HB { + "target_histogram_size": 50, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "Abhyasi", + "size": 0.020325203, + "ndv": 12 + }, + { + "start": "Ami", + "size": 0.020325203, + "ndv": 3 + }, + { + "start": "Arabic", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "Armenian", + "size": 0.020325203, + "ndv": 11 + }, + { + "start": "Balochi", + "size": 0.020325203, + "ndv": 13 + }, + { + "start": "Belorussian", + "size": 0.020325203, + "ndv": 13 + }, + { + "start": "Bullom-sherbro", + "size": 0.020325203, + "ndv": 15 + }, + { + "start": "Chechen", + "size": 0.020325203, + "ndv": 7 + }, + { + "start": "Chinese", + "size": 0.020325203, + "ndv": 12 + }, + { + "start": "Creole English", + "size": 0.020325203, + "ndv": 2 + }, + { + "start": "Creole French", + "size": 0.020325203, + "ndv": 13 + }, + { + "start": "Dorbet", + "size": 0.012195122, + "ndv": 8 + }, + { + "start": "English", + "size": 0.06097561, + "ndv": 1 + }, + { + "start": "Eskimo Languages", + "size": 0.020325203, + "ndv": 9 + }, + { + "start": "French", + "size": 0.020325203, + "ndv": 2 + }, + { + "start": "Friuli", + "size": 0.020325203, + "ndv": 9 + }, + { + "start": "Ganda", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "German", + "size": 0.020325203, + "ndv": 11 + }, + { + "start": "GuaymÃ", + "size": 0.020325203, + "ndv": 15 + }, + { + "start": "Hehet", + "size": 0.020325203, + "ndv": 7 + }, + { + "start": "Hungarian", + "size": 0.020325203, + "ndv": 10 + }, + { + "start": "Italian", + "size": 0.020325203, + "ndv": 10 + }, + { + "start": "Kanuri", + "size": 0.020325203, + "ndv": 10 + }, + { + "start": "Khoekhoe", + "size": 0.020325203, + "ndv": 11 + }, + { + "start": "Kotokoli", + "size": 0.020325203, + "ndv": 14 + }, + { + "start": "Lithuanian", + "size": 0.020325203, + "ndv": 16 + }, + { + "start": "Macedonian", + "size": 0.020325203, + "ndv": 13 + }, + { + "start": "Malenasian Languages", + "size": 0.020325203, + "ndv": 12 + }, + { + "start": "Maranao", + "size": 0.020325203, + "ndv": 18 + }, + { + "start": "Miao", + "size": 0.020325203, + "ndv": 17 + }, + { + "start": "Muong", + "size": 0.020325203, + "ndv": 15 + }, + { + "start": "Norwegian", + "size": 0.020325203, + "ndv": 18 + }, + { + "start": "Paiwan", + "size": 0.020325203, + "ndv": 13 + }, + { + "start": "Polish", + "size": 0.020325203, + "ndv": 3 + }, + { + "start": "Portuguese", + "size": 0.020325203, + "ndv": 9 + }, + { + "start": "Romanian", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "Russian", + "size": 0.020325203, + "ndv": 10 + }, + { + "start": "Saraiki", + "size": 0.020325203, + "ndv": 10 + }, + { + "start": "Sidamo", + "size": 0.020325203, + "ndv": 12 + }, + { + "start": "Soninke", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "Spanish", + "size": 0.020325203, + "ndv": 4 + }, + { + "start": "Sunda", + "size": 0.020325203, + "ndv": 11 + }, + { + "start": "Tamil", + "size": 0.020325203, + "ndv": 11 + }, + { + "start": "Tigre", + "size": 0.020325203, + "ndv": 15 + }, + { + "start": "Turkish", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "Ukrainian", + "size": 0.020325203, + "ndv": 4 + }, + { + "start": "Uzbek", + "size": 0.020325203, + "ndv": 13 + }, + { + "start": "Yap", + "end": "[South]Mande", + "size": 0.012195122, + "ndv": 9 + } + ] +} +Percentage 0.0 99.9 47 JSON_HB { + "target_histogram_size": 50, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "0.0", + "size": 0.066056911, + "ndv": 1 + }, + { + "start": "0.1", + "size": 0.020325203, + "ndv": 1 + }, + { + "start": "0.2", + "size": 0.022357724, + "ndv": 1 + }, + { + "start": "0.3", + "size": 0.017276423, + "ndv": 1 + }, + { + "start": "0.4", + "size": 0.025406504, + "ndv": 1 + }, + { + "start": "0.5", + "size": 0.020325203, + "ndv": 1 + }, + { + "start": "0.6", + "size": 0.020325203, + "ndv": 1 + }, + { + "start": "0.7", + "size": 0.020325203, + "ndv": 2 + }, + { + "start": "0.8", + "size": 0.020325203, + "ndv": 3 + }, + { + "start": "1.0", + "size": 0.020325203, + "ndv": 4 + }, + { + "start": "1.3", + "size": 0.020325203, + "ndv": 2 + }, + { + "start": "1.4", + "size": 0.020325203, + "ndv": 3 + }, + { + "start": "1.6", + "size": 0.020325203, + "ndv": 3 + }, + { + "start": "1.8", + "size": 0.020325203, + "ndv": 4 + }, + { + "start": "2.1", + "size": 0.020325203, + "ndv": 3 + }, + { + "start": "2.3", + "size": 0.020325203, + "ndv": 4 + }, + { + "start": "2.6", + "size": 0.020325203, + "ndv": 4 + }, + { + "start": "2.9", + "size": 0.020325203, + "ndv": 4 + }, + { + "start": "3.2", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "3.6", + "size": 0.020325203, + "ndv": 5 + }, + { + "start": "4.1", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "4.6", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "5.1", + "size": 0.020325203, + "ndv": 7 + }, + { + "start": "5.7", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "6.2", + "size": 0.020325203, + "ndv": 8 + }, + { + "start": "6.9", + "size": 0.020325203, + "ndv": 7 + }, + { + "start": "7.6", + "size": 0.020325203, + "ndv": 6 + }, + { + "start": "8.2", + "size": 0.020325203, + "ndv": 7 + }, + { + "start": "8.9", + "size": 0.020325203, + "ndv": 9 + }, + { + "start": "9.7", + "size": 0.020325203, + "ndv": 11 + }, + { + "start": "11.0", + "size": 0.020325203, + "ndv": 15 + }, + { + "start": "12.4", + "size": 0.020325203, + "ndv": 14 + }, + { + "start": "14.1", + "size": 0.020325203, + "ndv": 13 + }, + { + "start": "16.5", + "size": 0.020325203, + "ndv": 17 + }, + { + "start": "19.7", + "size": 0.020325203, + "ndv": 14 + }, + { + "start": "23.3", + "size": 0.020325203, + "ndv": 16 + }, + { + "start": "31.7", + "size": 0.020325203, + "ndv": 16 + }, + { + "start": "37.5", + "size": 0.020325203, + "ndv": 19 + }, + { + "start": "47.4", + "size": 0.020325203, + "ndv": 18 + }, + { + "start": "55.1", + "size": 0.020325203, + "ndv": 19 + }, + { + "start": "66.7", + "size": 0.020325203, + "ndv": 18 + }, + { + "start": "78.1", + "size": 0.020325203, + "ndv": 15 + }, + { + "start": "86.2", + "size": 0.020325203, + "ndv": 18 + }, + { + "start": "90.7", + "size": 0.020325203, + "ndv": 15 + }, + { + "start": "95.1", + "size": 0.020325203, + "ndv": 14 + }, + { + "start": "97.6", + "size": 0.020325203, + "ndv": 14 + }, + { + "start": "99.9", + "end": "99.9", + "size": 0.015243902, + "ndv": 1 + } + ] +} +analyze select * from Country use index () where Code between 'BBC' and 'GGG'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE Country ALL NULL NULL NULL NULL 239 239.00 24.58 25.52 Using where +analyze select * from Country use index () where Code < 'BBC'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE Country ALL NULL NULL NULL NULL 239 239.00 8.37 7.11 Using where +set histogram_type=@save_histogram_type; +set histogram_size=@save_histogram_size; +DROP SCHEMA world; +use test; +create table t10 ( +a varchar(10) +); +# +# Histograms are not collected for empty tables: +# +analyze table t10 persistent for all; +Table Op Msg_type Msg_text +test.t10 analyze status Engine-independent statistics collected +test.t10 analyze status Table is already up to date +select histogram +from mysql.column_stats where table_name='t10' and db_name=database(); +histogram +NULL +# +# Try with n_buckets > n_rows +# +insert into t10 values ('Berlin'),('Paris'),('Rome'); +set histogram_size=10, histogram_type='json_hb'; +analyze table t10 persistent for all; +Table Op Msg_type Msg_text +test.t10 analyze status Engine-independent statistics collected +test.t10 analyze status OK +select histogram +from mysql.column_stats where table_name='t10' and db_name=database(); +histogram +{ + "target_histogram_size": 10, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "Berlin", + "size": 0.333333333, + "ndv": 1 + }, + { + "start": "Paris", + "size": 0.333333333, + "ndv": 1 + }, + { + "start": "Rome", + "end": "Rome", + "size": 0.333333333, + "ndv": 1 + } + ] +} +drop table t10; +# +# MDEV-26590: Stack smashing/buffer overflow in Histogram_json_hb::parse upon UPDATE on table with long VARCHAR +# +CREATE TABLE t1 (b INT, a VARCHAR(3176)); +INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); +SET histogram_type= JSON_HB; +ANALYZE TABLE t1 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +SELECT * FROM t1; +b a +1 foo +2 bar +drop table t1; +# +# MDEV-26589: Assertion failure upon DECODE_HISTOGRAM with NULLs in first column +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (NULL,1), (NULL,2); +SET histogram_type = JSON_HB; +ANALYZE TABLE t1 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +SELECT DECODE_HISTOGRAM(hist_type, histogram) from mysql.column_stats; +DECODE_HISTOGRAM(hist_type, histogram) +NULL +{ + "target_histogram_size": 10, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "1", + "size": 0.5, + "ndv": 1 + }, + { + "start": "2", + "end": "2", + "size": 0.5, + "ndv": 1 + } + ] +} +drop table t1; +# +# MDEV-26711: Values in JSON histograms are not properly quoted +# +create table t1 (a varchar(32)); +insert into t1 values ('this is "quoted" text'); +set histogram_type= JSON_HB; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +select * from t1 where a = 'foo'; +a +drop table t1; +# +# MDEV-26724 Endless loop in json_escape_to_string upon ... empty string +# +CREATE TABLE t1 (f VARCHAR(8)); +INSERT INTO t1 VALUES ('a'),(''),('b'); +SET histogram_type=JSON_HB; +ANALYZE TABLE t PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t analyze Error Table 'test.t' doesn't exist +test.t analyze status Operation failed +select * from t1; +f +a + +b +drop table t1; +create table t1 (a char(1)) character set latin1; +insert into t1 values (0xD1); +select hex(a) from t1; +hex(a) +D1 +set histogram_type='json_hb'; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +select decode_histogram(hist_type, histogram) +from mysql.column_stats +where db_name=database() and table_name='t1'; +decode_histogram(hist_type, histogram) +{ + "target_histogram_size": 10, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "Ñ", + "end": "Ñ", + "size": 1, + "ndv": 1 + } + ] +} +select * from t1; +a +Ñ +drop table t1; +# +# Another testcase: use a character that cannot be represented in utf8: +# Also, now it's testcase for: +# MDEV-26764: JSON_HB Histograms: handle BINARY and unassigned characters +# +create table t1 ( a varchar(100) character set cp1251); +insert into t1 values ( _cp1251 x'88'),( _cp1251 x'88'), ( _cp1251 x'88'); +insert into t1 values ( _cp1251 x'98'),( _cp1251 x'98'); +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +select hist_type, histogram +from mysql.column_stats +where db_name=database() and table_name='t1'; +hist_type histogram +JSON_HB { + "target_histogram_size": 10, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "€", + "size": 0.6, + "ndv": 1 + }, + { + "start_hex": "98", + "end_hex": "98", + "size": 0.4, + "ndv": 1 + } + ] +} +analyze select * from t1 where a=_cp1251 x'88'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 5.00 60.00 60.00 Using where +drop table t1; +# +# ASAN use-after-poison my_strnxfrm_simple_internal / Histogram_json_hb::range_selectivity ... +# (Just the testcase) +# +CREATE TABLE t1 (f CHAR(8)); +INSERT INTO t1 VALUES ('foo'),('bar'); +SET histogram_type = JSON_HB; +ANALYZE TABLE t1 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +SELECT * FROM t1 WHERE f > 'qux'; +f +DROP TABLE t1; +# +# MDEV-26737: Outdated VARIABLE_COMMENT for HISTOGRAM_TYPE in I_S.SYSTEM_VARIABLES +# +select variable_comment from information_schema.system_variables where VARIABLE_NAME='HISTOGRAM_TYPE'; +variable_comment +Specifies type of the histograms created by ANALYZE. Possible values are: SINGLE_PREC_HB - single precision height-balanced, DOUBLE_PREC_HB - double precision height-balanced, JSON_HB - height-balanced, stored as JSON. +# +# MDEV-26709: JSON histogram may contain bucketS than histogram_size allows +# +create table t1 (a int); +insert into t1 values (1),(3),(5),(7); +insert into t1 select 2 from seq_1_to_25; +insert into t1 select 4 from seq_1_to_25; +insert into t1 select 6 from seq_1_to_25; +set histogram_size=4, histogram_type=JSON_HB; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +select histogram from mysql.column_stats where table_name = 't1'; +histogram +{ + "target_histogram_size": 4, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "1", + "size": 0.253164557, + "ndv": 2 + }, + { + "start": "2", + "size": 0.253164557, + "ndv": 3 + }, + { + "start": "4", + "size": 0.253164557, + "ndv": 3 + }, + { + "start": "6", + "end": "7", + "size": 0.240506329, + "ndv": 2 + } + ] +} +drop table t1; +# +# MDEV-26750: Estimation for filtered rows is far off with JSON_HB histogram +# +create table t1 (c char(8)); +insert into t1 values ('1x'); +insert into t1 values ('1x'); +insert into t1 values ('1xx'); +insert into t1 values ('0xx'); +insert into t1 select * from t1; +insert into t1 select * from t1; +set histogram_type= JSON_HB; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +analyze +select c from t1 where c > '1'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 16 16.00 75.00 75.00 Using where +drop table t1; +# +# MDEV-26849: JSON Histograms: point selectivity estimates are off for non-existent values +# +create table t0(a int); +insert into t0 (a) values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int); +insert into t1 select 100*A.a from t0 A, t0 B, t0 C; +select a, count(*) from t1 group by a order by a; +a count(*) +0 100 +100 100 +200 100 +300 100 +400 100 +500 100 +600 100 +700 100 +800 100 +900 100 +set histogram_type=json_hb, histogram_size=default; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +select * from mysql.column_stats where table_name='t1'; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +test t1 a 0 900 0.0000 4.0000 100.0000 10 JSON_HB { + "target_histogram_size": 254, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start": "0", + "size": 0.1, + "ndv": 1 + }, + { + "start": "100", + "size": 0.1, + "ndv": 1 + }, + { + "start": "200", + "size": 0.1, + "ndv": 1 + }, + { + "start": "300", + "size": 0.1, + "ndv": 1 + }, + { + "start": "400", + "size": 0.1, + "ndv": 1 + }, + { + "start": "500", + "size": 0.1, + "ndv": 1 + }, + { + "start": "600", + "size": 0.1, + "ndv": 1 + }, + { + "start": "700", + "size": 0.1, + "ndv": 1 + }, + { + "start": "800", + "size": 0.1, + "ndv": 1 + }, + { + "start": "900", + "end": "900", + "size": 0.1, + "ndv": 1 + } + ] +} +analyze select * from t1 where a=0; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1000.00 10.00 10.00 Using where +analyze select * from t1 where a=50; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1000.00 0.10 0.00 Using where +analyze select * from t1 where a=70; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1000.00 0.10 0.00 Using where +analyze select * from t1 where a=100; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1000.00 10.00 10.00 Using where +analyze select * from t1 where a=150; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1000.00 0.10 0.00 Using where +analyze select * from t1 where a=200; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1000.00 10.00 10.00 Using where +drop table t0,t1; +# +# MDEV-26892: JSON histograms become invalid with a specific (corrupt) value in t +# +create table t1 (a varchar(32)) DEFAULT CHARSET=cp1257; +set histogram_type= JSON_HB, histogram_size= 1; +insert into t1 values ('foo'),(unhex('9C')); +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +select * from t1; +a +foo +? +drop table t1; +# +# MDEV-26911: Unexpected ER_DUP_KEY, ASAN errors, double free detected in tcache with JSON_HB histogram +# +SET histogram_type= JSON_HB; +CREATE TABLE t1 (pk INT AUTO_INCREMENT, f VARCHAR(8), PRIMARY KEY (pk)); +INSERT INTO t1 (f) VALUES ('foo'); +ANALYZE TABLE t1 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +ALTER TABLE t1 MODIFY f TEXT, ORDER BY pk; +INSERT INTO t1 (f) VALUES ('bar'); +DROP TABLE t1; +# +# MDEV-26886: Estimation for filtered rows less precise with JSON histogram +# +create table t1 (a tinyint) as select if(seq%3,seq,0) as a from seq_1_to_100; +select count(*) from t1 where a <= 0; +count(*) +33 +set histogram_type = JSON_HB, histogram_size=default; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +analyze select * from t1 where a <= 0; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 100.00 33.00 33.00 Using where +analyze select * from t1 where a < 0; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 100.00 1.00 0.00 Using where +analyze select * from t1 where a > 0; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 100.00 67.00 67.00 Using where +analyze select * from t1 where a >= 0; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 100.00 100.00 100.00 Using where +drop table t1; +# +# More test coverage +# +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int); +insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C; +create table t2 (a int); +insert into t2 select 1 from t1; +insert into t2 select (a+1)*10 from t0; +insert into t2 values (0); +analyze table t2 persistent for all; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +analyze select * from t2 where a < 1; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1011 1011.00 0.10 0.10 Using where +analyze select * from t2 where a =100; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1011 1011.00 0.10 0.10 Using where +drop table t0,t1,t2; +# +# MDEV-27230: Estimation for filtered rows less precise ... +# +create table t1 (a char(1)); +insert into t1 select chr(seq%26+97) from seq_1_to_50; +insert into t1 select ':' from t1; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +analyze select COUNT(*) FROM t1 WHERE a <> 'a'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 100.00 99.00 99.00 Using where +analyze select COUNT(*) FROM t1 WHERE a < 'a'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 100.00 50.00 50.00 Using where +drop table t1; +# +# MDEV-27229: Estimation for filtered rows less precise ... #5 +# +create table t1 (id int, a varchar(8)); +insert into t1 select seq, 'bar' from seq_1_to_100; +insert into t1 select id, 'qux' from t1; +set histogram_type=JSON_HB; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +analyze select COUNT(*) FROM t1 WHERE a > 'foo'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 200 200.00 50.00 50.00 Using where +analyze select COUNT(*) FROM t1 WHERE a > 'aaa'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 200 200.00 100.00 100.00 Using where +analyze select COUNT(*) FROM t1 WHERE a >='aaa'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 200 200.00 100.00 100.00 Using where +analyze select COUNT(*) FROM t1 WHERE a > 'bar'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 200 200.00 50.00 50.00 Using where +analyze select COUNT(*) FROM t1 WHERE a >='bar'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 200 200.00 100.00 100.00 Using where +analyze select COUNT(*) FROM t1 WHERE a < 'aaa'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 200 200.00 0.50 0.00 Using where +analyze select COUNT(*) FROM t1 WHERE a <='aaa'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 200 200.00 0.50 0.00 Using where +analyze select COUNT(*) FROM t1 WHERE a < 'bar'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 200 200.00 0.50 0.00 Using where +analyze select COUNT(*) FROM t1 WHERE a <='bar'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 200 200.00 50.00 50.00 Using where +drop table t1; +# +# MDEV-27243: Estimation for filtered rows less precise ... #7 +# (Testcase only) +CREATE TABLE t1 (f TIME); +INSERT INTO t1 SELECT IF(seq%2,'00:00:00',SEC_TO_TIME(seq+7200)) FROM seq_1_to_1000; +SET histogram_type= JSON_HB; +ANALYZE TABLE t1 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +ANALYZE SELECT * FROM t1 WHERE f > '00:01:00'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1000.00 50.00 50.00 Using where +drop table t1; +# +# MDEV-26901: Estimation for filtered rows less precise ... #4 +# +create table t1 (f int); +insert into t1 values +(7),(5),(0),(5),(112),(9),(9),(7),(5),(9), +(1),(7),(0),(6),(6),(2),(1),(6),(169),(7); +select f from t1 where f in (77, 1, 144, 73, 14, 12); +f +1 +1 +set histogram_type= JSON_HB; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +analyze select f from t1 where f in (77, 1, 144, 73, 14, 12); +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 20 20.00 10.00 10.00 Using where +drop table t1; +# +# Test that histograms over BIT fields use hex +# +create table t1 (a BIT(64)); +insert into t1 values +(x'01'),(x'10'),(x'BE562B1A99001918'); +set histogram_type= JSON_HB; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +select histogram +from mysql.column_stats where table_name='t1' and db_name=database(); +histogram +{ + "target_histogram_size": 254, + "collected_at": "REPLACED", + "collected_by": "REPLACED", + "histogram_hb": [ + { + "start_hex": "0000000000000001", + "size": 0.333333333, + "ndv": 1 + }, + { + "start_hex": "0000000000000010", + "size": 0.333333333, + "ndv": 1 + }, + { + "start_hex": "BE562B1A99001918", + "end_hex": "BE562B1A99001918", + "size": 0.333333333, + "ndv": 1 + } + ] +} +drop table t1; +# +# MDEV-28882: Assertion `tmp >= 0' failed in best_access_path +# +CREATE TABLE t1 (a varchar(1)); +INSERT INTO t1 VALUES ('o'),('s'),('j'),('s'),('y'),('s'),('l'), +('q'),('x'),('m'),('t'),('d'),('v'),('j'),('p'),('t'),('b'),('q'); +set histogram_type=json_hb; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +# filtered must not be negative: +explain format=json select * from t1 where a > 'y'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 18, + "filtered": 5.555555344, + "attached_condition": "t1.a > 'y'" + } + } + ] + } +} +drop table t1; diff --git a/mysql-test/main/statistics_json.test b/mysql-test/main/statistics_json.test new file mode 100644 index 00000000000..5263a98fff7 --- /dev/null +++ b/mysql-test/main/statistics_json.test @@ -0,0 +1,483 @@ +--echo # +--echo # Test that we can store JSON arrays in histogram field mysql.column_stats when histogram_type=JSON +--echo # + +let $histogram_type_override='JSON_HB'; +--source statistics.test + +--source include/have_innodb.inc +--source include/have_stat_tables.inc +--source include/have_sequence.inc +--disable_warnings +drop table if exists t1; +--enable_warnings + +set @save_histogram_type=@@histogram_type; +set @save_histogram_size=@@histogram_size; + +call mtr.add_suppression("Failed to parse histogram for table .*"); +create table ten(a int primary key); +insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +set histogram_size=100; +set histogram_type='double_prec_hb'; +create table t1_bin (a varchar(255)); +insert into t1_bin select concat('a-', a) from ten; +analyze table t1_bin persistent for all; +select hex(histogram) from mysql.column_stats where table_name='t1_bin'; +explain extended select * from t1_bin where a between 'a-3a' and 'zzzzzzzzz'; +analyze select * from t1_bin where a between 'a-3a' and 'zzzzzzzzz'; + +set histogram_type=json_hb; +create table t1_json (a varchar(255)); +insert into t1_json select concat('a-', a) from ten; +analyze table t1_json persistent for all; +--source include/json_hb_histogram.inc +select * from mysql.column_stats where table_name='t1_json'; +explain extended select * from t1_json where a between 'a-3a' and 'zzzzzzzzz'; +analyze select * from t1_json where a between 'a-3a' and 'zzzzzzzzz'; +explain extended select * from t1_json where a < 'b-1a'; +analyze select * from t1_json where a > 'zzzzzzzzz'; + +drop table ten; + +# +# Test different valid JSON strings that are invalid histograms. +# +UPDATE mysql.column_stats +SET histogram='["not-what-you-expect"]' WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; + +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":"not-histogram"}' WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; + +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":["not-a-bucket"]}' +WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; + +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":[{"no-expected-members":1}]}' +WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; + +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":[{"start":{}}]}' +WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; + +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":[{"start":"aaa", "size":"not-an-integer"}]}' +WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; + +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":[{"start":"aaa", "size":0.25}]}' +WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; + +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":[{"start":"aaa", "size":0.25, "ndv":1}]}' +WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; + +UPDATE mysql.column_stats +SET histogram='{"histogram_hb":[]}' +WHERE table_name='t1_json'; +FLUSH TABLES; +explain select * from t1_json limit 1; + +--source include/have_sequence.inc +create table t2 ( + city varchar(100) +); +set histogram_size=50; +insert into t2 select 'Moscow' from seq_1_to_99; +insert into t2 select 'Helsinki' from seq_1_to_2; +set histogram_type=json_hb; +analyze table t2 persistent for all; +explain extended select * from t2 where city = 'Moscow'; +analyze select * from t2 where city = 'Moscow'; +explain extended select * from t2 where city = 'Helsinki'; +analyze select * from t2 where city = 'helsinki'; +explain extended select * from t2 where city < 'Lagos'; + +drop table t1_bin; +drop table t1_json; +drop table t2; + +DELETE FROM mysql.column_stats; + +--disable_service_connection + +create schema world; +use world; +--disable_query_log +--disable_result_log +--disable_warnings +--source include/world_schema_utf8.inc +--source include/world.inc +--enable_warnings +--enable_result_log +--enable_query_log + +set histogram_type='JSON_HB'; +set histogram_size=50; +--disable_result_log +ANALYZE TABLE Country, City, CountryLanguage persistent for all; +--enable_result_log + +--source include/histogram_replaces.inc +SELECT column_name, min_value, max_value, hist_size, hist_type, histogram FROM mysql.column_stats; +analyze select * from Country use index () where Code between 'BBC' and 'GGG'; +analyze select * from Country use index () where Code < 'BBC'; + +set histogram_type=@save_histogram_type; +set histogram_size=@save_histogram_size; + +DROP SCHEMA world; + +--enable_service_connection + +use test; + +create table t10 ( + a varchar(10) +); + +--echo # +--echo # Histograms are not collected for empty tables: +--echo # +analyze table t10 persistent for all; +select histogram +from mysql.column_stats where table_name='t10' and db_name=database(); + +--echo # +--echo # Try with n_buckets > n_rows +--echo # +insert into t10 values ('Berlin'),('Paris'),('Rome'); +set histogram_size=10, histogram_type='json_hb'; +analyze table t10 persistent for all; +--source include/histogram_replaces.inc +select histogram +from mysql.column_stats where table_name='t10' and db_name=database(); +drop table t10; + +--echo # +--echo # MDEV-26590: Stack smashing/buffer overflow in Histogram_json_hb::parse upon UPDATE on table with long VARCHAR +--echo # + +CREATE TABLE t1 (b INT, a VARCHAR(3176)); +INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); +SET histogram_type= JSON_HB; +ANALYZE TABLE t1 PERSISTENT FOR ALL; +SELECT * FROM t1; +drop table t1; + +--echo # +--echo # MDEV-26589: Assertion failure upon DECODE_HISTOGRAM with NULLs in first column +--echo # + +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (NULL,1), (NULL,2); +SET histogram_type = JSON_HB; +ANALYZE TABLE t1 PERSISTENT FOR ALL; +--source include/histogram_replaces.inc +SELECT DECODE_HISTOGRAM(hist_type, histogram) from mysql.column_stats; +drop table t1; + +--echo # +--echo # MDEV-26711: Values in JSON histograms are not properly quoted +--echo # + +create table t1 (a varchar(32)); +insert into t1 values ('this is "quoted" text'); +set histogram_type= JSON_HB; +analyze table t1 persistent for all; +select * from t1 where a = 'foo'; +drop table t1; + +--echo # +--echo # MDEV-26724 Endless loop in json_escape_to_string upon ... empty string +--echo # +CREATE TABLE t1 (f VARCHAR(8)); +INSERT INTO t1 VALUES ('a'),(''),('b'); +SET histogram_type=JSON_HB; +ANALYZE TABLE t PERSISTENT FOR ALL; +select * from t1; +drop table t1; + +create table t1 (a char(1)) character set latin1; +insert into t1 values (0xD1); +select hex(a) from t1; +set histogram_type='json_hb'; +analyze table t1 persistent for all; + +--source include/histogram_replaces.inc +select decode_histogram(hist_type, histogram) +from mysql.column_stats +where db_name=database() and table_name='t1'; + +select * from t1; +drop table t1; + +--echo # +--echo # Another testcase: use a character that cannot be represented in utf8: +--echo # Also, now it's testcase for: +--echo # MDEV-26764: JSON_HB Histograms: handle BINARY and unassigned characters +--echo # +create table t1 ( a varchar(100) character set cp1251); +insert into t1 values ( _cp1251 x'88'),( _cp1251 x'88'), ( _cp1251 x'88'); +insert into t1 values ( _cp1251 x'98'),( _cp1251 x'98'); +analyze table t1 persistent for all; + +--source include/histogram_replaces.inc +select hist_type, histogram +from mysql.column_stats +where db_name=database() and table_name='t1'; + +analyze select * from t1 where a=_cp1251 x'88'; + +drop table t1; + +--echo # +--echo # ASAN use-after-poison my_strnxfrm_simple_internal / Histogram_json_hb::range_selectivity ... +--echo # (Just the testcase) +--echo # + +CREATE TABLE t1 (f CHAR(8)); +INSERT INTO t1 VALUES ('foo'),('bar'); + +SET histogram_type = JSON_HB; +ANALYZE TABLE t1 PERSISTENT FOR ALL; + +SELECT * FROM t1 WHERE f > 'qux'; +DROP TABLE t1; + +--echo # +--echo # MDEV-26737: Outdated VARIABLE_COMMENT for HISTOGRAM_TYPE in I_S.SYSTEM_VARIABLES +--echo # +select variable_comment from information_schema.system_variables where VARIABLE_NAME='HISTOGRAM_TYPE'; + +--echo # +--echo # MDEV-26709: JSON histogram may contain bucketS than histogram_size allows +--echo # +create table t1 (a int); +insert into t1 values (1),(3),(5),(7); +insert into t1 select 2 from seq_1_to_25; +insert into t1 select 4 from seq_1_to_25; +insert into t1 select 6 from seq_1_to_25; + +set histogram_size=4, histogram_type=JSON_HB; +analyze table t1 persistent for all; + +--source include/json_hb_histogram.inc +select histogram from mysql.column_stats where table_name = 't1'; + +drop table t1; + +--echo # +--echo # MDEV-26750: Estimation for filtered rows is far off with JSON_HB histogram +--echo # +create table t1 (c char(8)); + +insert into t1 values ('1x'); +insert into t1 values ('1x'); +insert into t1 values ('1xx'); +insert into t1 values ('0xx'); +insert into t1 select * from t1; +insert into t1 select * from t1; + +set histogram_type= JSON_HB; +analyze table t1 persistent for all; +analyze +select c from t1 where c > '1'; + +drop table t1; + +--echo # +--echo # MDEV-26849: JSON Histograms: point selectivity estimates are off for non-existent values +--echo # + +create table t0(a int); +insert into t0 (a) values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int); +insert into t1 select 100*A.a from t0 A, t0 B, t0 C; +select a, count(*) from t1 group by a order by a; +set histogram_type=json_hb, histogram_size=default; +analyze table t1 persistent for all; +--source include/json_hb_histogram.inc +select * from mysql.column_stats where table_name='t1'; +analyze select * from t1 where a=0; +analyze select * from t1 where a=50; +analyze select * from t1 where a=70; +analyze select * from t1 where a=100; +analyze select * from t1 where a=150; +analyze select * from t1 where a=200; + +drop table t0,t1; + +--echo # +--echo # MDEV-26892: JSON histograms become invalid with a specific (corrupt) value in t +--echo # +create table t1 (a varchar(32)) DEFAULT CHARSET=cp1257; +set histogram_type= JSON_HB, histogram_size= 1; +insert into t1 values ('foo'),(unhex('9C')); +analyze table t1 persistent for all; + +select * from t1; +drop table t1; + +--echo # +--echo # MDEV-26911: Unexpected ER_DUP_KEY, ASAN errors, double free detected in tcache with JSON_HB histogram +--echo # + +SET histogram_type= JSON_HB; + +CREATE TABLE t1 (pk INT AUTO_INCREMENT, f VARCHAR(8), PRIMARY KEY (pk)); +INSERT INTO t1 (f) VALUES ('foo'); +ANALYZE TABLE t1 PERSISTENT FOR ALL; +ALTER TABLE t1 MODIFY f TEXT, ORDER BY pk; +INSERT INTO t1 (f) VALUES ('bar'); +DROP TABLE t1; + +--echo # +--echo # MDEV-26886: Estimation for filtered rows less precise with JSON histogram +--echo # +create table t1 (a tinyint) as select if(seq%3,seq,0) as a from seq_1_to_100; +select count(*) from t1 where a <= 0; + +set histogram_type = JSON_HB, histogram_size=default; +analyze table t1 persistent for all; +analyze select * from t1 where a <= 0; +analyze select * from t1 where a < 0; +analyze select * from t1 where a > 0; +analyze select * from t1 where a >= 0; +drop table t1; + + +--echo # +--echo # More test coverage +--echo # +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1(a int); +insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C; + +create table t2 (a int); +insert into t2 select 1 from t1; +insert into t2 select (a+1)*10 from t0; +insert into t2 values (0); + +analyze table t2 persistent for all; +analyze select * from t2 where a < 1; +analyze select * from t2 where a =100; + +drop table t0,t1,t2; + +--echo # +--echo # MDEV-27230: Estimation for filtered rows less precise ... +--echo # +create table t1 (a char(1)); +insert into t1 select chr(seq%26+97) from seq_1_to_50; +insert into t1 select ':' from t1; +analyze table t1 persistent for all; +analyze select COUNT(*) FROM t1 WHERE a <> 'a'; +analyze select COUNT(*) FROM t1 WHERE a < 'a'; +drop table t1; + +--echo # +--echo # MDEV-27229: Estimation for filtered rows less precise ... #5 +--echo # +create table t1 (id int, a varchar(8)); +insert into t1 select seq, 'bar' from seq_1_to_100; +insert into t1 select id, 'qux' from t1; + +set histogram_type=JSON_HB; +analyze table t1 persistent for all; +analyze select COUNT(*) FROM t1 WHERE a > 'foo'; + +analyze select COUNT(*) FROM t1 WHERE a > 'aaa'; +analyze select COUNT(*) FROM t1 WHERE a >='aaa'; + +analyze select COUNT(*) FROM t1 WHERE a > 'bar'; +analyze select COUNT(*) FROM t1 WHERE a >='bar'; + +# Can enable these after get_avg_frequency issue is resolved: +analyze select COUNT(*) FROM t1 WHERE a < 'aaa'; +analyze select COUNT(*) FROM t1 WHERE a <='aaa'; +analyze select COUNT(*) FROM t1 WHERE a < 'bar'; + +analyze select COUNT(*) FROM t1 WHERE a <='bar'; + +drop table t1; + +--echo # +--echo # MDEV-27243: Estimation for filtered rows less precise ... #7 +--echo # (Testcase only) + +CREATE TABLE t1 (f TIME); +INSERT INTO t1 SELECT IF(seq%2,'00:00:00',SEC_TO_TIME(seq+7200)) FROM seq_1_to_1000; + +SET histogram_type= JSON_HB; +ANALYZE TABLE t1 PERSISTENT FOR ALL; +ANALYZE SELECT * FROM t1 WHERE f > '00:01:00'; +drop table t1; + +--echo # +--echo # MDEV-26901: Estimation for filtered rows less precise ... #4 +--echo # +create table t1 (f int); +insert into t1 values + (7),(5),(0),(5),(112),(9),(9),(7),(5),(9), + (1),(7),(0),(6),(6),(2),(1),(6),(169),(7); + +select f from t1 where f in (77, 1, 144, 73, 14, 12); + +set histogram_type= JSON_HB; +analyze table t1 persistent for all; + +analyze select f from t1 where f in (77, 1, 144, 73, 14, 12); +drop table t1; + + +--echo # +--echo # Test that histograms over BIT fields use hex +--echo # +create table t1 (a BIT(64)); +insert into t1 values + (x'01'),(x'10'),(x'BE562B1A99001918'); +set histogram_type= JSON_HB; +analyze table t1 persistent for all; +--source include/json_hb_histogram.inc +select histogram +from mysql.column_stats where table_name='t1' and db_name=database(); + +drop table t1; + +--echo # +--echo # MDEV-28882: Assertion `tmp >= 0' failed in best_access_path +--echo # + +CREATE TABLE t1 (a varchar(1)); + +INSERT INTO t1 VALUES ('o'),('s'),('j'),('s'),('y'),('s'),('l'), + ('q'),('x'),('m'),('t'),('d'),('v'),('j'),('p'),('t'),('b'),('q'); + +set histogram_type=json_hb; +analyze table t1 persistent for all; +--echo # filtered must not be negative: +explain format=json select * from t1 where a > 'y'; + +drop table t1; + diff --git a/mysql-test/main/statistics_upgrade.result b/mysql-test/main/statistics_upgrade.result new file mode 100644 index 00000000000..87e2b23570d --- /dev/null +++ b/mysql-test/main/statistics_upgrade.result @@ -0,0 +1,91 @@ +call mtr.add_suppression("Incorrect definition of table mysql.column_stats:.*"); +set histogram_type=single_prec_hb; +create table t1 (a int); +insert into t1 select seq from seq_1_to_100; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +set histogram_type=double_prec_hb, histogram_size=20; +create table t2 (a int); +insert into t2 select seq from seq_1_to_100; +analyze table t2 persistent for all; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +CREATE TABLE IF NOT EXISTS t3 ( +db_name varchar(64) NOT NULL, +table_name varchar(64) NOT NULL, +column_name varchar(64) NOT NULL, +min_value varbinary(255) DEFAULT NULL, +max_value varbinary(255) DEFAULT NULL, +nulls_ratio decimal(12,4) DEFAULT NULL, +avg_length decimal(12,4) DEFAULT NULL, +avg_frequency decimal(12,4) DEFAULT NULL, +hist_size tinyint unsigned, +hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB'), +histogram varbinary(255), +PRIMARY KEY (db_name,table_name,column_name) +) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns'; +insert into t3 select * from mysql.column_stats; +create table t4 like t3; +insert into t4 select * from t3; +drop table mysql.column_stats; +alter table t3 rename mysql.column_stats; +# Run mysql_upgrade +mysql.innodb_index_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.innodb_table_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.transaction_registry +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.innodb_index_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.innodb_table_stats +Error : Unknown storage engine 'InnoDB' +error : Corrupt +mysql.transaction_registry +Error : Unknown storage engine 'InnoDB' +error : Corrupt +# +# Table definition after upgrade: +# +show create table mysql.column_stats; +Table Create Table +column_stats CREATE TABLE `column_stats` ( + `db_name` varchar(64) NOT NULL, + `table_name` varchar(64) NOT NULL, + `column_name` varchar(64) NOT NULL, + `min_value` varbinary(255) DEFAULT NULL, + `max_value` varbinary(255) DEFAULT NULL, + `nulls_ratio` decimal(12,4) DEFAULT NULL, + `avg_length` decimal(12,4) DEFAULT NULL, + `avg_frequency` decimal(12,4) DEFAULT NULL, + `hist_size` tinyint(3) unsigned DEFAULT NULL, + `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') DEFAULT NULL, + `histogram` longblob DEFAULT NULL, + PRIMARY KEY (`db_name`,`table_name`,`column_name`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns' +select +A.db_name, +A.table_name, +A.hist_type = B.hist_type as hist_type_equal, +A.histogram = B.histogram as histogram_equal +from +t4 A +left join +mysql.column_stats B on A.db_name=B.db_name and +A.table_name=B.table_name and +A.column_name=B.column_name; +db_name table_name hist_type_equal histogram_equal +test t1 1 1 +test t2 1 1 +drop table t1,t2,t4; +# +# MDEV-28866 mariadb-upgrade to 10.8 mysql.column_stats hist_type + histogram errors +# +FOUND 2 /Incorrect definition of table mysql.column_stats:/ in mysqld.1.err diff --git a/mysql-test/main/statistics_upgrade.test b/mysql-test/main/statistics_upgrade.test new file mode 100644 index 00000000000..9f47ab1a83b --- /dev/null +++ b/mysql-test/main/statistics_upgrade.test @@ -0,0 +1,77 @@ +-- source include/mysql_upgrade_preparation.inc +--source include/have_sequence.inc + +call mtr.add_suppression("Incorrect definition of table mysql.column_stats:.*"); + +set histogram_type=single_prec_hb; +create table t1 (a int); +insert into t1 select seq from seq_1_to_100; +analyze table t1 persistent for all; + +set histogram_type=double_prec_hb, histogram_size=20; +create table t2 (a int); +insert into t2 select seq from seq_1_to_100; +analyze table t2 persistent for all; + +# Create a table with old definition +CREATE TABLE IF NOT EXISTS t3 ( + db_name varchar(64) NOT NULL, + table_name varchar(64) NOT NULL, + column_name varchar(64) NOT NULL, + min_value varbinary(255) DEFAULT NULL, + max_value varbinary(255) DEFAULT NULL, + nulls_ratio decimal(12,4) DEFAULT NULL, + avg_length decimal(12,4) DEFAULT NULL, + avg_frequency decimal(12,4) DEFAULT NULL, + hist_size tinyint unsigned, + hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB'), + histogram varbinary(255), + PRIMARY KEY (db_name,table_name,column_name) +) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns'; + +# Copy the data there +insert into t3 select * from mysql.column_stats; + +create table t4 like t3; +insert into t4 select * from t3; + +# Put the old table in place of mysql.column_stats + +drop table mysql.column_stats; +alter table t3 rename mysql.column_stats; +--echo # Run mysql_upgrade + +--exec $MYSQL_UPGRADE --upgrade-system-tables --force --silent 2>&1 + +let $MYSQLD_DATADIR= `select @@datadir`; +--file_exists $MYSQLD_DATADIR/mysql_upgrade_info +--remove_file $MYSQLD_DATADIR/mysql_upgrade_info + +--echo # +--echo # Table definition after upgrade: +--echo # +show create table mysql.column_stats; + +select + A.db_name, + A.table_name, + A.hist_type = B.hist_type as hist_type_equal, + A.histogram = B.histogram as histogram_equal +from + t4 A + left join + mysql.column_stats B on A.db_name=B.db_name and + A.table_name=B.table_name and + A.column_name=B.column_name; + +drop table t1,t2,t4; + +--echo # +--echo # MDEV-28866 mariadb-upgrade to 10.8 mysql.column_stats hist_type + histogram errors +--echo # +# There should only be two count here corresponding the test creation of mysql.column_stats, and +# none generated by the $MYSQL_UPGRADE run. +--let $error_log= $MYSQLTEST_VARDIR/log/mysqld.1.err +--let SEARCH_FILE= $error_log +--let SEARCH_PATTERN= Incorrect definition of table mysql.column_stats: +--source include/search_pattern_in_file.inc diff --git a/mysql-test/main/statistics_upgrade_not_done.result b/mysql-test/main/statistics_upgrade_not_done.result new file mode 100644 index 00000000000..902bf25c242 --- /dev/null +++ b/mysql-test/main/statistics_upgrade_not_done.result @@ -0,0 +1,44 @@ +# Create the old-version of the table +call mtr.add_suppression(".*Incorrect definition of table mysql.column_stats:.*"); +alter table mysql.column_stats rename test.t1; +CREATE TABLE mysql.column_stats ( +`db_name` varchar(64) COLLATE utf8mb3_bin NOT NULL, +`table_name` varchar(64) COLLATE utf8mb3_bin NOT NULL, +`column_name` varchar(64) COLLATE utf8mb3_bin NOT NULL, +`min_value` varbinary(255) DEFAULT NULL, +`max_value` varbinary(255) DEFAULT NULL, +`nulls_ratio` decimal(12,4) DEFAULT NULL, +`avg_length` decimal(12,4) DEFAULT NULL, +`avg_frequency` decimal(12,4) DEFAULT NULL, +`hist_size` tinyint(3) unsigned DEFAULT NULL, +`hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') COLLATE utf8mb3_bin DEFAULT NULL, +`histogram` varbinary(255) DEFAULT NULL, +PRIMARY KEY (`db_name`,`table_name`,`column_name`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO mysql.column_stats VALUES +('test','t0','a','0','9',0.0000,4.0000,1.0000,5,'DOUBLE_PREC_HB', x'5555AAAA00'); +flush tables; +analyze select * from t0 where a<3; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10.00 100.00 30.00 Using where +# restart +select hex(histogram) from mysql.column_stats where table_name='t0' and db_name='test'; +hex(histogram) +5555AAAA00 +analyze select * from t0 where a<3; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10.00 100.00 30.00 Using where +create table t2 (a int); +# This currently just pretends that the histogram was collected. +analyze table t2 persistent for all; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status Table is already up to date +select * from mysql.column_stats where table_name='t2' and db_name='test'; +db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram +analyze select * from t0 where a<3; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10.00 33.33 30.00 Using where +drop table t0, t1, t2; diff --git a/mysql-test/main/statistics_upgrade_not_done.test b/mysql-test/main/statistics_upgrade_not_done.test new file mode 100644 index 00000000000..a74a5f35d83 --- /dev/null +++ b/mysql-test/main/statistics_upgrade_not_done.test @@ -0,0 +1,57 @@ +--source include/not_embedded.inc +--source include/mysql_upgrade_preparation.inc +--source include/have_innodb.inc + +# +# This is like the upgrade test in statistics_upgrade.test, except that we also +# check what happens if one doesn't do the upgrade and attempts to use the new +# server with the old mysql.column_stats table +# +--echo # Create the old-version of the table + +call mtr.add_suppression(".*Incorrect definition of table mysql.column_stats:.*"); + +alter table mysql.column_stats rename test.t1; + +CREATE TABLE mysql.column_stats ( + `db_name` varchar(64) COLLATE utf8mb3_bin NOT NULL, + `table_name` varchar(64) COLLATE utf8mb3_bin NOT NULL, + `column_name` varchar(64) COLLATE utf8mb3_bin NOT NULL, + `min_value` varbinary(255) DEFAULT NULL, + `max_value` varbinary(255) DEFAULT NULL, + `nulls_ratio` decimal(12,4) DEFAULT NULL, + `avg_length` decimal(12,4) DEFAULT NULL, + `avg_frequency` decimal(12,4) DEFAULT NULL, + `hist_size` tinyint(3) unsigned DEFAULT NULL, + `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') COLLATE utf8mb3_bin DEFAULT NULL, + `histogram` varbinary(255) DEFAULT NULL, + PRIMARY KEY (`db_name`,`table_name`,`column_name`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'; + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO mysql.column_stats VALUES +('test','t0','a','0','9',0.0000,4.0000,1.0000,5,'DOUBLE_PREC_HB', x'5555AAAA00'); + +flush tables; +analyze select * from t0 where a<3; + +# Restart the server + +--source include/restart_mysqld.inc + +select hex(histogram) from mysql.column_stats where table_name='t0' and db_name='test'; +analyze select * from t0 where a<3; + +create table t2 (a int); +-- echo # This currently just pretends that the histogram was collected. +analyze table t2 persistent for all; +select * from mysql.column_stats where table_name='t2' and db_name='test'; + +--exec $MYSQL_UPGRADE --upgrade-system-tables --force --silent 2>&1 +let $MYSQLD_DATADIR= `select @@datadir`; +--file_exists $MYSQLD_DATADIR/mysql_upgrade_info +--remove_file $MYSQLD_DATADIR/mysql_upgrade_info + +analyze select * from t0 where a<3; +drop table t0, t1, t2; diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index e749bafd211..d00f7ccd690 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -2923,17 +2923,21 @@ ANALYZE "r_total_time_ms": "REPLACED", "duplicate_removal": { "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 - }, + "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 + } + } + ], "subqueries": [ { "expression_cache": { @@ -2943,35 +2947,43 @@ ANALYZE "select_id": 2, "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": 50, - "attached_condition": "<nop>(<in_optimizer>(t1.b,(subquery#3) >= 4))" - }, + "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": 50, + "attached_condition": "<nop>(<in_optimizer>(t1.b,(subquery#3) >= 4))" + } + } + ], "subqueries": [ { "query_block": { "select_id": 3, "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 - } + "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 + } + } + ] } } ] diff --git a/mysql-test/main/subselect_cache.result b/mysql-test/main/subselect_cache.result index 9722acbd0e6..e859ebbd2e8 100644 --- a/mysql-test/main/subselect_cache.result +++ b/mysql-test/main/subselect_cache.result @@ -48,17 +48,21 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "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 - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "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 + } + } + ], "subqueries": [ { "expression_cache": { @@ -68,18 +72,22 @@ ANALYZE "select_id": 2, "r_loops": 4, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 4, - "rows": 4, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 18.75, - "attached_condition": "t1.b = t2.c" - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 4, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 18.75, + "attached_condition": "t1.b = t2.c" + } + } + ] } } } @@ -94,17 +102,21 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t1", - "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 - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "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 + } + } + ], "subqueries": [ { "expression_cache": { @@ -122,18 +134,22 @@ ANALYZE "select_id": 3, "r_loops": 4, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 4, - "rows": 4, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 18.75, - "attached_condition": "t1.b = t2.c" - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 4, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 18.75, + "attached_condition": "t1.b = t2.c" + } + } + ] } }, { @@ -158,18 +174,22 @@ ANALYZE "select_id": 2, "r_loops": 4, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t2", - "access_type": "ALL", - "r_loops": 4, - "rows": 4, - "r_rows": 4, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 18.75, - "attached_condition": "t1.b = t2.c" - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "r_loops": 4, + "rows": 4, + "r_rows": 4, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 18.75, + "attached_condition": "t1.b = t2.c" + } + } + ] } } } @@ -182,25 +202,33 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ], "subqueries": [ { "expression_cache": { "state": "uninitialized", "query_block": { "select_id": 2, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 4, - "filtered": 100, - "attached_condition": "t1.b = t2.c" - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 4, + "filtered": 100, + "attached_condition": "t1.b = t2.c" + } + } + ] } } } @@ -213,12 +241,16 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ], "subqueries": [ { "expression_cache": { @@ -231,13 +263,17 @@ EXPLAIN { "query_block": { "select_id": 3, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 4, - "filtered": 100, - "attached_condition": "t1.b = t2.c" - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 4, + "filtered": 100, + "attached_condition": "t1.b = t2.c" + } + } + ] } }, { @@ -259,13 +295,17 @@ EXPLAIN "state": "uninitialized", "query_block": { "select_id": 2, - "table": { - "table_name": "t2", - "access_type": "ALL", - "rows": 4, - "filtered": 100, - "attached_condition": "t1.b = t2.c" - } + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 4, + "filtered": 100, + "attached_condition": "t1.b = t2.c" + } + } + ] } } } diff --git a/mysql-test/main/subselect_mat.result b/mysql-test/main/subselect_mat.result index bbe81cec319..271b3c18a30 100644 --- a/mysql-test/main/subselect_mat.result +++ b/mysql-test/main/subselect_mat.result @@ -61,7 +61,7 @@ explain extended select * from t1 where a1 in (select b1 from t2 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (/* select#2 */ select `test`.`t2`.`b1` from `test`.`t2` where `test`.`t2`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery2>`.`b1`)))) select * from t1 where a1 in (select b1 from t2 where b1 > '0'); @@ -72,7 +72,7 @@ explain extended select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (/* select#2 */ select `test`.`t2`.`b1` from `test`.`t2` where `test`.`t2`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery2>`.`b1`)))) select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1); @@ -83,7 +83,7 @@ explain extended select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (/* select#2 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery2>`.`b1` and `test`.`t1`.`a2` = `<subquery2>`.`b2`)))) select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2); @@ -94,7 +94,7 @@ explain extended select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where; Using temporary +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (/* select#2 */ select `test`.`t2`.`b1`,min(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`b1` > '0' group by `test`.`t2`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery2>`.`b1` and `test`.`t1`.`a2` = `<subquery2>`.`min(b2)`)))) select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1); @@ -321,7 +321,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 4 MATERIALIZED t2i index it2i2 it2i3 18 NULL 5 100.00 Using where; Using index -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (/* select#2 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery2>`.`b1` and `test`.`t1`.`a2` = `<subquery2>`.`b2`)))) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (/* select#3 */ select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (/* select#4 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where `test`.`t3`.`c1` = `<subquery4>`.`b1` and `test`.`t3`.`c2` = `<subquery4>`.`b2`)))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery3>`.`c1` and `test`.`t1`.`a2` = `<subquery3>`.`c2`)))) select * from t1 @@ -451,8 +451,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 5 MATERIALIZED t2i index it2i2 it2i3 18 NULL 5 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where -3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1` and <cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1` and <cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (/* select#4 */ select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (/* select#5 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where `test`.`t3`.`c1` = `<subquery5>`.`b1` and `test`.`t3`.`c2` = `<subquery5>`.`b2`)))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery4>`.`c1` and `test`.`t1`.`a2` = `<subquery4>`.`c2`)))) @@ -474,8 +474,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) 4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 5 MATERIALIZED t2i index it2i2 it2i3 18 NULL 5 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where -3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`c1` = `test`.`t1`.`a1` and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1` and <cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1` and <cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (/* select#4 */ select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (/* select#5 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where `test`.`t3`.`c1` = `<subquery5>`.`b1` and `test`.`t3`.`c2` = `<subquery5>`.`b2`)))) ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where `test`.`t3`.`c1` = `<subquery4>`.`c1` and `test`.`t3`.`c2` = `<subquery4>`.`c2`)))) @@ -496,8 +496,8 @@ select * from t3 where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where -3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`>(<in_optimizer>(`test`.`t3`.`c1`,<exists>(/* select#2 */ select `test`.`t1`.`a1` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t3`.`c1`) = `test`.`t1`.`a1` union /* select#3 */ select `test`.`t2`.`b1` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t3`.`c1`) = `test`.`t2`.`b1`))) @@ -711,7 +711,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 3 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where 3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join) -4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 99.22 Using where +4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><concat(`test`.`t1`.`a1`,'x')>(<in_optimizer>(concat(`test`.`t1`.`a1`,'x'),<exists>(/* select#2 */ select left(`test`.`t1_16`.`a1`,8) from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`>(<in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),<exists>(/* select#3 */ select `test`.`t2_16`.`b1`,`test`.`t2_16`.`b2` from `test`.`t2_16` join `test`.`t2` where `test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6) and <expr_cache><`test`.`t2`.`b1`>(<in_optimizer>(`test`.`t2`.`b1`,`test`.`t2`.`b1` in ( <materialize> (/* select#4 */ select `test`.`t3`.`c1` from `test`.`t3` where `test`.`t3`.`c2` > '0' ), <primary_index_lookup>(`test`.`t2`.`b1` in <temporary table> on distinct_key where `test`.`t2`.`b1` = `<subquery4>`.`c1`)))) and <cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1` and <cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`))) and <cache>(concat(`test`.`t1`.`a1`,'x')) = left(`test`.`t1_16`.`a1`,8)))) drop table t1_16, t2_16, t3_16; diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result index a06a4aef99b..88f8f78019e 100644 --- a/mysql-test/main/subselect_no_semijoin.result +++ b/mysql-test/main/subselect_no_semijoin.result @@ -7415,34 +7415,46 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 2, - "filtered": 100 - }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } + } + ], "subqueries": [ { "query_block": { "select_id": 2, "pseudo_bits_condition": "1 = t1.a or <in_optimizer>(1,<exists>(subquery#3))", - "table": { - "table_name": "t2", - "access_type": "system", - "rows": 1, - "filtered": 100 - }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "system", + "rows": 1, + "filtered": 100 + } + } + ], "subqueries": [ { "query_block": { "select_id": 3, - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 2, - "filtered": 100, - "attached_condition": "1 = t3.c" - } + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "1 = t3.c" + } + } + ] } } ] diff --git a/mysql-test/main/subselect_sj_mat.result b/mysql-test/main/subselect_sj_mat.result index fe232009f42..2cc35c1896c 100644 --- a/mysql-test/main/subselect_sj_mat.result +++ b/mysql-test/main/subselect_sj_mat.result @@ -59,9 +59,9 @@ set @@optimizer_switch='materialization=on,in_to_exists=off,firstmatch=off'; explain extended select * from t1 where a1 in (select b1 from t2 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`b1` > '0' select * from t1 where a1 in (select b1 from t2 where b1 > '0'); @@ -71,9 +71,9 @@ a1 a2 explain extended select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`b1` > '0' select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1); @@ -83,9 +83,9 @@ a1 a2 explain extended select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 16 func,func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`b1` > '0' select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2); @@ -97,7 +97,7 @@ select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' gr id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 16 test.t1.a1,test.t1.a2 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where; Using temporary +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from <materialize> (/* select#2 */ select `test`.`t2`.`b1`,min(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`b1` > '0' group by `test`.`t2`.`b1`) join `test`.`t1` where `<subquery2>`.`b1` = `test`.`t1`.`a1` and `<subquery2>`.`min(b2)` = `test`.`t1`.`a2` select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1); @@ -331,12 +331,12 @@ where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and (a1, a2) in (select c1, c2 from t3 where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 98.44 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 16 func,func 1 100.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 16 func,func 1 100.00 -3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 98.44 Using where +3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 3 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 98.44 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and `test`.`t2`.`b1` > '0' and `test`.`t3`.`c2` > '0' select * from t1 @@ -375,12 +375,12 @@ b2 in (select c2 from t3 where c2 LIKE '%03')) and (a1, a2) in (select c1, c2 from t3 where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 16 func,func 1 100.00 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 16 func,func 1 100.00 -5 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 99.22 Using where +5 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where 4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: @@ -401,10 +401,10 @@ b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and (a1, a2) in (select c1, c2 from t3 t3c where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 16 func,func 1 100.00 -1 PRIMARY t2 ALL NULL NULL NULL NULL 5 99.22 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) -5 MATERIALIZED t3c ALL NULL NULL NULL NULL 4 99.22 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +5 MATERIALIZED t3c ALL NULL NULL NULL NULL 4 100.00 Using where 5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3c.c1,test.t3c.c2 1 100.00 Using index 4 MATERIALIZED t3b ALL NULL NULL NULL NULL 4 100.00 Using where 3 DEPENDENT SUBQUERY t3a ALL NULL NULL NULL NULL 4 100.00 Using where @@ -434,12 +434,12 @@ where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and (a1, a2) in (select c1, c2 from t3i where (c1, c2) in (select b1, b2 from t2i where b2 > '0'))); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL # # # 3 99.22 # +1 PRIMARY t1 ALL NULL # # # 3 100.00 # 1 PRIMARY <subquery5> eq_ref distinct_key # # # 1 100.00 # 1 PRIMARY <subquery2> eq_ref distinct_key # # # 1 100.00 # -5 MATERIALIZED t3 ALL NULL # # # 4 99.22 # +5 MATERIALIZED t3 ALL NULL # # # 4 100.00 # 5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 # -2 MATERIALIZED t2 ALL NULL # # # 5 99.22 # +2 MATERIALIZED t2 ALL NULL # # # 5 100.00 # 4 MATERIALIZED t3 ALL NULL # # # 4 100.00 # 3 MATERIALIZED t3 ALL NULL # # # 4 100.00 # 7 UNION t1i range it1i1,it1i2,it1i3 # # # 3 100.00 # @@ -472,12 +472,12 @@ where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where (a1, a2) in (select c1, c2 from t3 where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22 Using where +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 16 func,func 1 100.00 -4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 99.22 Using where +4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 4 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where -3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1` and <cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1` and <cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and `test`.`t3`.`c2` > '0' @@ -496,12 +496,12 @@ where (c1, c2) in (select b1, b2 from t2i where b2 > '0')) and a1 = c1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -1 PRIMARY t3 ALL NULL NULL NULL NULL 4 99.22 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) 1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 16 func,func 1 100.00 -4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 99.22 Using where +4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 4 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where -3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) join `test`.`t3` where `test`.`t3`.`c1` = `test`.`t1`.`a1` and `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1` and <cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1` and <cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and `test`.`t3`.`c2` > '0' @@ -522,8 +522,8 @@ select * from t3 where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where -3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`>(<in_optimizer>(`test`.`t3`.`c1`,<exists>(/* select#2 */ select `test`.`t1`.`a1` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t3`.`c1`) = `test`.`t1`.`a1` union /* select#3 */ select `test`.`t2`.`b1` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t3`.`c1`) = `test`.`t2`.`b1`))) @@ -738,7 +738,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; Using join buffer (flat, BNL join) 1 PRIMARY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) -1 PRIMARY t3 ALL NULL NULL NULL NULL 4 99.22 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2_16` join `test`.`t2` join `test`.`t1_16`) where `test`.`t2`.`b1` = `test`.`t3`.`c1` and `test`.`t2_16`.`b1` = `test`.`t1_16`.`a1` and `test`.`t2_16`.`b2` = `test`.`t1_16`.`a2` and `test`.`t2`.`b2` = substr(`test`.`t1_16`.`a2`,1,6) and `test`.`t3`.`c2` > '0' and concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8) diff --git a/mysql-test/main/symlink.result b/mysql-test/main/symlink.result index 67d067be1f9..f6a18edbd94 100644 --- a/mysql-test/main/symlink.result +++ b/mysql-test/main/symlink.result @@ -157,9 +157,13 @@ a drop table t1; End of 4.1 tests SET SESSION keep_files_on_create = TRUE; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release CREATE TABLE t1 (a INT) ENGINE MYISAM; Got one of the listed errors SET SESSION keep_files_on_create = FALSE; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release CREATE TABLE t1 (a INT) ENGINE MYISAM; DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/main/system_mysql_db.result b/mysql-test/main/system_mysql_db.result index a14f8c8108d..2c97d0c6809 100644 --- a/mysql-test/main/system_mysql_db.result +++ b/mysql-test/main/system_mysql_db.result @@ -234,8 +234,8 @@ column_stats CREATE TABLE `column_stats` ( `avg_length` decimal(12,4) DEFAULT NULL, `avg_frequency` decimal(12,4) DEFAULT NULL, `hist_size` tinyint(3) unsigned DEFAULT NULL, - `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') DEFAULT NULL, - `histogram` varbinary(255) DEFAULT NULL, + `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') DEFAULT NULL, + `histogram` longblob DEFAULT NULL, PRIMARY KEY (`db_name`,`table_name`,`column_name`) ) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns' show create table index_stats; diff --git a/mysql-test/main/system_mysql_db_fix40123.result b/mysql-test/main/system_mysql_db_fix40123.result index 686c53d212d..57845704fa1 100644 --- a/mysql-test/main/system_mysql_db_fix40123.result +++ b/mysql-test/main/system_mysql_db_fix40123.result @@ -272,8 +272,8 @@ column_stats CREATE TABLE `column_stats` ( `avg_length` decimal(12,4) DEFAULT NULL, `avg_frequency` decimal(12,4) DEFAULT NULL, `hist_size` tinyint(3) unsigned DEFAULT NULL, - `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') DEFAULT NULL, - `histogram` varbinary(255) DEFAULT NULL, + `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') DEFAULT NULL, + `histogram` longblob DEFAULT NULL, PRIMARY KEY (`db_name`,`table_name`,`column_name`) ) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns' show create table index_stats; diff --git a/mysql-test/main/system_mysql_db_fix50030.result b/mysql-test/main/system_mysql_db_fix50030.result index cb957a03240..377a3790754 100644 --- a/mysql-test/main/system_mysql_db_fix50030.result +++ b/mysql-test/main/system_mysql_db_fix50030.result @@ -276,8 +276,8 @@ column_stats CREATE TABLE `column_stats` ( `avg_length` decimal(12,4) DEFAULT NULL, `avg_frequency` decimal(12,4) DEFAULT NULL, `hist_size` tinyint(3) unsigned DEFAULT NULL, - `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') DEFAULT NULL, - `histogram` varbinary(255) DEFAULT NULL, + `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') DEFAULT NULL, + `histogram` longblob DEFAULT NULL, PRIMARY KEY (`db_name`,`table_name`,`column_name`) ) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns' show create table index_stats; diff --git a/mysql-test/main/system_mysql_db_fix50117.result b/mysql-test/main/system_mysql_db_fix50117.result index fba7c6365fe..2811e0fc660 100644 --- a/mysql-test/main/system_mysql_db_fix50117.result +++ b/mysql-test/main/system_mysql_db_fix50117.result @@ -256,8 +256,8 @@ column_stats CREATE TABLE `column_stats` ( `avg_length` decimal(12,4) DEFAULT NULL, `avg_frequency` decimal(12,4) DEFAULT NULL, `hist_size` tinyint(3) unsigned DEFAULT NULL, - `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') DEFAULT NULL, - `histogram` varbinary(255) DEFAULT NULL, + `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') DEFAULT NULL, + `histogram` longblob DEFAULT NULL, PRIMARY KEY (`db_name`,`table_name`,`column_name`) ) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns' show create table index_stats; diff --git a/mysql-test/main/timezone.result b/mysql-test/main/timezone.result index d84fe54ba8c..2ba1e3fb1d5 100644 --- a/mysql-test/main/timezone.result +++ b/mysql-test/main/timezone.result @@ -1,13 +1,18 @@ -DROP TABLE IF EXISTS t1; show variables like "system_time_zone"; Variable_name Value system_time_zone MET +# +# Test unix timestamp +# select @a:=FROM_UNIXTIME(1); @a:=FROM_UNIXTIME(1) 1970-01-01 01:00:01 select unix_timestamp(@a); unix_timestamp(@a) 1 +# +# Test of some values, including some with daylight saving time +# CREATE TABLE t1 (ts int); INSERT INTO t1 (ts) VALUES (Unix_timestamp('2002-10-27 01:00')); INSERT INTO t1 (ts) VALUES (Unix_timestamp('2002-10-27 02:00')); @@ -32,6 +37,9 @@ ts from_unixtime(ts) 1048989599 2003-03-30 03:59:59 1048989601 2003-03-30 04:00:01 DROP TABLE t1; +# +# Test of warning for spring time-gap values for system time zone +# CREATE TABLE t1 (ts timestamp); INSERT INTO t1 (ts) VALUES ('2003-03-30 01:59:59'), ('2003-03-30 02:59:59'), @@ -39,6 +47,9 @@ INSERT INTO t1 (ts) VALUES ('2003-03-30 01:59:59'), Warnings: Warning 1299 Invalid TIMESTAMP value in column 'ts' at row 2 DROP TABLE t1; +# +# Test for fix for Bug#2523 Check that boundary dates are processed correctly. +# select unix_timestamp('1970-01-01 01:00:00'), unix_timestamp('1970-01-01 01:00:01'), unix_timestamp('2038-01-19 04:14:07'), @@ -48,3 +59,19 @@ unix_timestamp('1970-01-01 01:00:00') unix_timestamp('1970-01-01 01:00:01') unix select unix_timestamp('1969-12-31 23:59:59'), unix_timestamp('1970-01-01 00:00:00'), unix_timestamp('1970-01-01 00:59:59'); unix_timestamp('1969-12-31 23:59:59') unix_timestamp('1970-01-01 00:00:00') unix_timestamp('1970-01-01 00:59:59') NULL NULL NULL +# +# End of 4.1 tests +# +# +# MDEV-27393 Timezone tables cannot have descending indexes +# +call mtr.add_suppression('mysql.time_zone_transition_type table is incorrectly defined or corrupted'); +alter table mysql.time_zone_transition_type drop primary key; +alter table mysql.time_zone_transition_type add primary key (time_zone_id,transition_type_id desc); +SET @@time_zone='Japan'; +ERROR HY000: Unknown or incorrect time zone: 'Japan' +alter table mysql.time_zone_transition_type drop primary key; +alter table mysql.time_zone_transition_type add primary key (time_zone_id,transition_type_id); +# +# End of 10.8 tests +# diff --git a/mysql-test/main/timezone.test b/mysql-test/main/timezone.test index ec1d50cf0ae..89c3ab5cfc1 100644 --- a/mysql-test/main/timezone.test +++ b/mysql-test/main/timezone.test @@ -7,24 +7,19 @@ disable_query_log; select FROM_UNIXTIME(24*3600); enable_query_log; -# Initialization ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - # The following is because of daylight saving time --replace_result MEST MET show variables like "system_time_zone"; -# -# Test unix timestamp -# +--echo # +--echo # Test unix timestamp +--echo # select @a:=FROM_UNIXTIME(1); select unix_timestamp(@a); -# -# Test of some values, including some with daylight saving time -# +--echo # +--echo # Test of some values, including some with daylight saving time +--echo # CREATE TABLE t1 (ts int); INSERT INTO t1 (ts) VALUES (Unix_timestamp('2002-10-27 01:00')); @@ -42,19 +37,18 @@ SELECT ts,from_unixtime(ts) FROM t1; DROP TABLE t1; -# -# Test of warning for spring time-gap values for system time zone -# +--echo # +--echo # Test of warning for spring time-gap values for system time zone +--echo # CREATE TABLE t1 (ts timestamp); INSERT INTO t1 (ts) VALUES ('2003-03-30 01:59:59'), ('2003-03-30 02:59:59'), ('2003-03-30 03:00:00'); DROP TABLE t1; -# -# Test for fix for Bug#2523 Check that boundary dates are processed -# correctly. -# +--echo # +--echo # Test for fix for Bug#2523 Check that boundary dates are processed correctly. +--echo # select unix_timestamp('1970-01-01 01:00:00'), unix_timestamp('1970-01-01 01:00:01'), unix_timestamp('2038-01-19 04:14:07'), @@ -62,4 +56,21 @@ select unix_timestamp('1970-01-01 01:00:00'), select unix_timestamp('1969-12-31 23:59:59'), unix_timestamp('1970-01-01 00:00:00'), unix_timestamp('1970-01-01 00:59:59'); -# End of 4.1 tests +--echo # +--echo # End of 4.1 tests +--echo # + +--echo # +--echo # MDEV-27393 Timezone tables cannot have descending indexes +--echo # +call mtr.add_suppression('mysql.time_zone_transition_type table is incorrectly defined or corrupted'); +alter table mysql.time_zone_transition_type drop primary key; +alter table mysql.time_zone_transition_type add primary key (time_zone_id,transition_type_id desc); +--error ER_UNKNOWN_TIME_ZONE +SET @@time_zone='Japan'; +alter table mysql.time_zone_transition_type drop primary key; +alter table mysql.time_zone_transition_type add primary key (time_zone_id,transition_type_id); + +--echo # +--echo # End of 10.8 tests +--echo # diff --git a/mysql-test/main/type_timestamp.result b/mysql-test/main/type_timestamp.result index f23c66e10a5..275d35ac476 100644 --- a/mysql-test/main/type_timestamp.result +++ b/mysql-test/main/type_timestamp.result @@ -575,7 +575,7 @@ a 2010-02-01 09:31:02 2010-02-01 09:31:03 2010-02-01 09:31:04 -CREATE TABLE t2 ( a TIMESTAMP, KEY ( a DESC ) ); +CREATE TABLE t2 ( a TIMESTAMP, KEY ( a ) ); INSERT INTO t2 VALUES( '2010-02-01 09:31:01' ); INSERT INTO t2 VALUES( '2010-02-01 09:31:02' ); INSERT INTO t2 VALUES( '2010-02-01 09:31:03' ); diff --git a/mysql-test/main/type_timestamp.test b/mysql-test/main/type_timestamp.test index a0f1f2c3d78..bff33c030b5 100644 --- a/mysql-test/main/type_timestamp.test +++ b/mysql-test/main/type_timestamp.test @@ -386,7 +386,7 @@ EXPLAIN SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0'; SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0'; -CREATE TABLE t2 ( a TIMESTAMP, KEY ( a DESC ) ); +CREATE TABLE t2 ( a TIMESTAMP, KEY ( a ) ); INSERT INTO t2 VALUES( '2010-02-01 09:31:01' ); INSERT INTO t2 VALUES( '2010-02-01 09:31:02' ); diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result index 48eea7a3add..109296ef2a1 100644 --- a/mysql-test/main/win.result +++ b/mysql-test/main/win.result @@ -1403,18 +1403,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t0.a" + "sorts": [ + { + "filesort": { + "sort_key": "t0.a" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t0", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] } } } @@ -1434,18 +1440,24 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "sum(t1.b)" + "sorts": [ + { + "filesort": { + "sort_key": "sum(t1.b)" + } } - }, + ], "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 + } + } + ] } } } @@ -1463,18 +1475,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "sum(t1.b)" + "sorts": [ + { + "filesort": { + "sort_key": "sum(t1.b)" + } } - }, + ], "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 + } + } + ] } } } @@ -1497,18 +1515,24 @@ EXPLAIN "filesort": { "sort_key": "t1.b", "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.b" + "sorts": [ + { + "filesort": { + "sort_key": "t1.b" + } } - }, + ], "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 + } + } + ] } } } @@ -1642,18 +1666,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.c, t1.a" + "sorts": [ + { + "filesort": { + "sort_key": "t1.c, t1.a" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] } } } @@ -1668,18 +1698,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.a" + "sorts": [ + { + "filesort": { + "sort_key": "t1.a" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] } } } @@ -1694,18 +1730,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.c, t1.a" + "sorts": [ + { + "filesort": { + "sort_key": "t1.c, t1.a" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] } } } @@ -1720,18 +1762,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.c, t1.a" + "sorts": [ + { + "filesort": { + "sort_key": "t1.c, t1.a" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] } } } @@ -1776,18 +1824,24 @@ EXPLAIN "filesort": { "sort_key": "row_number() over ( order by t1.s1,t1.s2) desc", "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.s1, t1.s2" + "sorts": [ + { + "filesort": { + "sort_key": "t1.s1, t1.s2" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 6, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + } + } + ] } } } @@ -1929,18 +1983,24 @@ EXPLAIN "select_id": 1, "duplicate_removal": { "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.part_id, t1.a" + "sorts": [ + { + "filesort": { + "sort_key": "t1.part_id, t1.a" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } + } + ] } } } @@ -2102,18 +2162,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.a, t1.pk" + "sorts": [ + { + "filesort": { + "sort_key": "t1.a, t1.pk" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 11, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 11, + "filtered": 100 + } + } + ] } } } @@ -2163,18 +2229,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.a, t1.b" + "sorts": [ + { + "filesort": { + "sort_key": "t1.a, t1.b" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 6, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + } + } + ] } } } @@ -3755,29 +3827,35 @@ ANALYZE "r_loops": 1, "r_total_time_ms": "REPLACED", "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "`row_number() OVER()`", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "r_used_priority_queue": false, - "r_output_rows": 3, - "r_buffer_size": "REPLACED", - "r_sort_mode": "sort_key,rowid" + "sorts": [ + { + "filesort": { + "sort_key": "`row_number() OVER()`", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 3, + "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,rowid" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } } } diff --git a/mysql-test/main/win_empty_over.result b/mysql-test/main/win_empty_over.result index a5ee74b943a..4fa53bb4eae 100644 --- a/mysql-test/main/win_empty_over.result +++ b/mysql-test/main/win_empty_over.result @@ -37,22 +37,28 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "pk" + "sorts": [ + { + "filesort": { + "sort_key": "pk" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "index", - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["pk"], - "rows": 11, - "filtered": 100, - "using_index": true - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["pk"], + "rows": 11, + "filtered": 100, + "using_index": true + } + } + ] } } } @@ -63,22 +69,28 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "`row_number() over ()`" + "sorts": [ + { + "filesort": { + "sort_key": "`row_number() over ()`" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "index", - "key": "PRIMARY", - "key_length": "4", - "used_key_parts": ["pk"], - "rows": 11, - "filtered": 100, - "using_index": true - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["pk"], + "rows": 11, + "filtered": 100, + "using_index": true + } + } + ] } } } diff --git a/mysql-test/main/winservice.inc b/mysql-test/main/winservice.inc new file mode 100644 index 00000000000..2d8f6ccae1e --- /dev/null +++ b/mysql-test/main/winservice.inc @@ -0,0 +1,75 @@ +source include/check_windows_admin.inc; + +# The test uses return code from sc.exe utility, which are as follows +let $ERROR_SERVICE_DOES_NOT_EXIST= 1060; +let $ERROR_SERVICE_CANNOT_ACCEPT_CTRL=1061;# intermediate, during start or stop +let $ERROR_SERVICE_NOT_ACTIVE=1062;# service stopped + +let $sc_exe= C:\Windows\System32\sc.exe; +let $ddir= $MYSQLTEST_VARDIR/tmp/$datadir_name; +let $service_name=$service_name_prefix$MASTER_MYPORT; + + +error 0,1; +rmdir $ddir; + +--disable_result_log +error 0,$ERROR_SERVICE_DOES_NOT_EXIST; +exec $sc_exe delete $service_name; +--enable_result_log + +source include/shutdown_mysqld.inc; +echo # run mysql_install_db with --service parameter; +--disable_result_log +exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --port=$MASTER_MYPORT --password=$password --service=$service_name -R; +--enable_result_log + +echo # Start service; +--disable_result_log +exec $sc_exe start $service_name; +--enable_result_log + +enable_reconnect; +source include/wait_until_connected_again.inc; +disable_reconnect; + +echo # Connect with root user password=$password; +connect (con1,localhost,root,$password,mysql); + +# Smoke test - check that we're actually using datadir +# we've created (i.e restart_parameters worked) +replace_result $ddir DATADIR; +select @@datadir; + +echo # Stop service and wait until it is down; + +# stop service +--disable_result_log +exec $sc_exe stop $service_name; +# Wait until stopped +let $sys_errno=0; +while($sys_errno != $ERROR_SERVICE_NOT_ACTIVE) +{ + --error 0,$ERROR_SERVICE_CANNOT_ACCEPT_CTRL,$ERROR_SERVICE_NOT_ACTIVE + exec $sc_exe stop $service_name; + if($sys_errno != $ERROR_SERVICE_NOT_ACTIVE) + { + --real_sleep 0.1 + } +} +--enable_result_log + +echo # Delete service; +let $sys_errno=0; +--disable_result_log +exec $sc_exe delete $service_name; +--enable_result_log + +# Cleanup +source include/wait_until_disconnected.inc; +rmdir $ddir; + +#restart original server +connection default; +source include/start_mysqld.inc; + diff --git a/mysql-test/main/winservice_basic.result b/mysql-test/main/winservice_basic.result new file mode 100644 index 00000000000..0a5e8693b6b --- /dev/null +++ b/mysql-test/main/winservice_basic.result @@ -0,0 +1,11 @@ +# run mysql_install_db with --service parameter +# Start service +# Connect with root user password=password +connect con1,localhost,root,$password,mysql; +select @@datadir; +@@datadir +DATADIR/ +# Stop service and wait until it is down +# Delete service +connection default; +# restart diff --git a/mysql-test/main/winservice_basic.test b/mysql-test/main/winservice_basic.test new file mode 100644 index 00000000000..33d072b4f70 --- /dev/null +++ b/mysql-test/main/winservice_basic.test @@ -0,0 +1,5 @@ +source include/windows.inc; +let $datadir_name=data; +let $service_name_prefix=mariadb; +let $password=password; +source winservice.inc; diff --git a/mysql-test/main/winservice_i18n.result b/mysql-test/main/winservice_i18n.result new file mode 100644 index 00000000000..8d5eba3df38 --- /dev/null +++ b/mysql-test/main/winservice_i18n.result @@ -0,0 +1,11 @@ +# run mysql_install_db with --service parameter +# Start service +# Connect with root user password=パスワード +connect con1,localhost,root,$password,mysql; +select @@datadir; +@@datadir +DATADIR/ +# Stop service and wait until it is down +# Delete service +connection default; +# restart diff --git a/mysql-test/main/winservice_i18n.test b/mysql-test/main/winservice_i18n.test new file mode 100644 index 00000000000..c63b38fd2b8 --- /dev/null +++ b/mysql-test/main/winservice_i18n.test @@ -0,0 +1,7 @@ +source include/windows.inc; +source include/check_utf8_cli.inc; + +let $datadir_name=датадир; +let $service_name_prefix=mariadb_sörvis; +let $password=パスワード; +source winservice.inc; |