diff options
81 files changed, 759 insertions, 734 deletions
diff --git a/mysql-test/main/analyze_format_json.result b/mysql-test/main/analyze_format_json.result index 34761fb51b4..02635a8f3dd 100644 --- a/mysql-test/main/analyze_format_json.result +++ b/mysql-test/main/analyze_format_json.result @@ -312,7 +312,7 @@ ANALYZE "ref": ["test.t1.a"], "loops": 10, "r_loops": 10, - "rows": 2, + "rows": 1, "r_rows": 0.2, "cost": "REPLACED", "r_table_time_ms": "REPLACED", diff --git a/mysql-test/main/analyze_stmt.result b/mysql-test/main/analyze_stmt.result index c5d35759c9c..89375146730 100644 --- a/mysql-test/main/analyze_stmt.result +++ b/mysql-test/main/analyze_stmt.result @@ -314,7 +314,7 @@ insert into t2 values (0),(1); analyze select * from t1 straight_join t2 force index(a) where t2.a=t1.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 10 10.00 100.00 100.00 Using where -1 SIMPLE t2 ref a a 5 test.t1.a 2 0.20 100.00 100.00 Using index +1 SIMPLE t2 ref a a 5 test.t1.a 1 0.20 100.00 100.00 Using index drop table t1,t2; # # MDEV-8063: Unconditional ANALYZE DELETE does not delete rows diff --git a/mysql-test/main/costs.result b/mysql-test/main/costs.result index 8349bcf886f..2924c4c6d38 100644 --- a/mysql-test/main/costs.result +++ b/mysql-test/main/costs.result @@ -22,15 +22,15 @@ Last_query_cost 0.000000 explain select count(*) from t1 where a > 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 12 Using where; Using index -Last_query_cost 0.002795 +Last_query_cost 0.002877 explain select count(*) from t1 where a > 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 12 Using where; Using index -Last_query_cost 0.002795 +Last_query_cost 0.002877 explain select count(*) from t1 where a > 2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 11 Using where; Using index -Last_query_cost 0.002665 +Last_query_cost 0.002747 # # Shorter indexes are prefered over longer indexs # @@ -41,20 +41,20 @@ Last_query_cost 0.007441 explain select count(*) from t1 where b between 5 and 10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range ba,bda ba 5 NULL 6 Using where; Using index -Last_query_cost 0.002015 +Last_query_cost 0.002097 explain select sum(b+c) from t1 where b between 5 and 6 and c between 5 and 6; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range ba,bda,cba,cb cba 10 NULL 2 Using where; Using index -Last_query_cost 0.001494 +Last_query_cost 0.001577 # Cost of 'd' should be slightly smaller as key 'ba' is longer than 'd' explain select count(*) from t1 where b > 6; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range ba,bda ba 5 NULL 5 Using where; Using index -Last_query_cost 0.001885 +Last_query_cost 0.001967 explain select count(*) from t1 where d > 6; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range d d 5 NULL 5 Using where; Using index -Last_query_cost 0.001885 +Last_query_cost 0.001967 # # Check covering index usage # @@ -68,15 +68,15 @@ Last_query_cost 0.007441 explain select count(*) from t1 where b=2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref ba,bda ba 5 const 2 Using index -Last_query_cost 0.001059 +Last_query_cost 0.001141 explain select count(*) from t1 where b=2 and c=2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref ba,bda,cba,cb cba 10 const,const 2 Using index -Last_query_cost 0.001059 +Last_query_cost 0.001141 explain select count(*) from t1 where b=3 and c between 3 and 4; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range ba,bda,cba,cb cba 10 NULL 2 Using where; Using index -Last_query_cost 0.001494 +Last_query_cost 0.001577 # # Prefer eq keys over ref keys # @@ -87,5 +87,5 @@ Last_query_cost 0.003126 explain select a,b,e from t1 where d=10 or d=11; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range d d 5 NULL 2 Using index condition -Last_query_cost 0.003126 +Last_query_cost 0.003291 drop table t1; diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result index cadaa5f819a..5989abb7324 100644 --- a/mysql-test/main/cte_nonrecursive.result +++ b/mysql-test/main/cte_nonrecursive.result @@ -85,14 +85,14 @@ with t as (select a, count(*) from t1 where b >= 'c' group by a) select * from t2,t where t2.c=t.a; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.c 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t2.c 1 2 DERIVED t1 ALL NULL NULL NULL NULL 8 Using where; Using temporary; Using filesort explain select * from t2, (select a, count(*) from t1 where b >= 'c' group by a) as t where t2.c=t.a; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.c 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t2.c 1 2 DERIVED t1 ALL NULL NULL NULL NULL 8 Using where; Using temporary; Using filesort # specivication of t contains having with t as (select a, count(*) from t1 where b >= 'c' @@ -173,7 +173,7 @@ with t as (select count(*) as c from t1 where b >= 'c' group by a) select * from t2 where c in (select c from t); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where -1 PRIMARY <derived2> ref key0 key0 8 test.t2.c 2 Using where; FirstMatch(t2) +1 PRIMARY <derived2> ref key0 key0 8 test.t2.c 1 Using where; FirstMatch(t2) 2 DERIVED t1 ALL NULL NULL NULL NULL 8 Using where; Using temporary; Using filesort explain select * from t2 @@ -595,7 +595,7 @@ explain select * from v2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.c 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t2.c 1 2 DERIVED t1 ALL NULL NULL NULL NULL 8 Using where; Using temporary; Using filesort # with clause in the specification of a view that whose definition # table alias for a with table diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result index 189689fa463..7114ff1e072 100644 --- a/mysql-test/main/cte_recursive.result +++ b/mysql-test/main/cte_recursive.result @@ -689,13 +689,13 @@ from ancestor_couple_ids c, coupled_ancestors h, coupled_ancestors w where c.h_id = h.id and c.w_id= w.id; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where -1 PRIMARY <derived3> ref key0 key0 5 c.h_id 2 100.00 -1 PRIMARY <derived3> ref key0 key0 5 c.w_id 2 100.00 +1 PRIMARY <derived3> ref key0 key0 5 c.h_id 1 100.00 +1 PRIMARY <derived3> ref key0 key0 5 c.w_id 1 100.00 3 DERIVED folks ALL NULL NULL NULL NULL 12 100.00 Using where 4 RECURSIVE UNION p ALL NULL NULL NULL NULL 12 100.00 Using where -4 RECURSIVE UNION <derived2> ref key0 key0 5 test.p.id 2 100.00 +4 RECURSIVE UNION <derived2> ref key0 key0 5 test.p.id 1 100.00 5 RECURSIVE UNION p ALL NULL NULL NULL NULL 12 100.00 Using where -5 RECURSIVE UNION <derived2> ref key0 key0 5 test.p.id 2 100.00 +5 RECURSIVE UNION <derived2> ref key0 key0 5 test.p.id 1 100.00 NULL UNION RESULT <union3,4,5> ALL NULL NULL NULL NULL NULL NULL 2 DERIVED <derived3> ALL NULL NULL NULL NULL 12 100.00 Using where Warnings: @@ -1238,9 +1238,9 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 12 2 DERIVED folks ALL NULL NULL NULL NULL 12 Using where 3 RECURSIVE UNION p ALL PRIMARY NULL NULL NULL 12 -3 RECURSIVE UNION <derived2> ref key0 key0 5 test.p.id 2 +3 RECURSIVE UNION <derived2> ref key0 key0 5 test.p.id 1 4 RECURSIVE UNION p ALL PRIMARY NULL NULL NULL 12 -4 RECURSIVE UNION <derived2> ref key0 key0 5 test.p.id 2 +4 RECURSIVE UNION <derived2> ref key0 key0 5 test.p.id 1 NULL UNION RESULT <union2,3,4> ALL NULL NULL NULL NULL NULL with recursive ancestors @@ -3210,7 +3210,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 16 100.00 2 DERIVED a ALL NULL NULL NULL NULL 16 100.00 Using where 3 RECURSIVE UNION b ALL NULL NULL NULL NULL 16 100.00 Using where -3 RECURSIVE UNION <derived2> ref key0 key0 35 test.b.departure 2 100.00 +3 RECURSIVE UNION <derived2> ref key0 key0 35 test.b.departure 1 100.00 4 DEPENDENT SUBQUERY <derived2> ALL NULL NULL NULL NULL 16 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: @@ -3313,9 +3313,9 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 15 Using filesort 2 DERIVED t2 ALL NULL NULL NULL NULL 15 Using where 3 RECURSIVE UNION t2 ALL NULL NULL NULL NULL 15 Using where -3 RECURSIVE UNION <derived2> ref key0 key0 5 test.t2.id 2 +3 RECURSIVE UNION <derived2> ref key0 key0 5 test.t2.id 1 4 RECURSIVE UNION t2 ALL NULL NULL NULL NULL 15 Using where -4 RECURSIVE UNION <derived2> ref key0 key0 5 test.t2.id 2 +4 RECURSIVE UNION <derived2> ref key0 key0 5 test.t2.id 1 NULL UNION RESULT <union2,3,4> ALL NULL NULL NULL NULL NULL DROP TABLE t1,t2; set tmp_memory_table_size=default; @@ -4168,7 +4168,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used 2 DERIVED s ALL NULL NULL NULL NULL 4 3 RECURSIVE UNION t1 ALL NULL NULL NULL NULL 4 Using where -3 RECURSIVE UNION <derived2> ref key0 key0 9 test.t1.c 2 +3 RECURSIVE UNION <derived2> ref key0 key0 9 test.t1.c 1 NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL 4 UNION <derived2> ALL NULL NULL NULL NULL 4 with recursive r_cte as @@ -4292,7 +4292,7 @@ ANALYZE "ref": ["test.t1.c"], "loops": 4, "r_loops": 4, - "rows": 2, + "rows": 1, "r_rows": 0.5, "cost": "REPLACED", "r_table_time_ms": "REPLACED", @@ -4545,7 +4545,7 @@ NULL UNION RESULT <union4,5> ALL NULL NULL NULL NULL NULL 3 DERIVED h ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 3 DERIVED w ALL NULL NULL NULL NULL 12 Using where; Using join buffer (incremental, BNL join) 2 RECURSIVE UNION h ALL NULL NULL NULL NULL 12 Using where -2 RECURSIVE UNION <derived4> ref key0 key0 5 test.h.id 2 +2 RECURSIVE UNION <derived4> ref key0 key0 5 test.h.id 1 2 RECURSIVE UNION w ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) NULL UNION RESULT <union3,2> ALL NULL NULL NULL NULL NULL prepare stmt from "with recursive @@ -4643,7 +4643,7 @@ id select_type table type possible_keys key key_len ref rows Extra 5 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 2 NULL UNION RESULT <union3,4,5> ALL NULL NULL NULL NULL NULL 2 DERIVED h ALL NULL NULL NULL NULL 12 Using where -2 DERIVED <derived3> ref key0 key0 5 test.h.id 2 +2 DERIVED <derived3> ref key0 key0 5 test.h.id 1 2 DERIVED w ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) prepare stmt from "with recursive ancestor_couples(h_id, h_name, h_dob, h_father, h_mother, diff --git a/mysql-test/main/custom_aggregates_i_s.result b/mysql-test/main/custom_aggregates_i_s.result index cb98aee389d..2a19e9f7cab 100644 --- a/mysql-test/main/custom_aggregates_i_s.result +++ b/mysql-test/main/custom_aggregates_i_s.result @@ -39,7 +39,7 @@ explain select * from t1, (select f1(sal) as a from t1 where id>= 1) q where q.a=t1.sal; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t1.sal 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t1.sal 1 2 DERIVED t1 ALL NULL NULL NULL NULL 3 Using where show status like "%custom_aggregate%"; Variable_name Value diff --git a/mysql-test/main/derived.result b/mysql-test/main/derived.result index 422b2b07230..0eb4f131571 100644 --- a/mysql-test/main/derived.result +++ b/mysql-test/main/derived.result @@ -1292,7 +1292,7 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f analyze select * from t1 , ((select distinct t2.a, t2.b from t2 order by c))q where t1.a=q.a; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 6.00 100.00 100.00 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 2 1.00 100.00 100.00 +1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 1 1.00 100.00 100.00 2 DERIVED t2 ALL NULL NULL NULL NULL 6 6.00 100.00 100.00 Using temporary; Using filesort # multiple selects in derived table # NO UNION ALL diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index 5eae44eb028..2e07179ba73 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -1008,7 +1008,7 @@ explain select * from v_double as v,t2_double as t where (v.a=t.a) and (v.avg_a>0.45) and (v.b>10); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t.a 1 Using where 2 DERIVED t1_double ALL NULL NULL NULL NULL 9 Using where; Using temporary; Using filesort explain format=json select * from v_double as v,t2_double as t where (v.a=t.a) and (v.avg_a>0.45) and (v.b>10); @@ -1039,7 +1039,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v.avg_a > 0.45 and v.b > 10", @@ -1085,7 +1085,7 @@ explain select * from v_decimal as v,t2_decimal as t where (v.a=t.a) and (v.avg_c>15) and (v.b>1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 3 test.t.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 3 test.t.a 1 Using where 2 DERIVED t1_decimal ALL NULL NULL NULL NULL 9 Using where; Using temporary; Using filesort explain format=json select * from v_decimal as v,t2_decimal as t where (v.a=t.a) and (v.avg_c>15) and (v.b>1); @@ -1116,7 +1116,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v.avg_c > 15 and v.b > 1", @@ -2308,7 +2308,7 @@ explain select * from v_decimal as v,t2_decimal as t where (v.a=v.b) and (v.b=t.b) and ((t.b>1) or (v.a=1)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 6 test.t.b,test.t.b 2 +1 PRIMARY <derived2> ref key0 key0 6 test.t.b,test.t.b 1 2 DERIVED t1_decimal ALL NULL NULL NULL NULL 9 Using where; Using temporary; Using filesort explain format=json select * from v_decimal as v,t2_decimal as t where (v.a=v.b) and (v.b=t.b) and ((t.b>1) or (v.a=1)); @@ -2339,7 +2339,7 @@ EXPLAIN "used_key_parts": ["a", "b"], "ref": ["test.t.b", "test.t.b"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -2716,7 +2716,7 @@ explain select * from v_double as v,t2_double as t where (v.b=v.c) and (v.c=t.c) and ((t.c>10) or (v.a=1)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 18 test.t.c,test.t.c 2 Using where +1 PRIMARY <derived2> ref key0 key0 18 test.t.c,test.t.c 1 Using where 2 DERIVED t1_double ALL NULL NULL NULL NULL 9 Using where; Using temporary; Using filesort explain format=json select * from v_double as v,t2_double as t where (v.b=v.c) and (v.c=t.c) and ((t.c>10) or (v.a=1)); @@ -2747,7 +2747,7 @@ EXPLAIN "used_key_parts": ["b", "c"], "ref": ["test.t.c", "test.t.c"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.c > 10 or v.a = 1", @@ -2799,7 +2799,7 @@ explain select * from v_double as v,t2_double as t where (((v.a>0.2) or (v.b<17)) or (t.c>17)) and (t.c=v.c) and (v.c>18); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 9 test.t.c 2 Using where +1 PRIMARY <derived2> ref key0 key0 9 test.t.c 1 Using where 2 DERIVED t1_double ALL NULL NULL NULL NULL 9 Using where; Using temporary; Using filesort explain format=json select * from v_double as v,t2_double as t where (((v.a>0.2) or (v.b<17)) or (t.c>17)) and (t.c=v.c) and (v.c>18); @@ -2830,7 +2830,7 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t.c"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v.a > 0.2 or v.b < 17 or t.c > 17", @@ -6276,7 +6276,7 @@ explain select * from v_char as v,t2_char as t where (v.a=t.a) and (v.b='Vika') and (v.max_c>2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t ALL NULL NULL NULL NULL 12 Using where -1 PRIMARY <derived2> ref key0 key0 2 test.t.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 2 test.t.a 1 Using where 2 DERIVED t1_char ALL NULL NULL NULL NULL 12 Using where; Using temporary; Using filesort explain format=json select * from v_char as v,t2_char as t where (v.a=t.a) and (v.b='Vika') and (v.max_c>2); @@ -6307,7 +6307,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t.a"], "loops": 12, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v.b = 'Vika' and v.max_c > 2", @@ -9016,7 +9016,7 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["func"], "loops": 1, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -9072,7 +9072,7 @@ SELECT d FROM v4 WHERE s > a id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) -3 DEPENDENT SUBQUERY <derived5> index_subquery key0 key0 5 func 2 Using where +3 DEPENDENT SUBQUERY <derived5> index_subquery key0 key0 5 func 1 Using where 5 DERIVED t4 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort explain format=json SELECT * FROM t1 WHERE a IN ( SELECT b FROM v2 WHERE b < a OR b IN ( @@ -9123,7 +9123,7 @@ EXPLAIN "used_key_parts": ["d"], "ref": ["func"], "loops": 1, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -9279,7 +9279,7 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t1.a"], "loops": 2, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "trigcond(v2.b is null) and trigcond(trigcond(t1.a is not null))", @@ -9417,7 +9417,7 @@ EXPLAIN "used_key_parts": ["pk2"], "ref": ["func"], "loops": 1, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -9488,7 +9488,7 @@ EXPLAIN "used_key_parts": ["pk2"], "ref": ["func"], "loops": 1, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -10728,7 +10728,7 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t1.a"], "loops": 7, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -10796,7 +10796,7 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t1.a"], "loops": 7, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -10867,7 +10867,7 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t1.a"], "loops": 7, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -10932,7 +10932,7 @@ EXPLAIN "used_key_parts": ["m"], "ref": ["test.t1.a"], "loops": 7, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -11194,7 +11194,7 @@ EXPLAIN "used_key_parts": ["id2"], "ref": ["test.t1.id2"], "loops": 4, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "vc.ct > 0", @@ -12244,7 +12244,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t1.a"], "loops": 2, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -12320,7 +12320,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t1.a"], "loops": 2, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -12511,7 +12511,7 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t2.a"], "loops": 5, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.a = t.c and t.a >= 3", @@ -13014,7 +13014,7 @@ EXPLAIN "table_name": "<derived2>", "access_type": "ALL", "loops": 1, - "rows": 16, + "rows": 8, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t.f is not null", @@ -13044,7 +13044,7 @@ EXPLAIN "used_key_parts": ["f"], "ref": ["test.t1.f"], "loops": 8, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -13126,7 +13126,7 @@ EXPLAIN "used_key_parts": ["f2"], "ref": ["test.t1.f2"], "loops": 2, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -13711,7 +13711,7 @@ a b c a b c explain select * from v1,t2 where (v1.a=t2.a) and (v1.a<5); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 INTERSECT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL INTERSECT RESULT <intersect2,3> ALL NULL NULL NULL NULL NULL @@ -13743,7 +13743,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -14052,7 +14052,7 @@ a b c a b c explain select * from v1,t2 where (v1.a=t2.a) and (v1.c>200); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 INTERSECT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL INTERSECT RESULT <intersect2,3> ALL NULL NULL NULL NULL NULL @@ -14084,7 +14084,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 200", @@ -14168,7 +14168,7 @@ a b c a b c explain select * from v1,t2 where (v1.a=t2.a) and (v1.a<5) and (v1.c>110); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 INTERSECT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL INTERSECT RESULT <intersect2,3> ALL NULL NULL NULL NULL NULL @@ -14200,7 +14200,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 110", @@ -14285,7 +14285,7 @@ a b c a b c explain select * from v1,t2 where (v1.a=t2.a) and ((v1.b>27) or (v1.b<19)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 INTERSECT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL INTERSECT RESULT <intersect2,3> ALL NULL NULL NULL NULL NULL @@ -14317,7 +14317,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b > 27 or v1.b < 19", @@ -14407,7 +14407,7 @@ explain select * from v1,t2 where (v1.a=t2.a) and ((v1.c>200) or (v1.c<105)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 INTERSECT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL INTERSECT RESULT <intersect2,3> ALL NULL NULL NULL NULL NULL @@ -14440,7 +14440,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 200 or v1.c < 105", @@ -14717,7 +14717,7 @@ where ((d1.a<4) and (d1.c<200))); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key1 key1 5 test.t2.b 2 Using where +1 PRIMARY <derived2> ref key1 key1 5 test.t2.b 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 INTERSECT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL INTERSECT RESULT <intersect2,3> ALL NULL NULL NULL NULL NULL @@ -14759,7 +14759,7 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t2.b"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.c = 909 and t2.b > 13 or d1.a < 4 and d1.c < 200", @@ -14853,7 +14853,7 @@ a b c a b c explain select * from v1,t2 where (v1.a=t2.a) and (v1.a<5); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 EXCEPT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL EXCEPT RESULT <except2,3> ALL NULL NULL NULL NULL NULL @@ -14885,7 +14885,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -15202,7 +15202,7 @@ a b c a b c explain select * from v1,t2 where (v1.a=t2.a) and (v1.c>500); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 EXCEPT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL EXCEPT RESULT <except2,3> ALL NULL NULL NULL NULL NULL @@ -15234,7 +15234,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 500", @@ -15318,7 +15318,7 @@ a b c a b c explain select * from v1,t2 where (v1.a=t2.a) and (v1.a<5) and (v1.c>500); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 EXCEPT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL EXCEPT RESULT <except2,3> ALL NULL NULL NULL NULL NULL @@ -15350,7 +15350,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 500", @@ -15437,7 +15437,7 @@ a b c a b c explain select * from v1,t2 where (v1.a=t2.a) and ((v1.b>27) or (v1.b<19)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 EXCEPT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL EXCEPT RESULT <except2,3> ALL NULL NULL NULL NULL NULL @@ -15469,7 +15469,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b > 27 or v1.b < 19", @@ -15559,7 +15559,7 @@ explain select * from v1,t2 where (v1.a=t2.a) and ((v1.c<400) or (v1.c>800)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 EXCEPT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL EXCEPT RESULT <except2,3> ALL NULL NULL NULL NULL NULL @@ -15592,7 +15592,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c < 400 or v1.c > 800", @@ -15863,7 +15863,7 @@ where ((d1.a>4) and (d1.c>500))); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key1 key1 5 test.t2.b 2 Using where +1 PRIMARY <derived2> ref key1 key1 5 test.t2.b 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 EXCEPT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL EXCEPT RESULT <except2,3> ALL NULL NULL NULL NULL NULL @@ -15905,7 +15905,7 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t2.b"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "t2.c = 988 and t2.b > 13 or d1.a > 4 and d1.c > 500", @@ -16641,7 +16641,7 @@ a b c a b c explain select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<150); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 INTERSECT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 4 EXCEPT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort @@ -16674,7 +16674,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c < 150", @@ -16791,7 +16791,7 @@ a b c a b c explain select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<130); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 EXCEPT <derived4> ALL NULL NULL NULL NULL 18 Using where 4 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort @@ -16826,7 +16826,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c < 130", @@ -17186,7 +17186,7 @@ a b c a b c explain select * from v2,t2 where (v2.a=t2.a) and (v2.a>4) and (v2.c<150); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED <derived3> ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 4 INTERSECT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort @@ -17219,7 +17219,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.c < 150", @@ -17338,7 +17338,7 @@ a b c a b c explain select * from v2,t2 where (v2.a=t2.a) and (v2.a>4) and (v2.c<150); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED <derived3> ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 4 EXCEPT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort @@ -17371,7 +17371,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v2.c < 150", @@ -17487,7 +17487,7 @@ a b c a b c explain select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.b>12) and (v1.c<450); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 INTERSECT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL INTERSECT RESULT <intersect2,3> ALL NULL NULL NULL NULL NULL @@ -17519,7 +17519,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b > 12 and v1.c < 450", @@ -17610,7 +17610,7 @@ a b c a b c explain select * from v1,t2 where (v1.a=t2.a) and (v1.a<2) and (v1.b<30) and (v1.c>450); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 EXCEPT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL EXCEPT RESULT <except2,3> ALL NULL NULL NULL NULL NULL @@ -17642,7 +17642,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.b < 30 and v1.c > 450", @@ -17735,7 +17735,7 @@ a b c a b c explain select * from v1,t2 where (v1.a=t2.a) and ((v1.a<2) or (v1.a<5)) and (v1.c>450); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.a 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort 3 EXCEPT t1 ALL NULL NULL NULL NULL 18 Using where; Using temporary; Using filesort NULL EXCEPT RESULT <except2,3> ALL NULL NULL NULL NULL NULL @@ -17767,7 +17767,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.a"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 450", @@ -18022,7 +18022,7 @@ a b max_c a b c explain select * from v1,t2 where (v1.b=t2.b) and (v1.a<5); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.b 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.b 1 Using where 2 DERIVED t3 range i1 i1 5 NULL 5 Using index condition explain format=json select * from v1,t2 where (v1.b=t2.b) and (v1.a<5); EXPLAIN @@ -18052,7 +18052,7 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t2.b"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 5", @@ -18107,7 +18107,7 @@ a b c a b c explain select * from v1,t2 where (v1.b=t2.b) and (v1.a<4); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.b 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.b 1 Using where 2 DERIVED t3 range i1 i1 5 NULL 2 Using index condition 3 UNION t3 range i1 i1 5 NULL 1 Using index condition NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL @@ -18139,7 +18139,7 @@ EXPLAIN "used_key_parts": ["b"], "ref": ["test.t2.b"], "loops": 9, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.a < 4", @@ -19224,7 +19224,7 @@ on t1.a=t.a where t1.b < 3; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 range idx_b idx_b 5 NULL 4 100.00 Using index condition; Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 2 50.00 +1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 1 100.00 2 LATERAL DERIVED t2 ref idx_a idx_a 5 test.t1.a 1 100.00 Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`t`.`s` AS `s`,`t`.`m` AS `m` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `s`,min(`test`.`t2`.`c`) AS `m` from `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` group by `test`.`t2`.`a`) `t` where `t`.`a` = `test`.`t1`.`a` and `test`.`t1`.`b` < 3 @@ -19265,9 +19265,9 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t1.a"], "loops": 4, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", - "filtered": 50, + "filtered": 100, "materialized": { "lateral": 1, "query_block": { @@ -19353,7 +19353,7 @@ on t1.a=t.a where t1.b <= 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL idx_b NULL NULL NULL 12 83.33 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 2 50.00 +1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 1 100.00 2 LATERAL DERIVED t2 ref idx_a idx_a 5 test.t1.a 1 100.00 Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`t`.`s` AS `s`,`t`.`m` AS `m` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `s`,min(`test`.`t2`.`b`) AS `m` from `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` group by `test`.`t2`.`a`) `t` where `t`.`a` = `test`.`t1`.`a` and `test`.`t1`.`b` <= 5 @@ -19390,9 +19390,9 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t1.a"], "loops": 10, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", - "filtered": 50, + "filtered": 100, "materialized": { "lateral": 1, "query_block": { @@ -19476,7 +19476,7 @@ from t1 left join on t1.a=t.a; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 12 100.00 -1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 2 50.00 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 1 100.00 Using where 2 LATERAL DERIVED t2 ref idx_a idx_a 5 test.t1.a 1 100.00 Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`t`.`max` AS `max`,`t`.`min` AS `min` from `test`.`t1` left join (/* select#2 */ select `test`.`t2`.`a` AS `a`,max(`test`.`t2`.`b`) AS `max`,min(`test`.`t2`.`b`) AS `min` from `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` group by `test`.`t2`.`a`) `t` on(`t`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` is not null) where 1 @@ -19511,9 +19511,9 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t1.a"], "loops": 12, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", - "filtered": 50, + "filtered": 100, "attached_condition": "trigcond(trigcond(t1.a is not null))", "materialized": { "lateral": 1, @@ -19586,7 +19586,7 @@ on t3.a=t.a and t3.c=t.c where t3.b > 15; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 range idx_b idx_b 5 NULL 2 100.00 Using index condition; Using where -1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 2 100.00 +1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 1 100.00 2 LATERAL DERIVED t4 ref idx idx 133 test.t3.a,test.t3.c 1 100.00 Warnings: Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`c` AS `c`,`t`.`max` AS `max`,`t`.`min` AS `min` from `test`.`t3` join (/* select#2 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`c` AS `c`,max(`test`.`t4`.`b`) AS `max`,min(`test`.`t4`.`b`) AS `min` from `test`.`t4` where `test`.`t4`.`a` = `test`.`t3`.`a` and `test`.`t4`.`c` = `test`.`t3`.`c` group by `test`.`t4`.`a`,`test`.`t4`.`c`) `t` where `t`.`a` = `test`.`t3`.`a` and `t`.`c` = `test`.`t3`.`c` and `test`.`t3`.`b` > 15 @@ -19627,7 +19627,7 @@ EXPLAIN "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], "loops": 2, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -19683,7 +19683,7 @@ on t3.a=t.a and t3.c=t.c where t3.b <= 15; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL idx_b NULL NULL NULL 12 83.33 Using where -1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 2 50.00 +1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 1 100.00 2 LATERAL DERIVED t4 ref idx idx 133 test.t3.a,test.t3.c 1 100.00 Warnings: Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`c` AS `c`,`t`.`max` AS `max`,`t`.`min` AS `min` from `test`.`t3` join (/* select#2 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`c` AS `c`,max(`test`.`t4`.`b`) AS `max`,min(`test`.`t4`.`b`) AS `min` from `test`.`t4` where `test`.`t4`.`a` = `test`.`t3`.`a` and `test`.`t4`.`c` = `test`.`t3`.`c` group by `test`.`t4`.`a`,`test`.`t4`.`c`) `t` where `t`.`a` = `test`.`t3`.`a` and `t`.`c` = `test`.`t3`.`c` and `test`.`t3`.`b` <= 15 @@ -19720,9 +19720,9 @@ EXPLAIN "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], "loops": 10, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", - "filtered": 50, + "filtered": 100, "materialized": { "lateral": 1, "query_block": { @@ -19776,7 +19776,7 @@ on t3.a=t.a and t3.c=t.c where t3.b > 15; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 range idx_b idx_b 5 NULL 2 100.00 Using index condition; Using where -1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 2 100.00 +1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 1 100.00 2 LATERAL DERIVED t4 ref idx idx 133 test.t3.a,test.t3.c 1 100.00 Warnings: Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`c` AS `c`,`t`.`max` AS `max`,`t`.`min` AS `min` from `test`.`t3` join (/* select#2 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`c` AS `c`,max(`test`.`t4`.`b`) AS `max`,min(`test`.`t4`.`b`) AS `min` from `test`.`t4` where `test`.`t4`.`a` = `test`.`t3`.`a` and `test`.`t4`.`c` = `test`.`t3`.`c` group by `test`.`t4`.`c`,`test`.`t4`.`a`) `t` where `t`.`a` = `test`.`t3`.`a` and `t`.`c` = `test`.`t3`.`c` and `test`.`t3`.`b` > 15 @@ -19817,7 +19817,7 @@ EXPLAIN "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], "loops": 2, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -19873,7 +19873,7 @@ on t3.a=t.a and t3.c=t.c where t3.b <= 15; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL idx_b NULL NULL NULL 12 83.33 Using where -1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 2 50.00 +1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 1 100.00 2 LATERAL DERIVED t4 ref idx idx 133 test.t3.a,test.t3.c 1 100.00 Warnings: Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`c` AS `c`,`t`.`max` AS `max`,`t`.`min` AS `min` from `test`.`t3` join (/* select#2 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`c` AS `c`,max(`test`.`t4`.`b`) AS `max`,min(`test`.`t4`.`b`) AS `min` from `test`.`t4` where `test`.`t4`.`a` = `test`.`t3`.`a` and `test`.`t4`.`c` = `test`.`t3`.`c` group by `test`.`t4`.`c`,`test`.`t4`.`a`) `t` where `t`.`a` = `test`.`t3`.`a` and `t`.`c` = `test`.`t3`.`c` and `test`.`t3`.`b` <= 15 @@ -19910,9 +19910,9 @@ EXPLAIN "used_key_parts": ["a", "c"], "ref": ["test.t3.a", "test.t3.c"], "loops": 10, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", - "filtered": 50, + "filtered": 100, "materialized": { "lateral": 1, "query_block": { @@ -19979,7 +19979,7 @@ where t2.b between 80 and 85 and t2.c in ('y','z') 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 range idx idx 133 NULL 2 100.00 Using index condition; 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 2 100.00 +1 PRIMARY <derived2> ref key0 key0 128 test.t3.c 1 100.00 2 LATERAL DERIVED t4 ref idx_c idx_c 128 test.t3.c 2 100.00 Warnings: Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`t`.`c` AS `t_c`,`t`.`max` AS `max`,`t`.`min` AS `min` from `test`.`t2` join `test`.`t3` join (/* select#2 */ select `test`.`t4`.`c` AS `c`,max(`test`.`t4`.`b`) AS `max`,min(`test`.`t4`.`b`) AS `min` from `test`.`t4` where `test`.`t4`.`c` = `test`.`t3`.`c` group by `test`.`t4`.`c`) `t` where `test`.`t3`.`a` = `test`.`t2`.`a` and `t`.`c` = `test`.`t3`.`c` and `test`.`t2`.`b` between 80 and 85 and `test`.`t2`.`c` in ('y','z') @@ -20034,7 +20034,7 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t3.c"], "loops": 3, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -20271,7 +20271,7 @@ where t2.b between 80 and 85 and t2.c in ('y','z') 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 range idx idx 133 NULL 2 100.00 Using index condition; 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 2 100.00 +1 PRIMARY <derived2> ref key0 key0 128 test.t3.c 1 100.00 2 LATERAL DERIVED t4 ref idx_c idx_c 128 test.t3.c 2 100.00 Using temporary Warnings: Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`t`.`c` AS `c`,`t`.`b` AS `b`,`t`.`sum(b) over (partition by c)` AS `sum(b) over (partition by c)` from `test`.`t2` join `test`.`t3` join (/* select#2 */ select `test`.`t4`.`c` AS `c`,`test`.`t4`.`b` AS `b`,sum(`test`.`t4`.`b`) over ( partition by `test`.`t4`.`c`) AS `sum(b) over (partition by c)` from `test`.`t4` where `test`.`t4`.`c` = `test`.`t3`.`c`) `t` where `test`.`t3`.`a` = `test`.`t2`.`a` and `t`.`c` = `test`.`t3`.`c` and `test`.`t2`.`b` between 80 and 85 and `test`.`t2`.`c` in ('y','z') @@ -20326,7 +20326,7 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t3.c"], "loops": 3, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -20818,7 +20818,7 @@ a c explain extended SELECT * FROM t4 WHERE c IN ( SELECT c FROM v1 ) and a < 2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t4 range a a 5 NULL 1 100.00 Using index condition; Using where -1 PRIMARY <derived3> ref key0 key0 128 test.t4.c 2 50.00 FirstMatch(t4) +1 PRIMARY <derived3> ref key0 key0 128 test.t4.c 1 100.00 FirstMatch(t4) 3 LATERAL DERIVED t3 ref c c 128 test.t4.c 2 100.00 3 LATERAL DERIVED <subquery4> eq_ref distinct_key distinct_key 4 func 1 100.00 4 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 100.00 @@ -20858,9 +20858,9 @@ EXPLAIN "used_key_parts": ["c"], "ref": ["test.t4.c"], "loops": 1, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", - "filtered": 50, + "filtered": 100, "first_match": "t4", "materialized": { "lateral": 1, @@ -21003,7 +21003,7 @@ pk1 f pk2 cnt EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN v2 ON pk1 = pk2 WHERE f <> 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 2 100.00 Using where -1 PRIMARY <derived2> ref key0 key0 4 test.t1.pk1 2 100.00 +1 PRIMARY <derived2> ref key0 key0 4 test.t1.pk1 1 100.00 2 LATERAL DERIVED t2 eq_ref PRIMARY PRIMARY 4 test.t1.pk1 1 100.00 Using index Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`f` AS `f`,`v2`.`pk2` AS `pk2`,`v2`.`cnt` AS `cnt` from `test`.`t1` join `test`.`v2` where `v2`.`pk2` = `test`.`t1`.`pk1` and `test`.`t1`.`f` <> 5 @@ -21036,7 +21036,7 @@ EXPLAIN "used_key_parts": ["pk2"], "ref": ["test.t1.pk1"], "loops": 2, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -21229,7 +21229,7 @@ GROUP BY t1.b,t2.c) dt WHERE t3.d = dt.b; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 5 100.00 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t3.d 2 50.00 +1 PRIMARY <derived2> ref key0 key0 5 test.t3.d 1 100.00 2 LATERAL DERIVED t1 ref idx_b idx_b 5 test.t3.d 1 100.00 Using index; Using temporary; Using filesort 2 LATERAL DERIVED t2 ALL NULL NULL NULL NULL 5 100.00 Using join buffer (flat, BNL join) Warnings: @@ -21264,7 +21264,7 @@ left join on u.id=auditlastlogin.userid; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY u ALL NULL NULL NULL NULL 2 -1 PRIMARY <derived2> ref key0 key0 5 test.u.id 2 +1 PRIMARY <derived2> ref key0 key0 5 test.u.id 1 2 DERIVED au ALL NULL NULL NULL NULL 4 Using temporary; Using filesort select * from t1 as u left join @@ -21568,8 +21568,8 @@ where dt.a = t1.a and t1.a = t3.id and t1.a in (select a from t2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY t1 ref a a 5 test.t3.id 1 +1 PRIMARY <derived2> ref key0 key0 5 test.t3.id 1 1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 -1 PRIMARY <derived2> ref key0 key0 5 test.t3.id 2 3 MATERIALIZED t2 ALL NULL NULL NULL NULL 1007 2 DERIVED cp2 range NULL a 5 NULL 7 Using index for group-by explain format=json select * from t1, (select a from t1 cp2 group by a) dt, t3 @@ -21608,28 +21608,34 @@ EXPLAIN }, { "table": { - "table_name": "<subquery3>", - "access_type": "eq_ref", - "possible_keys": ["distinct_key"], - "key": "distinct_key", - "key_length": "4", + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", "used_key_parts": ["a"], - "ref": ["func"], + "ref": ["test.t3.id"], + "loops": 2, "rows": 1, + "cost": "COST_REPLACED", "filtered": 100, "materialized": { - "unique": 1, "query_block": { - "select_id": 3, + "select_id": 2, + "cost": "COST_REPLACED", "nested_loop": [ { "table": { - "table_name": "t2", - "access_type": "ALL", + "table_name": "cp2", + "access_type": "range", + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], "loops": 1, - "rows": 1007, + "rows": 7, "cost": "COST_REPLACED", - "filtered": 100 + "filtered": 100, + "using_index_for_group_by": true } } ] @@ -21639,34 +21645,28 @@ EXPLAIN }, { "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "5", + "table_name": "<subquery3>", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "4", "used_key_parts": ["a"], - "ref": ["test.t3.id"], - "loops": 2, - "rows": 2, - "cost": "COST_REPLACED", + "ref": ["func"], + "rows": 1, "filtered": 100, "materialized": { + "unique": 1, "query_block": { - "select_id": 2, - "cost": "COST_REPLACED", + "select_id": 3, "nested_loop": [ { "table": { - "table_name": "cp2", - "access_type": "range", - "key": "a", - "key_length": "5", - "used_key_parts": ["a"], + "table_name": "t2", + "access_type": "ALL", "loops": 1, - "rows": 7, + "rows": 1007, "cost": "COST_REPLACED", - "filtered": 100, - "using_index_for_group_by": true + "filtered": 100 } } ] @@ -21688,8 +21688,8 @@ where dt.a = t1.a and t1.a = t3.id and t1.a in (select a from t2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY t1 ref a a 5 test.t3.id 1 +1 PRIMARY <derived2> ref key0 key0 5 test.t3.id 1 1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 -1 PRIMARY <derived2> ref key0 key0 5 test.t3.id 2 3 MATERIALIZED t2 ALL NULL NULL NULL NULL 1007 2 LATERAL DERIVED cp2 ref a a 5 test.t1.a 1 Using where; Using index explain format=json select * from t1, (select a from t1 cp2 group by a) dt, t3 @@ -21728,37 +21728,6 @@ EXPLAIN }, { "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", - "loops": 1, - "rows": 1007, - "cost": "COST_REPLACED", - "filtered": 100 - } - } - ] - } - } - } - }, - { - "table": { "table_name": "<derived2>", "access_type": "ref", "possible_keys": ["key0"], @@ -21767,7 +21736,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t3.id"], "loops": 2, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -21798,6 +21767,37 @@ EXPLAIN } } } + }, + { + "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", + "loops": 1, + "rows": 1007, + "cost": "COST_REPLACED", + "filtered": 100 + } + } + ] + } + } + } } ] } @@ -21909,7 +21909,7 @@ WHERE t1.id BETWEEN 200 AND 100000; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 range t1_id t1_id 5 NULL 47 Using where; Using index 1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t3.t1_id 1 Using index -1 PRIMARY <derived2> ref key0 key0 5 test.t3.t1_id 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t3.t1_id 1 2 LATERAL DERIVED t2 ref t1_id t1_id 5 test.t1.id 1 Using index condition; Using where EXPLAIN FORMAT=JSON SELECT t1.id FROM t1 @@ -21966,9 +21966,9 @@ EXPLAIN "used_key_parts": ["t1_id"], "ref": ["test.t3.t1_id"], "loops": 47, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", - "filtered": 50, + "filtered": 100, "materialized": { "lateral": 1, "query_block": { @@ -22144,7 +22144,7 @@ from_agg_items.ledger_id = charges.from_ledger_id WHERE charges.to_ledger_id = 2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY charges ref PRIMARY,fk_charge_from_ledger,fk_charge_to_ledger fk_charge_to_ledger 8 const 8 -1 PRIMARY <derived2> ref key0 key0 17 test.charges.from_ledger_id,test.charges.id 2 +1 PRIMARY <derived2> ref key0 key0 17 test.charges.from_ledger_id,test.charges.id 1 2 LATERAL DERIVED transaction_items ref fk_items_transaction,fk_items_charge fk_items_charge 9 test.charges.id 2 2 LATERAL DERIVED transactions eq_ref PRIMARY,fk_transactions_ledger PRIMARY 8 test.transaction_items.transaction_id 1 Using where EXPLAIN FORMAT=JSON SELECT @@ -22200,7 +22200,7 @@ EXPLAIN "used_key_parts": ["ledger_id", "charge_id"], "ref": ["test.charges.from_ledger_id", "test.charges.id"], "loops": 8, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -22351,7 +22351,7 @@ from_agg_items.ledger_id = charges.from_ledger_id WHERE charges.to_ledger_id = 2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY charges ref fk_charge_to_ledger fk_charge_to_ledger 8 const 10 -1 PRIMARY <derived2> ref key0 key0 18 test.charges.from_ledger_id,test.charges.id 2 +1 PRIMARY <derived2> ref key0 key0 18 test.charges.from_ledger_id,test.charges.id 1 2 LATERAL DERIVED transaction_items ref fk_items_transaction,fk_items_charge fk_items_charge 9 test.charges.id 2 2 LATERAL DERIVED transactions eq_ref PRIMARY,fk_transactions_ledger PRIMARY 8 test.transaction_items.transaction_id 1 Using where EXPLAIN FORMAT=JSON SELECT @@ -22403,7 +22403,7 @@ EXPLAIN "used_key_parts": ["ledger_id", "charge_id"], "ref": ["test.charges.from_ledger_id", "test.charges.id"], "loops": 10, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { diff --git a/mysql-test/main/derived_opt.result b/mysql-test/main/derived_opt.result index 7d02990fb5d..53ee25963bb 100644 --- a/mysql-test/main/derived_opt.result +++ b/mysql-test/main/derived_opt.result @@ -92,13 +92,13 @@ pla_id test explain SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY m2 ALL NULL NULL NULL NULL 9 -1 PRIMARY <derived2> ref key0 key0 7 test.m2.matintnum 2 +1 PRIMARY <derived2> ref key0 key0 7 test.m2.matintnum 1 2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort 2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1 explain SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY m2 ALL NULL NULL NULL NULL 9 -1 PRIMARY <derived2> ref key0 key0 7 test.m2.matintnum 2 +1 PRIMARY <derived2> ref key0 key0 7 test.m2.matintnum 1 2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort 2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1 drop table t1,t2; @@ -534,7 +534,7 @@ ON t2.id=t.id WHERE t2.id < 3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition -1 PRIMARY <derived2> ref key0 key0 5 test.t2.id 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t2.id 1 2 DERIVED t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort set join_cache_level=default; set optimizer_switch= @save_optimizer_switch; diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result index c326a895a38..b119b7a6c0e 100644 --- a/mysql-test/main/derived_split_innodb.result +++ b/mysql-test/main/derived_split_innodb.result @@ -20,7 +20,7 @@ EXPLAIN SELECT t1.n1 FROM t1, (SELECT n1, n2 FROM t1 WHERE c1 = 'a' GROUP BY n1) WHERE t.n1 = t1.n1 AND t.n2 = t1.n2 AND c1 = 'a' GROUP BY n1; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ref c1,n1_c1_n2 c1 1 const 2 Using index condition; Using where; Using temporary; Using filesort -1 PRIMARY <derived2> ref key0 key0 8 test.t1.n1,test.t1.n2 2 +1 PRIMARY <derived2> ref key0 key0 8 test.t1.n1,test.t1.n2 1 2 LATERAL DERIVED t1 ref c1,n1_c1_n2 n1_c1_n2 4 test.t1.n1 1 Using where; Using index SELECT t1.n1 FROM t1, (SELECT n1, n2 FROM t1 WHERE c1 = 'a' GROUP BY n1) as t WHERE t.n1 = t1.n1 AND t.n2 = t1.n2 AND c1 = 'a' GROUP BY n1; @@ -49,7 +49,7 @@ t2 WHERE t2.id2=t.id2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.id2 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t2.id2 1 2 DERIVED t3 ALL NULL NULL NULL NULL 1 Using where; Using temporary; Using filesort 2 DERIVED t1 eq_ref PRIMARY,id2 PRIMARY 4 test.t3.i3 1 2 DERIVED t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join) @@ -99,7 +99,7 @@ ON t2.id=t.id WHERE t2.id < 3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 2 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.id 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t2.id 1 2 LATERAL DERIVED t1 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 set join_cache_level=default; DROP TABLE t1,t2; @@ -162,7 +162,7 @@ WHERE t1.a = dt.a; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index a,a_2 a_2 10 NULL 6 Using where; Using index -1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 2 +1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 1 3 DERIVED t1_inner index NULL a_2 10 NULL 6 Using where; Using index 3 DERIVED t2_inner ref c c 5 test.t1_inner.b 1 Using index set statement optimizer_switch='split_materialized=on' for EXPLAIN @@ -174,7 +174,7 @@ WHERE t1.a = dt.a; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index a,a_2 a_2 10 NULL 6 Using where; Using index -1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 2 +1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 1 3 DERIVED t1_inner index a,a_2 a_2 10 NULL 6 Using where; Using index 3 DERIVED t2_inner ref c c 5 test.t1_inner.b 1 Using index DROP TABLE t1, t2; @@ -209,7 +209,7 @@ where t1.id = dt.id and t1.itemid = dt.itemid and t2.id=t1.itemid; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 1 PRIMARY t1 ref idx idx 4 test.t2.id 1 -1 PRIMARY <derived2> ref key0 key0 9 test.t2.id,test.t1.id 2 +1 PRIMARY <derived2> ref key0 key0 9 test.t2.id,test.t1.id 1 2 DERIVED t3 ref idx1,idx2 idx1 4 const 5 Using where; Using index select t1.id, t1.itemid, dt.id, t2.id from t1, @@ -228,7 +228,7 @@ where t1.id = dt.id and t1.itemid = dt.itemid and t2.id=t1.itemid; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 1 PRIMARY t1 ref idx idx 4 test.t2.id 1 -1 PRIMARY <derived2> ref key0 key0 9 test.t2.id,test.t1.id 2 +1 PRIMARY <derived2> ref key0 key0 9 test.t2.id,test.t1.id 1 2 DERIVED t3 ref idx1 idx1 4 const 5 Using where; Using index select t1.id, t1.itemid, dt.id, t2.id from t1, @@ -273,7 +273,7 @@ on t3.a=t.a and t3.c=t.c where t3.b > 15; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 range idx_b idx_b 5 NULL 2 Using index condition; Using where -1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 2 +1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 1 2 LATERAL DERIVED t4 ref idx idx 133 test.t3.a,test.t3.c 1 # ... and if one adds WITH ROLLUP, then LATERAL DERIVED is no longer used: explain select t3.a,t3.c,t.max,t.min diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index d1816e93009..e7190e29f3f 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -214,7 +214,7 @@ explain extended select * from t1 join (select * from t2 group by f2) tt on f1=f2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 11 100.00 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 2 100.00 +1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 1 100.00 2 DERIVED t2 ALL NULL NULL NULL NULL 11 100.00 Using temporary; Using filesort Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`tt`.`f2` AS `f2`,`tt`.`f22` AS `f22` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t2` group by `test`.`t2`.`f2`) `tt` where `tt`.`f2` = `test`.`t1`.`f1` @@ -228,7 +228,7 @@ flush status; explain select * from t1 join (select * from t2 group by f2) tt on f1=f2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 11 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 1 2 DERIVED t2 ALL NULL NULL NULL NULL 11 Using temporary; Using filesort show status like 'Handler_read%'; Variable_name Value @@ -288,7 +288,7 @@ explain showing created indexes explain extended select * from t1 join v2 on f1=f2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 11 100.00 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 2 100.00 +1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 1 100.00 2 DERIVED t2 ALL NULL NULL NULL NULL 11 100.00 Using temporary; Using filesort Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`v2`.`f2` AS `f2`,`v2`.`f22` AS `f22` from `test`.`t1` join `test`.`v2` where `v2`.`f2` = `test`.`t1`.`f1` @@ -339,7 +339,7 @@ flush status; explain select * from t1 join v2 on f1=f2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 11 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 1 2 DERIVED t2 ALL NULL NULL NULL NULL 11 Using temporary; Using filesort show status like 'Handler_read%'; Variable_name Value @@ -372,7 +372,7 @@ Handler_read_rnd_next 36 explain extended select * from v1 join v4 on f1=f2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 11 100.00 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.f2 2 100.00 +1 PRIMARY <derived2> ref key0 key0 5 test.t2.f2 1 100.00 2 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort Warnings: Note 1003 /* select#1 */ select `v1`.`f1` AS `f1`,`v1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`v1` join `test`.`t2` where `v1`.`f1` = `test`.`t2`.`f2` and `test`.`t2`.`f2` in (2,3) @@ -404,7 +404,7 @@ EXPLAIN "used_key_parts": ["f1"], "ref": ["test.t2.f2"], "loops": 11, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -569,7 +569,7 @@ join on x.f1 = z.f1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY <derived3> ALL NULL NULL NULL NULL 11 100.00 Using where -1 PRIMARY <derived5> ref key0 key0 5 tt.f1 2 100.00 +1 PRIMARY <derived5> ref key0 key0 5 tt.f1 1 100.00 5 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort 3 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort Warnings: @@ -630,7 +630,7 @@ EXPLAIN "used_key_parts": ["f1"], "ref": ["tt.f1"], "loops": 11, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -717,7 +717,7 @@ join on x.f1 = z.f1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 11 100.00 Using where -1 PRIMARY <derived4> ref key0 key0 5 x.f1 2 100.00 +1 PRIMARY <derived4> ref key0 key0 5 x.f1 1 100.00 4 DERIVED <derived5> ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort 5 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort 2 DERIVED <derived3> ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort @@ -806,7 +806,7 @@ EXPLAIN "used_key_parts": ["f1"], "ref": ["x.f1"], "loops": 11, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -981,7 +981,7 @@ join of above two explain extended select * from v6 join v7 on f2=f1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 11 100.00 Using where -1 PRIMARY <derived5> ref key0 key0 5 test.t2.f2 2 100.00 +1 PRIMARY <derived5> ref key0 key0 5 test.t2.f2 1 100.00 5 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort Warnings: Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22`,`v1`.`f1` AS `f1`,`v1`.`f11` AS `f11` from `test`.`t2` join `test`.`v1` where `v1`.`f1` = `test`.`t2`.`f2` and `test`.`t2`.`f2` < 7 and `test`.`t2`.`f2` in (2,3) @@ -1013,7 +1013,7 @@ EXPLAIN "used_key_parts": ["f1"], "ref": ["test.t2.f2"], "loops": 11, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -1053,7 +1053,7 @@ test two keys explain select * from t1 join (select * from t2 group by f2) tt on t1.f1=tt.f2 join t1 xx on tt.f22=xx.f1; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 11 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 1 1 PRIMARY xx ALL NULL NULL NULL NULL 11 Using where; Using join buffer (flat, BNL join) 2 DERIVED t2 ALL NULL NULL NULL NULL 11 Using temporary; Using filesort select * from t1 join (select * from t2 group by f2) tt on t1.f1=tt.f2 join t1 xx on tt.f22=xx.f1; @@ -1078,7 +1078,7 @@ EXPLAIN SELECT * FROM v1 JOIN t2 ON v1.f1 = t2.f1; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 index f1 f1 5 NULL 3 Using where; Using index -1 PRIMARY <derived2> ref key0 key0 5 test.t2.f1 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t2.f1 1 2 DERIVED t1 ALL NULL NULL NULL NULL 4 SELECT * FROM v1 JOIN t2 ON v1.f1 = t2.f1; f1 f1 @@ -1275,11 +1275,11 @@ SELECT * FROM t3 WHERE t3.a IN (SELECT v1.a FROM v1, t2 WHERE t2.a = v1.b); 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 t2 ALL NULL NULL NULL NULL 3 100.00 Using where -2 DEPENDENT SUBQUERY <derived3> ref key0 key0 5 test.t2.a 2 100.00 Using where +2 DEPENDENT SUBQUERY <derived3> ref key1 key1 5 func 1 100.00 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) 3 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00 Using temporary; Using filesort Warnings: -Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` where <expr_cache><`test`.`t3`.`a`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(/* select#2 */ select `v1`.`a` from `test`.`v1` join `test`.`t2` where `v1`.`b` = `test`.`t2`.`a` and <cache>(`test`.`t3`.`a`) = `v1`.`a`))) +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` where <expr_cache><`test`.`t3`.`a`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(/* select#2 */ select `v1`.`a` from `test`.`v1` join `test`.`t2` where `test`.`t2`.`a` = `v1`.`b` and <cache>(`test`.`t3`.`a`) = `v1`.`a`))) SELECT * FROM t3 WHERE t3.a IN (SELECT v1.a FROM v1, t2 WHERE t2.a = v1.b); a @@ -1308,8 +1308,8 @@ FROM (SELECT DISTINCT t1.* FROM t1,t2 WHERE t2.f2 = t1.f2) t,t3,t4 WHERE t4.f2 = t3.f2 AND t4.f2 = t.f1 ORDER BY f; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t4 index f2 f2 9 NULL 2 Using where; Using index; Using temporary; Using filesort -1 PRIMARY t3 ref f2 f2 4 test.t4.f2 2 Using index -1 PRIMARY <derived2> ref key0 key0 4 test.t4.f2 2 +1 PRIMARY <derived2> ref key1 key1 4 test.t4.f2 1 +1 PRIMARY t3 ref f2 f2 4 test.t4.f2 1 Using index 2 DERIVED t2 system NULL NULL NULL NULL 1 Using temporary 2 DERIVED t1 ref f2 f2 4 const 2 Using where SELECT t.f1 AS f @@ -1335,7 +1335,7 @@ EXPLAIN SELECT * FROM t1 AS t JOIN v1 AS v WHERE t.a = v.b AND t.b = v.b; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t ALL NULL NULL NULL NULL 3 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t.a 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t.a 1 2 DERIVED t1 ALL NULL NULL NULL NULL 3 SELECT * FROM t1 AS t JOIN v1 AS v WHERE t.a = v.b AND t.b = v.b; a b a b @@ -1641,7 +1641,7 @@ EXPLAIN SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1) +1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 1 FirstMatch(t1) 3 DERIVED t2 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort SELECT * FROM v2; a b @@ -1940,14 +1940,14 @@ WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM t3 t); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY t index_subquery PRIMARY,c c 8 func,func 2 Using index; Using where +2 DEPENDENT SUBQUERY t index_subquery PRIMARY,c c 8 func,func 1 Using index; Using where EXPLAIN SELECT * FROM t1 , t2 WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM (SELECT * FROM t3) t); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY t3 index_subquery PRIMARY,c c 8 func,func 2 Using index; Using where +2 DEPENDENT SUBQUERY t3 index_subquery PRIMARY,c c 8 func,func 1 Using index; Using where SELECT * FROM t1 , t2 WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM (SELECT * FROM t3) t); b a @@ -2014,7 +2014,7 @@ EXPLAIN SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -1 PRIMARY <derived3> ref key0 key0 10 test.t1.b,test.t1.a 2 FirstMatch(t1) +1 PRIMARY <derived3> ref key0 key0 10 test.t1.b,test.t1.a 1 FirstMatch(t1) 3 DERIVED t2 ALL NULL NULL NULL NULL 2 SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); a b @@ -2068,7 +2068,7 @@ EXPLAIN SELECT v1.a FROM v1,v2 WHERE v2.b = v1.b ORDER BY 1; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 Using where; Using filesort -1 PRIMARY <derived3> ref key0 key0 4 v1.b 2 +1 PRIMARY <derived3> ref key0 key0 4 v1.b 1 3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort 2 DERIVED t1 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort DROP VIEW v1,v2; @@ -2659,7 +2659,7 @@ EXPLAIN EXTENDED SELECT v1.c1, v1.c2 FROM v1, t2 WHERE v1.c1=t2.c1 AND v1.c2=t2.c2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.c2 2 100.00 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.c2 1 100.00 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 5 100.00 Warnings: Note 1003 /* select#1 */ select `v1`.`c1` AS `c1`,`v1`.`c2` AS `c2` from `test`.`v1` join `test`.`t2` where `v1`.`c1` = `test`.`t2`.`c1` and `v1`.`c2` = `test`.`t2`.`c2` @@ -2672,7 +2672,7 @@ SELECT t2.c1, t2.c2 FROM (SELECT c1 g, MAX(c2) m FROM t1 GROUP BY c1) t, t2 WHERE t.g=t2.c1 AND t.m=t2.c2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t2.c2 2 100.00 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.c2 1 100.00 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort Warnings: Note 1003 /* select#1 */ select `test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2` from (/* select#2 */ select `test`.`t1`.`c1` AS `g`,max(`test`.`t1`.`c2`) AS `m` from `test`.`t1` group by `test`.`t1`.`c1`) `t` join `test`.`t2` where `t`.`g` = `test`.`t2`.`c1` and `t`.`m` = `test`.`t2`.`c2` @@ -3003,7 +3003,7 @@ GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY m2 ALL NULL NULL NULL NULL 9 -1 PRIMARY <derived2> ref key0 key0 7 test.m2.matintnum 2 +1 PRIMARY <derived2> ref key0 key0 7 test.m2.matintnum 1 2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort 2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1 prepare stmt1 from @@ -3137,7 +3137,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 LEFT JOIN v2 ON t1.id=v2.order_pk; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index -1 PRIMARY <derived2> ref key0 key0 5 test.t1.id 2 100.00 +1 PRIMARY <derived2> ref key0 key0 5 test.t1.id 1 100.00 2 LATERAL DERIVED t1 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 100.00 Using where; Using index Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`v2`.`order_pk` AS `order_pk` from `test`.`t1` left join `test`.`v2` on(`v2`.`order_pk` = `test`.`t1`.`id`) where 1 @@ -3151,7 +3151,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 LEFT JOIN v3 ON t1.id=v3.order_pk; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index -1 PRIMARY <derived2> ref key0 key0 5 test.t1.id 2 100.00 +1 PRIMARY <derived2> ref key0 key0 5 test.t1.id 1 100.00 2 LATERAL DERIVED t1 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 100.00 Using where; Using index Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`v3`.`order_pk` AS `order_pk` from `test`.`t1` left join `test`.`v3` on(`v3`.`order_pk` = `test`.`t1`.`id`) where 1 diff --git a/mysql-test/main/distinct.result b/mysql-test/main/distinct.result index d789066ac3b..02a76cf3e09 100644 --- a/mysql-test/main/distinct.result +++ b/mysql-test/main/distinct.result @@ -173,9 +173,9 @@ INSERT INTO t2 values (1),(2),(3); INSERT INTO t3 VALUES (1,'1'),(2,'2'),(1,'1'),(2,'2'); explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index a a 4 NULL 5 Using index; Using temporary -1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 Using where -1 SIMPLE t3 ref a a 5 test.t1.b 2 Using index +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using where; Using temporary +1 SIMPLE t3 ref a a 5 test.t1.b 1 Using index +1 SIMPLE t2 ref a a 4 test.t1.a 1 Using index; Distinct SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; a 1 diff --git a/mysql-test/main/explain_json.result b/mysql-test/main/explain_json.result index b53b5241077..806773d154c 100644 --- a/mysql-test/main/explain_json.result +++ b/mysql-test/main/explain_json.result @@ -696,7 +696,7 @@ EXPLAIN "used_key_parts": ["cnt"], "ref": ["test.tbl2.a"], "loops": 10, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "tbl1.cnt = tbl2.a", diff --git a/mysql-test/main/group_by.result b/mysql-test/main/group_by.result index 95ec41c048b..ef5e500c314 100644 --- a/mysql-test/main/group_by.result +++ b/mysql-test/main/group_by.result @@ -552,12 +552,12 @@ a b 3 1 explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL a NULL NULL NULL 4 Using temporary; Using filesort -1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort +1 SIMPLE t2 ref a a 4 test.t1.a 1 explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL a NULL NULL NULL 4 Using temporary -1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary +1 SIMPLE t2 ref a a 4 test.t1.a 1 drop table t1,t2; SET @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity,@@optimizer_switch=@save_optimizer_switch; create table t1 (a int, b int); @@ -1972,8 +1972,8 @@ SELECT a, AVG(t1.b), FROM t1 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL a 10 NULL 9 Using index -3 DEPENDENT SUBQUERY t12 ref a a 10 func,func 2 Using index condition -2 DEPENDENT SUBQUERY t11 ref a a 10 func,func 2 Using index condition +3 DEPENDENT SUBQUERY t12 ref a a 10 func,func 1 Using index condition +2 DEPENDENT SUBQUERY t11 ref a a 10 func,func 1 Using index condition SELECT a, AVG(t1.b), (SELECT t11.c FROM t1 t11 WHERE t11.a = t1.a AND t11.b = AVG(t1.b)) AS t11c, (SELECT t12.c FROM t1 t12 WHERE t12.a = t1.a AND t12.b = AVG(t1.b)) AS t12c diff --git a/mysql-test/main/group_min_max.result b/mysql-test/main/group_min_max.result index f97f6d41ab2..a227246e7ec 100644 --- a/mysql-test/main/group_min_max.result +++ b/mysql-test/main/group_min_max.result @@ -2233,7 +2233,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY PRIMARY 7 NULL 1 Using where; Using index for group-by EXPLAIN SELECT a FROM t1 WHERE a='BB' GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY PRIMARY 7 const 1 Using where; Using index +1 SIMPLE t1 range PRIMARY PRIMARY 7 NULL 1 Using where; Using index for group-by SELECT DISTINCT a FROM t1 WHERE a='BB'; a BB diff --git a/mysql-test/main/having_cond_pushdown.result b/mysql-test/main/having_cond_pushdown.result index 15b49b7ba2f..e1f49b075b7 100644 --- a/mysql-test/main/having_cond_pushdown.result +++ b/mysql-test/main/having_cond_pushdown.result @@ -1026,7 +1026,7 @@ GROUP BY v1.a HAVING (v1.a>1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where; Using temporary; Using filesort -1 PRIMARY <derived2> ref key0 key0 5 test.t2.x 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t2.x 1 2 DERIVED t1 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort explain format=json SELECT v1.a FROM t2,v1 @@ -1063,7 +1063,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.x"], "loops": 4, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -1131,7 +1131,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.x"], "loops": 4, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -1189,7 +1189,7 @@ GROUP BY v1.c HAVING (v1.c>2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where; Using temporary; Using filesort -1 PRIMARY <derived2> ref key0 key0 5 test.t2.x 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t2.x 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort explain format=json SELECT v1.a,v1.c FROM t2,v1 @@ -1226,7 +1226,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.x"], "loops": 4, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 2", @@ -1295,7 +1295,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t2.x"], "loops": 4, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "v1.c > 2", diff --git a/mysql-test/main/in_subq_cond_pushdown.result b/mysql-test/main/in_subq_cond_pushdown.result index 195d9db22de..d0431852614 100644 --- a/mysql-test/main/in_subq_cond_pushdown.result +++ b/mysql-test/main/in_subq_cond_pushdown.result @@ -4012,7 +4012,7 @@ GROUP BY t1.a WHERE d_tab.a=t3.x AND d_tab.a<5 AND d_tab.max_c<70; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 8 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t3.x 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t3.x 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 16 Using where; Using temporary; Using filesort 2 DERIVED <subquery3> eq_ref distinct_key distinct_key 12 test.t1.a,test.t1.b,test.t1.c 1 3 MATERIALIZED t2 ALL NULL NULL NULL NULL 12 Using where; Using temporary @@ -4059,7 +4059,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t3.x"], "loops": 8, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "d_tab.max_c < 70", @@ -4210,7 +4210,7 @@ GROUP BY t1.a WHERE d_tab.a=t3.x AND d_tab.a<5 AND d_tab.max_c<70; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 8 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t3.x 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t3.x 1 Using where 2 DERIVED t1 ALL NULL NULL NULL NULL 16 Using where; Using temporary; Using filesort 2 DERIVED <subquery3> eq_ref distinct_key distinct_key 12 test.t1.a,test.t1.b,test.t1.c 1 3 MATERIALIZED t2 ALL NULL NULL NULL NULL 12 Using where; Using temporary @@ -4257,7 +4257,7 @@ EXPLAIN "used_key_parts": ["a"], "ref": ["test.t3.x"], "loops": 8, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "attached_condition": "d_tab.max_c < 70", diff --git a/mysql-test/main/innodb_ext_key.result b/mysql-test/main/innodb_ext_key.result index 5a5704a8837..d1f4c60f5b2 100644 --- a/mysql-test/main/innodb_ext_key.result +++ b/mysql-test/main/innodb_ext_key.result @@ -392,7 +392,7 @@ SELECT a FROM t1 AS t, t2 as t2_out WHERE t2_out.c = t.a AND t.b IN (SELECT b FROM t1, t2 WHERE b = t.b); a 24 -Last_query_cost 0.119652 +Last_query_cost 0.120558 DROP TABLE t1,t2; # # LP Bug #923236: hash join + extended_keys = on diff --git a/mysql-test/main/join.result b/mysql-test/main/join.result index c35ec009587..a156feeeea9 100644 --- a/mysql-test/main/join.result +++ b/mysql-test/main/join.result @@ -1115,7 +1115,7 @@ ON t4.a = t5.a ON t1.a = t3.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 -1 SIMPLE t3 ref a a 5 test.t1.a 2 Using where; Using index +1 SIMPLE t3 ref a a 5 test.t1.a 1 Using where; Using index 1 SIMPLE t4 ALL NULL NULL NULL NULL 0 Using where 1 SIMPLE t5 ALL NULL NULL NULL NULL 0 Using where 1 SIMPLE t6 ALL NULL NULL NULL NULL 0 Using where @@ -1486,7 +1486,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE D system PRIMARY NULL NULL NULL 1 1 SIMPLE DSAR system NULL NULL NULL NULL 1 1 SIMPLE DSA ref PRIMARY PRIMARY 4 const 3 Using where; Using index -1 SIMPLE DT ref t_id t_id 2 test.DSA.t_id 2 Using where +1 SIMPLE DT ref t_id t_id 2 test.DSA.t_id 1 Using where SELECT * FROM t5 DU, t1 D, t4 DT, t2 DSA, t3 DSAR WHERE DU.dog_id=D.dog_id AND D.dog_id=DT.dog_id AND D.birthday=DT.birthday AND DT.t_id=DSA.t_id AND DT.birthday=DSA.birthday AND DSA.dog_id=DSAR.dog_id; diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result index b5ed58e4382..0965ac8a555 100644 --- a/mysql-test/main/join_cache.result +++ b/mysql-test/main/join_cache.result @@ -3125,15 +3125,15 @@ t1.metaid = t2.metaid AND t1.affiliateid = '2'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 system PRIMARY NULL NULL NULL 1 1 SIMPLE t5 ref PRIMARY,t5_formattypeid t5_formattypeid 4 const 1 -1 SIMPLE t9 index PRIMARY,t9_subgenreid,t9_metaid PRIMARY 8 NULL 2 Using index; Using join buffer (flat, BNL join) -1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t9.metaid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t4 ref PRIMARY,t4_formatclassid,t4_formats_idx t4_formatclassid 4 test.t5.formatclassid 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t3 ref t3_metaid,t3_formatid,t3_metaidformatid t3_formatid 4 test.t4.formatid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t1 ref t1_affiliateid,t1_metaid t1_metaid 4 test.t3.metaid 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t3.metaid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t7 ref PRIMARY PRIMARY 4 test.t3.metaid 1 Using index +1 SIMPLE t8 eq_ref PRIMARY PRIMARY 4 test.t7.artistid 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t9 ref PRIMARY,t9_subgenreid,t9_metaid t9_metaid 4 test.t3.metaid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t10 eq_ref PRIMARY,t10_genreid PRIMARY 4 test.t9.subgenreid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t11 eq_ref PRIMARY PRIMARY 4 test.t10.genreid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t7 ref PRIMARY PRIMARY 4 test.t9.metaid 1 Using index -1 SIMPLE t8 eq_ref PRIMARY PRIMARY 4 test.t7.artistid 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t3 ref t3_metaid,t3_formatid,t3_metaidformatid t3_metaidformatid 4 test.t9.metaid 1 Using index condition; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t4 eq_ref PRIMARY,t4_formatclassid,t4_formats_idx PRIMARY 4 test.t3.formatid 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t1 ref t1_affiliateid,t1_metaid t1_affiliateid 4 const 2 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan SELECT t1.uniquekey, t1.xml AS affiliateXml, t8.name AS artistName, t8.artistid, t11.name AS genreName, t11.genreid, t11.priority AS genrePriority, @@ -3273,7 +3273,7 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref i_a i_a 4 test.t1.a 2 Using where; Not exists +1 SIMPLE t2 ref i_a i_a 4 test.t1.a 1 Using where; Not exists SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; a a b 3 NULL NULL @@ -3284,7 +3284,7 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref i_a i_a 4 test.t1.a 2 Using where; Not exists; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 ref i_a i_a 4 test.t1.a 1 Using where; Not exists; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; a a b 3 NULL NULL @@ -3311,7 +3311,7 @@ select t1.a, count(t2.p) as count from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL PRIMARY 4 NULL 8 Using index; Using temporary; Using filesort -1 SIMPLE t2 ref i_a i_a 5 test.t1.a 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 ref i_a i_a 5 test.t1.a 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan select t1.a, count(t2.p) as count from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a; a count @@ -4085,7 +4085,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.carrier 1 Using where -1 SIMPLE t4 ref carrier_id carrier_id 5 test.t3.id 2 Using index +1 SIMPLE t4 ref carrier_id carrier_id 5 test.t3.id 1 Using index SET join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4; # @@ -4101,7 +4101,7 @@ set join_cache_level = 5; explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 -1 SIMPLE t2 ref b b 5 test.t1.b 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 ref b b 5 test.t1.b 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; a NULL @@ -4110,7 +4110,7 @@ set join_cache_level = 8; explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 -1 SIMPLE t2 ref b b 5 test.t1.b 2 Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 ref b b 5 test.t1.b 1 Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; a NULL @@ -4121,7 +4121,7 @@ set join_cache_level = 5; explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 -1 SIMPLE t2 ref b b 5 test.t1.b 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 ref b b 5 test.t1.b 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; a NULL @@ -4136,7 +4136,7 @@ set join_cache_level = 5; explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 -1 SIMPLE t2 ref b b 103 test.t1.b 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 ref b b 103 test.t1.b 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; a NULL @@ -4145,7 +4145,7 @@ set join_cache_level = 8; explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 -1 SIMPLE t2 ref b b 103 test.t1.b 2 Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 ref b b 103 test.t1.b 1 Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; a NULL @@ -4529,7 +4529,7 @@ EXPLAIN SELECT t2.i FROM t1,t2 WHERE t1.cu = t2.cl ; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 -1 SIMPLE t1 ref cu cu 33 func 2 Using where; Using index +1 SIMPLE t1 ref cu cu 33 func 1 Using where; Using index SELECT t2.i FROM t1,t2 WHERE t1.cu = t2.cl ; i 6 @@ -4862,7 +4862,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where -1 SIMPLE t4 ref idx idx 5 test.t1.a1 2 100.00 Using where +1 SIMPLE t4 ref idx idx 5 test.t1.a1 1 100.00 Using where 1 SIMPLE t5 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`c2` AS `c2`,`test`.`t2`.`d2` AS `d2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`a3` AS `a3`,`test`.`t3`.`c3` AS `c3`,`test`.`t3`.`d3` AS `d3`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`a4` AS `a4`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`a5` AS `a5` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`d2` = `test`.`t1`.`pk` and `test`.`t3`.`a3` = `test`.`t2`.`c2`) left join `test`.`t4` on(`test`.`t4`.`a4` = `test`.`t1`.`a1` and `test`.`t1`.`a1` is not null) left join `test`.`t5` on(`test`.`t5`.`a5` = `test`.`t3`.`a3`) where 1 @@ -4884,7 +4884,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t4 ref idx idx 5 test.t1.a1 2 100.00 Using where +1 SIMPLE t4 ref idx idx 5 test.t1.a1 1 100.00 Using where 1 SIMPLE t5 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`c2` AS `c2`,`test`.`t2`.`d2` AS `d2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`a3` AS `a3`,`test`.`t3`.`c3` AS `c3`,`test`.`t3`.`d3` AS `d3`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`a4` AS `a4`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`a5` AS `a5` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`d2` = `test`.`t1`.`pk` and `test`.`t3`.`a3` = `test`.`t2`.`c2`) left join `test`.`t4` on(`test`.`t4`.`a4` = `test`.`t1`.`a1` and `test`.`t1`.`a1` is not null) left join `test`.`t5` on(`test`.`t5`.`a5` = `test`.`t3`.`a3`) where 1 @@ -4906,7 +4906,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where -1 SIMPLE t4 ref idx idx 5 test.t1.a1 2 100.00 Using where +1 SIMPLE t4 ref idx idx 5 test.t1.a1 1 100.00 Using where 1 SIMPLE t5 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`c2` AS `c2`,`test`.`t2`.`d2` AS `d2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`a3` AS `a3`,`test`.`t3`.`c3` AS `c3`,`test`.`t3`.`d3` AS `d3`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`a4` AS `a4`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`a5` AS `a5` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`d2` = `test`.`t1`.`pk` and `test`.`t3`.`a3` = `test`.`t2`.`c2`) left join `test`.`t4` on(`test`.`t4`.`a4` = `test`.`t1`.`a1` and `test`.`t1`.`a1` is not null) left join `test`.`t5` on(`test`.`t5`.`a5` = `test`.`t3`.`a3`) where 1 @@ -5154,7 +5154,7 @@ EXPLAIN SELECT * FROM t1,t2 WHERE t2.f3 = t1.f2 AND t1.f1 IN (9, 0, 100) ORDER BY t1.f2 LIMIT 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range f1,f2 f1 5 NULL 3 Using where; Rowid-ordered scan; Using filesort -1 SIMPLE t2 ref f3 f3 67 test.t1.f2 2 Using where; Using index +1 SIMPLE t2 ref f3 f3 67 test.t1.f2 1 Using where; Using index SELECT * FROM t1,t2 WHERE t2.f3 = t1.f2 AND t1.f1 IN (9, 0 ,100) ORDER BY t1.f2 LIMIT 1; f1 f2 f3 @@ -5164,7 +5164,7 @@ EXPLAIN SELECT * FROM t1,t2 WHERE t2.f3 = t1.f2 AND t1.f1 IN (9, 0 ,100) ORDER BY t1.f2 LIMIT 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range f1,f2 f1 5 NULL 3 Using index condition; Using where; Rowid-ordered scan; Using filesort -1 SIMPLE t2 ref f3 f3 67 test.t1.f2 2 Using where; Using index +1 SIMPLE t2 ref f3 f3 67 test.t1.f2 1 Using where; Using index SELECT * FROM t1,t2 WHERE t2.f3 = t1.f2 AND t1.f1 IN (9, 0 ,100) ORDER BY t1.f2 LIMIT 1; f1 f2 f3 @@ -5265,7 +5265,7 @@ EXPLAIN SELECT a FROM t1,t2 WHERE t2.v = t1.v ; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where -1 SIMPLE t2 ref idx idx 4 test.t1.v 2 +1 SIMPLE t2 ref idx idx 4 test.t1.v 1 SELECT a FROM t1,t2 WHERE t2.v = t1.v ; a 11 @@ -5323,7 +5323,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where -1 PRIMARY t2 ref c c 5 test.t1.b 2 Using index; Start temporary; End temporary +1 PRIMARY t2 ref c c 5 test.t1.b 1 Using index; Start temporary; End temporary SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); a b 3914 17 @@ -5503,7 +5503,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t3 system NULL NULL NULL NULL 1 1 PRIMARY t2 range a,c a 5 NULL 2 Using index condition; Using where; Using filesort -1 PRIMARY t4 ref c c 5 test.t2.c 2 Using where; Start temporary; End temporary +1 PRIMARY t4 ref c c 5 test.t2.c 1 Using where; Start temporary; End temporary SELECT * FROM t1,t2 WHERE t2.c IN (SELECT c FROM t3,t4 WHERE t4.a < 10) AND t2.a BETWEEN 4 and 5 @@ -5521,7 +5521,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 Using temporary; Using filesort 1 PRIMARY t3 system NULL NULL NULL NULL 1 1 PRIMARY t2 range a,c a 5 NULL 2 Using index condition; Using where -1 PRIMARY t4 ref c c 5 test.t2.c 2 Using where; Start temporary; End temporary +1 PRIMARY t4 ref c c 5 test.t2.c 1 Using where; Start temporary; End temporary SELECT * FROM t1,t2 WHERE t2.c IN (SELECT c FROM t3,t4 WHERE t4.a < 10) AND t2.a BETWEEN 4 and 5 @@ -5540,7 +5540,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 Using temporary; Using filesort 1 PRIMARY t3 system NULL NULL NULL NULL 1 1 PRIMARY t2 range a,c a 5 NULL 2 Using index condition; Using where -1 PRIMARY t4 ref c c 5 test.t2.c 2 Using where; Start temporary; End temporary +1 PRIMARY t4 ref c c 5 test.t2.c 1 Using where; Start temporary; End temporary SELECT * FROM t1,t2 WHERE t2.c IN (SELECT c FROM t3,t4 WHERE t4.a < 10) AND t2.a BETWEEN 4 and 5 @@ -5583,7 +5583,7 @@ and t2.uid=t1.fid; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ref uid uid 5 const 4 Using where; Start temporary 1 PRIMARY t4 eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 Using index -1 PRIMARY t1 ref uid uid 5 test.t3.fid 2 Using where; End temporary; Using join buffer (flat, BKAH join); Rowid-ordered scan +1 PRIMARY t1 ref uid uid 5 test.t3.fid 1 Using where; End temporary; Using join buffer (flat, BKAH join); Rowid-ordered scan 1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 Using join buffer (flat, BKAH join); Rowid-ordered scan select name from t2, t1 where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) diff --git a/mysql-test/main/join_nested.result b/mysql-test/main/join_nested.result index 96f4372ee14..7eaaf85e2bf 100644 --- a/mysql-test/main/join_nested.result +++ b/mysql-test/main/join_nested.result @@ -855,7 +855,7 @@ ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b AND t2.a>0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join) -1 SIMPLE t2 ref idx_b idx_b 5 test.t3.b 2 100.00 Using where +1 SIMPLE t2 ref idx_b idx_b 5 test.t3.b 1 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t3`.`b` and `test`.`t2`.`b` = `test`.`t3`.`b` and `test`.`t2`.`a` > 0 and `test`.`t3`.`b` is not null) where 1 @@ -969,10 +969,10 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t8 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where +1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 1 100.00 Using where 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where -1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`a` > 0 and `test`.`t4`.`a` > 0 and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`a` > 0)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t4`.`b` = `test`.`t3`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`a` > 0 and `test`.`t4`.`a` > 0 and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`a` > 0)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t3`.`b` = `test`.`t4`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null) INSERT INTO t8 VALUES (-3,12,0), (-1,14,0), (-5,15,0), (-1,11,0), (-4,13,0); CREATE INDEX idx_b ON t8(b); EXPLAIN EXTENDED @@ -1017,12 +1017,12 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where 1 SIMPLE t7 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where -1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where +1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 1 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where +1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 1 100.00 Using where 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where -1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`a` > 0 and `test`.`t4`.`a` > 0 and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t8`.`a` >= 0 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`a` > 0)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t4`.`b` = `test`.`t3`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`a` > 0 and `test`.`t4`.`a` > 0 and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t8`.`a` >= 0 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`a` > 0)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t3`.`b` = `test`.`t4`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null) INSERT INTO t1 VALUES (-1,133,0), (-2,12,0), (-3,11,0), (-5,15,0); CREATE INDEX idx_b ON t1(b); CREATE INDEX idx_a ON t0(a); @@ -1063,17 +1063,17 @@ t0.b=t1.b AND (t9.a=1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ref idx_a idx_a 5 const 2 100.00 Using where -1 SIMPLE t1 ref idx_b idx_b 5 test.t0.b 2 100.00 +1 SIMPLE t1 ref idx_b idx_b 5 test.t0.b 1 100.00 1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where 1 SIMPLE t7 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where -1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where +1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 1 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where +1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 1 100.00 Using where 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where -1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2 and `test`.`t1`.`a` > 0) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t4`.`b` = `test`.`t3`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2 and `test`.`t1`.`a` > 0) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t3`.`b` = `test`.`t4`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null) SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b FROM t0,t1 @@ -1210,12 +1210,12 @@ EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON c < 3 and b = c; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL a 5 NULL 21 Using index 1 SIMPLE t2 range b b 5 NULL 3 Using where; Using index -1 SIMPLE t3 ref c c 5 test.t2.b 2 Using index +1 SIMPLE t3 ref c c 5 test.t2.b 1 Using index EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL a 5 NULL 21 Using index 1 SIMPLE t2 range b b 5 NULL 3 Using where; Using index -1 SIMPLE t3 ref c c 5 test.t2.b 2 Using index +1 SIMPLE t3 ref c c 5 test.t2.b 1 Using index SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; a b c NULL 0 0 diff --git a/mysql-test/main/join_nested_jcl6.result b/mysql-test/main/join_nested_jcl6.result index a62bba19f16..2148fb859b4 100644 --- a/mysql-test/main/join_nested_jcl6.result +++ b/mysql-test/main/join_nested_jcl6.result @@ -864,7 +864,7 @@ ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b AND t2.a>0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join) -1 SIMPLE t2 ref idx_b idx_b 5 test.t3.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 ref idx_b idx_b 5 test.t3.b 1 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join) Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t3`.`b` and `test`.`t2`.`b` = `test`.`t3`.`b` and `test`.`t2`.`a` > 0 and `test`.`t3`.`b` is not null) where 1 @@ -978,10 +978,10 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 1 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`a` > 0 and `test`.`t4`.`a` > 0 and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`a` > 0 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t4`.`b` = `test`.`t3`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`a` > 0 and `test`.`t4`.`a` > 0 and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`a` > 0 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t3`.`b` = `test`.`t4`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null) INSERT INTO t8 VALUES (-3,12,0), (-1,14,0), (-5,15,0), (-1,11,0), (-4,13,0); CREATE INDEX idx_b ON t8(b); EXPLAIN EXTENDED @@ -1026,12 +1026,12 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 1 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 1 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`a` > 0 and `test`.`t4`.`a` > 0 and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t8`.`a` >= 0 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`a` > 0 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t4`.`b` = `test`.`t3`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`a` > 0 and `test`.`t4`.`a` > 0 and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t8`.`a` >= 0 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`a` > 0 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t3`.`b` = `test`.`t4`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null) INSERT INTO t1 VALUES (-1,133,0), (-2,12,0), (-3,11,0), (-5,15,0); CREATE INDEX idx_b ON t1(b); CREATE INDEX idx_a ON t0(a); @@ -1072,17 +1072,17 @@ t0.b=t1.b AND (t9.a=1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ref idx_a idx_a 5 const 2 100.00 Using where -1 SIMPLE t1 ref idx_b idx_b 5 test.t0.b 2 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t1 ref idx_b idx_b 5 test.t0.b 1 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 1 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 1 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2 and `test`.`t1`.`a` > 0) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t4`.`b` = `test`.`t3`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2 and `test`.`t1`.`a` > 0) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t3`.`b` = `test`.`t4`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null) SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b FROM t0,t1 @@ -1219,12 +1219,12 @@ EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON c < 3 and b = c; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL a 5 NULL 21 Using index 1 SIMPLE t2 range b b 5 NULL 3 Using where; Using index -1 SIMPLE t3 ref c c 5 test.t2.b 2 Using index +1 SIMPLE t3 ref c c 5 test.t2.b 1 Using index EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL a 5 NULL 21 Using index 1 SIMPLE t2 range b b 5 NULL 3 Using where; Using index -1 SIMPLE t3 ref c c 5 test.t2.b 2 Using index +1 SIMPLE t3 ref c c 5 test.t2.b 1 Using index SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; a b c NULL 0 0 @@ -2085,9 +2085,9 @@ ON t6.b >= 2 AND t5.b=t7.b AND (t8.a > 0 OR t8.c IS NULL) AND t6.a>0 AND t7.a>0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t5 ALL NULL NULL NULL NULL 3 -1 SIMPLE t7 ref|filter PRIMARY,b_i b_i|PRIMARY 5|4 test.t5.b 2 (29%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter +1 SIMPLE t7 ref|filter PRIMARY,b_i b_i|PRIMARY 5|4 test.t5.b 1 (29%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter 1 SIMPLE t6 range|filter PRIMARY,b_i PRIMARY|b_i 4|5 NULL 3 (86%) Using where; Rowid-ordered scan; Using join buffer (incremental, BNL join); Using rowid filter -1 SIMPLE t8 ref b_i b_i 5 test.t5.b 2 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t8 ref b_i b_i 5 test.t5.b 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b FROM t5 LEFT JOIN @@ -2122,7 +2122,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t5 ALL NULL NULL NULL NULL 2 1 SIMPLE t6 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t7 const PRIMARY PRIMARY 4 const 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t8 ref b_i b_i 5 test.t5.b 2 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t8 ref b_i b_i 5 test.t5.b 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b FROM t5 LEFT JOIN (t6 LEFT JOIN t7 ON t7.a=1, t8) @@ -2139,7 +2139,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t5 ALL NULL NULL NULL NULL 2 1 SIMPLE t6 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t7 ref b_i b_i 5 const 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t8 ref b_i b_i 5 test.t5.b 2 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t8 ref b_i b_i 5 test.t5.b 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b FROM t5 LEFT JOIN (t6 LEFT JOIN t7 ON t7.b=2, t8) @@ -2154,9 +2154,9 @@ FROM t5 LEFT JOIN ON (t5.b=t8.b); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t5 ALL NULL NULL NULL NULL 2 -1 SIMPLE t6 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t8 ref b_i b_i 5 test.t5.b 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t6 ALL NULL NULL NULL NULL 1 Using join buffer (incremental, BNL join) 1 SIMPLE t7 const PRIMARY PRIMARY 4 const 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t8 ref b_i b_i 5 test.t5.b 2 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b FROM t5 LEFT JOIN (t8, t6 LEFT JOIN t7 ON t7.a=1) diff --git a/mysql-test/main/join_outer.result b/mysql-test/main/join_outer.result index 6ed5114ea5b..ce9dbfb8c3d 100644 --- a/mysql-test/main/join_outer.result +++ b/mysql-test/main/join_outer.result @@ -1230,7 +1230,7 @@ EXPLAIN SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref idx idx 4 test.t1.id 2 Using where; Not exists +1 SIMPLE t2 ref idx idx 4 test.t1.id 1 Using where; Not exists flush status; SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; id a @@ -2080,7 +2080,7 @@ WHERE t1.pk BETWEEN 5 AND 6 AND t1.b IS NULL OR t1.b = 5 ORDER BY t1.b; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ref idx idx 4 const 2 100.00 Using where -1 SIMPLE t2 ref c c 5 test.t1.a 2 100.00 +1 SIMPLE t2 ref c c 5 test.t1.a 1 100.00 Warnings: Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`c` = `test`.`t1`.`a` and `test`.`t1`.`b` = 5 order by `test`.`t1`.`b` SELECT t1.b, t2.c, t2.d FROM t2 JOIN t1 ON t2.c = t1.a @@ -2097,7 +2097,7 @@ WHERE t1.pk BETWEEN 5 AND 6 AND t1.b IS NULL OR t1.b = 5 ORDER BY t1.b; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ref PRIMARY,idx idx 4 const 2 100.00 Using where -1 SIMPLE t2 ref c c 5 test.t1.a 2 100.00 +1 SIMPLE t2 ref c c 5 test.t1.a 1 100.00 Warnings: Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`c` = `test`.`t1`.`a` and `test`.`t1`.`b` = 5 order by `test`.`t1`.`b` SELECT t1.b, t2.c, t2.d FROM t2 LEFT JOIN t1 ON t2.c = t1.a diff --git a/mysql-test/main/join_outer_innodb.result b/mysql-test/main/join_outer_innodb.result index dc3a8bdb1f6..71ff11781a8 100644 --- a/mysql-test/main/join_outer_innodb.result +++ b/mysql-test/main/join_outer_innodb.result @@ -448,9 +448,9 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t12 eq_ref PRIMARY PRIMARY 4 test.t11.k3 1 Using where 1 SIMPLE l2 eq_ref PRIMARY PRIMARY 4 test.t11.k4 1 Using where 1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1 -1 SIMPLE t13 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index +1 SIMPLE t13 ref PRIMARY,m3 PRIMARY 4 test.t1.a1 1 Using where 1 SIMPLE l4 eq_ref PRIMARY PRIMARY 4 test.t13.m2 1 Using where -1 SIMPLE m2 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index +1 SIMPLE m2 ref PRIMARY,m3 PRIMARY 4 test.t1.a1 1 Using where 1 SIMPLE l3 eq_ref PRIMARY PRIMARY 4 test.m2.m2 1 Using where 1 SIMPLE t14 eq_ref PRIMARY PRIMARY 2 test.t1.a8 1 Using where 1 SIMPLE t15 eq_ref PRIMARY PRIMARY 2 test.t1.a9 1 Using where @@ -471,9 +471,9 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t12 eq_ref PRIMARY PRIMARY 4 test.t11.k3 1 Using where 1 SIMPLE l2 eq_ref PRIMARY PRIMARY 4 test.t11.k4 1 Using where 1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1 -1 SIMPLE t13 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index +1 SIMPLE t13 ref PRIMARY,m3 PRIMARY 4 test.t1.a1 1 Using where 1 SIMPLE l4 eq_ref PRIMARY PRIMARY 4 test.t13.m2 1 Using where -1 SIMPLE m2 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index +1 SIMPLE m2 ref PRIMARY,m3 PRIMARY 4 test.t1.a1 1 Using where 1 SIMPLE l3 eq_ref PRIMARY PRIMARY 4 test.m2.m2 1 Using where 1 SIMPLE t14 eq_ref PRIMARY PRIMARY 2 test.t1.a8 1 Using where 1 SIMPLE t15 eq_ref PRIMARY PRIMARY 2 test.t1.a9 1 Using where diff --git a/mysql-test/main/join_outer_jcl6.result b/mysql-test/main/join_outer_jcl6.result index eeb22c2c5ac..ff5e76b78ad 100644 --- a/mysql-test/main/join_outer_jcl6.result +++ b/mysql-test/main/join_outer_jcl6.result @@ -1237,7 +1237,7 @@ EXPLAIN SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref idx idx 4 test.t1.id 2 Using where; Not exists; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 ref idx idx 4 test.t1.id 1 Using where; Not exists; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan flush status; SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; id a @@ -2087,7 +2087,7 @@ WHERE t1.pk BETWEEN 5 AND 6 AND t1.b IS NULL OR t1.b = 5 ORDER BY t1.b; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ref idx idx 4 const 2 100.00 Using where -1 SIMPLE t2 ref c c 5 test.t1.a 2 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 ref c c 5 test.t1.a 1 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan Warnings: Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`c` = `test`.`t1`.`a` and `test`.`t1`.`b` = 5 order by `test`.`t1`.`b` SELECT t1.b, t2.c, t2.d FROM t2 JOIN t1 ON t2.c = t1.a @@ -2104,7 +2104,7 @@ WHERE t1.pk BETWEEN 5 AND 6 AND t1.b IS NULL OR t1.b = 5 ORDER BY t1.b; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ref PRIMARY,idx idx 4 const 2 100.00 Using where -1 SIMPLE t2 ref c c 5 test.t1.a 2 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 ref c c 5 test.t1.a 1 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan Warnings: Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`c` = `test`.`t1`.`a` and `test`.`t1`.`b` = 5 order by `test`.`t1`.`b` SELECT t1.b, t2.c, t2.d FROM t2 LEFT JOIN t1 ON t2.c = t1.a diff --git a/mysql-test/main/key_cache.result b/mysql-test/main/key_cache.result index 4ec0d6ab7d7..0ac03750081 100644 --- a/mysql-test/main/key_cache.result +++ b/mysql-test/main/key_cache.result @@ -134,7 +134,7 @@ i explain select count(*) from t1, t2 where t1.p = t2.i; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using index -1 SIMPLE t2 ref k1 k1 5 test.t1.p 2 Using index +1 SIMPLE t2 ref k1 k1 5 test.t1.p 1 Using index select count(*) from t1, t2 where t1.p = t2.i; count(*) 3 diff --git a/mysql-test/main/key_diff.result b/mysql-test/main/key_diff.result index af928fcb203..f419be55208 100644 --- a/mysql-test/main/key_diff.result +++ b/mysql-test/main/key_diff.result @@ -36,7 +36,7 @@ a a a a explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL a NULL NULL NULL 5 -1 SIMPLE t2 ALL b NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ref b b 4 test.t1.a 1 Using index condition select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a; a b a b A B a a diff --git a/mysql-test/main/myisam_explain_non_select_all.result b/mysql-test/main/myisam_explain_non_select_all.result index 9eca0065bb1..bb6fa785b7f 100644 --- a/mysql-test/main/myisam_explain_non_select_all.result +++ b/mysql-test/main/myisam_explain_non_select_all.result @@ -2442,13 +2442,13 @@ INSERT INTO t2 VALUES(1,1),(2,2); EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 -2 DEPENDENT SUBQUERY t2 ref IDX IDX 5 test.t1.f1 2 +2 DEPENDENT SUBQUERY t2 ref IDX IDX 5 test.t1.f1 1 FLUSH STATUS; FLUSH TABLES; EXPLAIN EXTENDED UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 -2 DEPENDENT SUBQUERY t2 ref IDX IDX 5 test.t1.f1 2 100.00 +2 DEPENDENT SUBQUERY t2 ref IDX IDX 5 test.t1.f1 1 100.00 Warnings: Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 # Status of EXPLAIN EXTENDED query @@ -2459,7 +2459,7 @@ FLUSH TABLES; EXPLAIN EXTENDED SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 -2 DEPENDENT SUBQUERY t2 ref IDX IDX 5 test.t1.f1 2 100.00 +2 DEPENDENT SUBQUERY t2 ref IDX IDX 5 test.t1.f1 1 100.00 Warnings: Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select <expr_cache><`test`.`t1`.`f1`>((/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where `test`.`t2`.`f3` = `test`.`t1`.`f1`)) AS `(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1)` from `test`.`t1` diff --git a/mysql-test/main/null_key.result b/mysql-test/main/null_key.result index 572d7302b74..cee3484a304 100644 --- a/mysql-test/main/null_key.result +++ b/mysql-test/main/null_key.result @@ -181,12 +181,12 @@ insert into t2 values (7),(8); explain select * from t2 straight_join t1 where t1.a=t2.a and b is null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where -1 SIMPLE t1 ref a,b a 10 test.t2.a,const 2 Using where; Using index +1 SIMPLE t1 ref a,b a 10 test.t2.a,const 1 Using where; Using index drop index b on t1; explain select * from t2,t1 where t1.a=t2.a and b is null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where -1 SIMPLE t1 ref a a 10 test.t2.a,const 2 Using where; Using index +1 SIMPLE t1 ref a a 10 test.t2.a,const 1 Using where; Using index select * from t2,t1 where t1.a=t2.a and b is null; a a b 7 7 NULL diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 207fa0f38a1..4ac15c41c27 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -1218,7 +1218,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "used_range_estimates": false, "reason": "not available", "rows": 1, - "cost": 0.1731074, + "cost": 0.1821659, "chosen": true }, { @@ -1235,7 +1235,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "type": "ref", "rows_read": 1, "rows_out": 1, - "cost": 0.1731074, + "cost": 0.1821659, "uses_join_buffering": false } } @@ -1246,7 +1246,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "plan_prefix": "t1", "table": "t2", "rows_for_plan": 100, - "cost_for_plan": 0.1987835 + "cost_for_plan": 0.207842 } ] }, @@ -1272,7 +1272,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "used_range_estimates": false, "reason": "not available", "rows": 1, - "cost": 0.1731074, + "cost": 0.1821659, "chosen": true }, { @@ -1289,7 +1289,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "type": "ref", "rows_read": 1, "rows_out": 1, - "cost": 0.1731074, + "cost": 0.1821659, "uses_join_buffering": false } } @@ -1300,10 +1300,10 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { "plan_prefix": "t2", "table": "t1", "rows_for_plan": 100, - "cost_for_plan": 0.1987835, + "cost_for_plan": 0.207842, "pruned_by_cost": true, - "current_cost": 0.1987835, - "best_cost": 0.1987835 + "current_cost": 0.207842, + "best_cost": 0.207842 } ] } @@ -1312,7 +1312,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { { "best_join_order": ["t1", "t2"], "rows": 100, - "cost": 0.1987835 + "cost": 0.207842 }, { "substitute_best_equal": { @@ -1760,7 +1760,7 @@ set statement optimizer_scan_setup_cost=0 for EXPLAIN SELECT MIN(d) FROM t1 wher "direction": 1, "rows_to_examine": 7, "range_scan": false, - "scan_cost": 0.001667847, + "scan_cost": 0.001758432, "chosen": true } ] @@ -2338,7 +2338,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "using_mrr": false, "index_only": false, "rows": 180, - "cost": 0.223346519, + "cost": 0.223677504, "chosen": false, "cause": "cost" }, @@ -2349,7 +2349,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "using_mrr": false, "index_only": false, "rows": 41, - "cost": 0.051838728, + "cost": 0.051929313, "chosen": true } ], @@ -2370,7 +2370,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "ranges": ["(1,2) <= (a,b) <= (1,2)"] }, "rows_for_plan": 41, - "cost_for_plan": 0.051838728, + "cost_for_plan": 0.051929313, "chosen": true } } @@ -2430,7 +2430,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "index": "a_c", "used_range_estimates": true, "rows": 180, - "cost": 0.222796377, + "cost": 0.222922562, "chosen": true }, { @@ -2438,7 +2438,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "index": "a_b", "used_range_estimates": true, "rows": 41, - "cost": 0.051288586, + "cost": 0.051379171, "chosen": true }, { @@ -2451,7 +2451,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "type": "ref", "rows_read": 41, "rows_out": 41, - "cost": 0.051288586, + "cost": 0.051379171, "uses_join_buffering": false } } @@ -2462,14 +2462,14 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "plan_prefix": "", "table": "t1", "rows_for_plan": 41, - "cost_for_plan": 0.051288586 + "cost_for_plan": 0.051379171 } ] }, { "best_join_order": ["t1"], "rows": 41, - "cost": 0.051288586 + "cost": 0.051379171 }, { "substitute_best_equal": { @@ -2497,7 +2497,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "table": "t1", "rows_estimation": 41, "filesort_cost": 9.387121e-4, - "read_cost": 0.052227298, + "read_cost": 0.052317883, "filesort_type": "priority_queue with addon fields", "fanout": 1, "possible_keys": [ @@ -2507,7 +2507,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "direction": 1, "rows_to_examine": 24, "range_scan": false, - "scan_cost": 0.030312813, + "scan_cost": 0.030403398, "chosen": true }, { @@ -2516,7 +2516,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "direction": 1, "rows_to_examine": 4.390243902, "range_scan": true, - "scan_cost": 0.023380552, + "scan_cost": 0.023415994, "chosen": true }, { @@ -2557,8 +2557,8 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "using_mrr": false, "index_only": false, "rows": 180, - "cost": 0.223346519, - "cost_with_limit": 0.002483968, + "cost": 0.223677504, + "cost_with_limit": 0.002574553, "chosen": true } ], @@ -2579,7 +2579,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "ranges": ["(1) <= (a) <= (1)"] }, "rows_for_plan": 180, - "cost_for_plan": 0.223346519, + "cost_for_plan": 0.223677504, "chosen": true } } @@ -3752,7 +3752,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "using_mrr": false, "index_only": false, "rows": 1, - "cost": 0.002483968, + "cost": 0.002574553, "chosen": true }, { @@ -3762,7 +3762,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "using_mrr": false, "index_only": false, "rows": 1, - "cost": 0.002483968, + "cost": 0.002574553, "chosen": false, "cause": "cost" }, @@ -3773,7 +3773,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "using_mrr": false, "index_only": true, "rows": 1, - "cost": 0.001388369, + "cost": 0.001478954, "chosen": true } ], @@ -3822,7 +3822,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "ranges": ["(2,5,1) <= (pk,a,b) <= (2,5,1)"] }, "rows_for_plan": 1, - "cost_for_plan": 0.001388369, + "cost_for_plan": 0.001478954, "chosen": true } } @@ -3887,7 +3887,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "index": "pk", "used_range_estimates": true, "rows": 1, - "cost": 0.001933826, + "cost": 0.002024411, "chosen": true }, { @@ -3895,7 +3895,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "index": "pk_a", "used_range_estimates": true, "rows": 1, - "cost": 0.001933826, + "cost": 0.002024411, "chosen": false, "cause": "cost" }, @@ -3904,7 +3904,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "index": "pk_a_b", "used_range_estimates": true, "rows": 1, - "cost": 0.000838227, + "cost": 0.000928812, "chosen": true }, { @@ -3917,7 +3917,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "type": "ref", "rows_read": 1, "rows_out": 1, - "cost": 0.000838227, + "cost": 0.000928812, "uses_join_buffering": false } } @@ -3928,14 +3928,14 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "plan_prefix": "", "table": "t1", "rows_for_plan": 1, - "cost_for_plan": 0.000838227 + "cost_for_plan": 0.000928812 } ] }, { "best_join_order": ["t1"], "rows": 1, - "cost": 0.000838227 + "cost": 0.000928812 }, { "substitute_best_equal": { @@ -4309,7 +4309,7 @@ explain delete from t0 where t0.a<3 { "using_mrr": false, "index_only": false, "rows": 3, - "cost": 0.004951706, + "cost": 0.005042291, "chosen": true } ], @@ -4327,7 +4327,7 @@ explain delete from t0 where t0.a<3 { "ranges": ["(NULL) < (a) < (3)"] }, "rows_for_plan": 3, - "cost_for_plan": 0.004951706, + "cost_for_plan": 0.005042291, "chosen": true } } @@ -4454,7 +4454,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "using_mrr": false, "index_only": true, "rows": 3, - "cost": 0.001664909, + "cost": 0.001755494, "chosen": true } ], @@ -4475,7 +4475,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "ranges": ["(NULL) < (a) < (3)"] }, "rows_for_plan": 3, - "cost_for_plan": 0.001664909, + "cost_for_plan": 0.001755494, "chosen": true } } @@ -4519,7 +4519,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "using_mrr": false, "index_only": true, "rows": 3, - "cost": 0.001664909, + "cost": 0.001755494, "chosen": true } ], @@ -4540,7 +4540,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "ranges": ["(NULL) < (a) < (3)"] }, "rows_for_plan": 3, - "cost_for_plan": 0.001664909, + "cost_for_plan": 0.001755494, "chosen": true } } @@ -4575,7 +4575,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "rows": 3, "rows_after_filter": 3, "rows_out": 3, - "cost": 0.001664909, + "cost": 0.001755494, "chosen": true } ], @@ -4583,7 +4583,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "type": "range", "rows_read": 3, "rows_out": 3, - "cost": 0.001664909, + "cost": 0.001755494, "uses_join_buffering": false } } @@ -4601,7 +4601,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "rows": 3, "rows_after_filter": 3, "rows_out": 3, - "cost": 0.001664909, + "cost": 0.001755494, "chosen": true } ], @@ -4609,7 +4609,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "type": "range", "rows_read": 3, "rows_out": 3, - "cost": 0.001664909, + "cost": 0.001755494, "uses_join_buffering": false } } @@ -4620,7 +4620,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "plan_prefix": "", "table": "t0", "rows_for_plan": 3, - "cost_for_plan": 0.001664909, + "cost_for_plan": 0.001755494, "rest_of_plan": [ { "plan_prefix": "t0", @@ -4638,7 +4638,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "used_range_estimates": false, "reason": "not better than ref estimates", "rows": 1, - "cost": 0.002105081, + "cost": 0.002376836, "chosen": true }, { @@ -4651,7 +4651,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "type": "ref", "rows_read": 1, "rows_out": 1, - "cost": 0.002105081, + "cost": 0.002376836, "uses_join_buffering": false } } @@ -4662,7 +4662,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "plan_prefix": "t0", "table": "t1", "rows_for_plan": 3, - "cost_for_plan": 0.00376999 + "cost_for_plan": 0.00413233 } ] }, @@ -4670,7 +4670,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "plan_prefix": "", "table": "t1", "rows_for_plan": 3, - "cost_for_plan": 0.001664909, + "cost_for_plan": 0.001755494, "rest_of_plan": [ { "plan_prefix": "t1", @@ -4688,8 +4688,8 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "rec_per_key_stats_missing": true, "used_range_estimates": false, "reason": "not better than ref estimates", - "rows": 2, - "cost": 0.002519891, + "rows": 1.166666667, + "cost": 0.002392836, "chosen": true }, { @@ -4700,9 +4700,9 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { ], "chosen_access_method": { "type": "ref", - "rows_read": 2, - "rows_out": 2, - "cost": 0.002519891, + "rows_read": 1.166666667, + "rows_out": 1.166666667, + "cost": 0.002392836, "uses_join_buffering": false } } @@ -4712,11 +4712,11 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { { "plan_prefix": "t1", "table": "t0", - "rows_for_plan": 6, - "cost_for_plan": 0.0041848, + "rows_for_plan": 3.5, + "cost_for_plan": 0.00414833, "pruned_by_cost": true, - "current_cost": 0.0041848, - "best_cost": 0.00376999 + "current_cost": 0.00414833, + "best_cost": 0.00413233 } ] } @@ -4725,7 +4725,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { { "best_join_order": ["t0", "t1"], "rows": 3, - "cost": 0.00376999 + "cost": 0.00413233 }, { "substitute_best_equal": { @@ -10386,7 +10386,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 1, - "cost": 0.001388369, + "cost": 0.001478954, "chosen": true } ], @@ -10415,7 +10415,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 107, - "cost": 0.016044989, + "cost": 0.016135574, "chosen": true } ], @@ -10447,7 +10447,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1000, - "cost": 1.235599899, + "cost": 1.235690484, "chosen": true } ], @@ -10487,7 +10487,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 4, - "cost": 0.006185575, + "cost": 0.00627616, "chosen": true } ], @@ -10521,7 +10521,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 0.002483968, + "cost": 0.002574553, "chosen": true } ], @@ -10550,7 +10550,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 0.002483968, + "cost": 0.002574553, "chosen": true } ], @@ -10587,7 +10587,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 0.002483968, + "cost": 0.002574553, "chosen": true } ], @@ -10617,7 +10617,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 0.002483968, + "cost": 0.002574553, "chosen": true } ], @@ -10647,7 +10647,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 0.002483968, + "cost": 0.002574553, "chosen": true } ], @@ -10680,7 +10680,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 0.002483968, + "cost": 0.002574553, "chosen": true } ], @@ -10716,7 +10716,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 0.002483968, + "cost": 0.002574553, "chosen": true } ], @@ -10750,7 +10750,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 2, - "cost": 0.003717837, + "cost": 0.003808422, "chosen": true } ], @@ -10774,7 +10774,7 @@ EXPLAIN { "query_block": { "select_id": 1, - "cost": 1.235599899, + "cost": 1.235690484, "nested_loop": [ { "table": { @@ -10786,7 +10786,7 @@ EXPLAIN "used_key_parts": ["start_date", "end_date"], "loops": 1, "rows": 1000, - "cost": 1.235599899, + "cost": 1.235690484, "filtered": 100, "index_condition": "t1.start_date >= '2019-02-10' and t1.end_date < '2019-04-01'" } @@ -10808,7 +10808,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1000, - "cost": 1.235599899, + "cost": 1.235690484, "chosen": true } ], @@ -11086,7 +11086,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "used_range_estimates": false, "reason": "not available", "rows": 1, - "cost": 0.01810946, + "cost": 0.01901531, "chosen": true }, { @@ -11100,7 +11100,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "type": "ref", "rows_read": 1, "rows_out": 1, - "cost": 0.01810946, + "cost": 0.01901531, "uses_join_buffering": false } } @@ -11111,7 +11111,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "plan_prefix": "A", "table": "B", "rows_for_plan": 10, - "cost_for_plan": 0.02970911, + "cost_for_plan": 0.03061496, "pushdown_cond_selectivity": 0.8, "filtered": 80, "rows_out": 0.8, @@ -11127,7 +11127,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "cost_for_plan": 0.1669214, "pruned_by_cost": true, "current_cost": 0.1669214, - "best_cost": 0.02970911 + "best_cost": 0.03061496 } ] ] @@ -11156,7 +11156,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 1, - "cost": 0.002483968, + "cost": 0.002574553, "chosen": true } ], @@ -11216,7 +11216,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) "using_mrr": false, "index_only": true, "rows": 1, - "cost": 0.001388369, + "cost": 0.001478954, "chosen": true } ] @@ -11332,7 +11332,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "used_range_estimates": false, "reason": "not available", "rows": 1, - "cost": 0.01749506, + "cost": 0.01840091, "chosen": true }, { @@ -11346,7 +11346,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "type": "ref", "rows_read": 1, "rows_out": 1, - "cost": 0.01749506, + "cost": 0.01840091, "uses_join_buffering": false } } @@ -11357,7 +11357,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "plan_prefix": "t1", "table": "t2", "rows_for_plan": 10, - "cost_for_plan": 0.02909471, + "cost_for_plan": 0.03000056, "cost_for_sorting": 0.006368384 } ] @@ -11389,7 +11389,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "used_range_estimates": false, "reason": "not available", "rows": 1, - "cost": 0.1731074, + "cost": 0.1821659, "chosen": true }, { @@ -11421,7 +11421,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "cost_for_plan": 0.13622835, "pruned_by_cost": true, "current_cost": 0.13622835, - "best_cost": 0.035463094 + "best_cost": 0.036368944 } ] } @@ -12003,7 +12003,7 @@ on t1.a=t.a where t1.b < 3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 range idx_b idx_b 5 NULL 4 Using index condition; Using where -1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 2 +1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 1 2 LATERAL DERIVED t2 ref idx_a idx_a 5 test.t1.a 1 select json_detailed(json_extract(trace, '$**.choose_best_splitting')) @@ -12035,7 +12035,7 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) "used_range_estimates": false, "reason": "not available", "rows": 1.8367, - "cost": 0.0019606, + "cost": 0.002051185, "chosen": true }, { @@ -12049,7 +12049,7 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) "type": "ref", "rows_read": 1.8367, "rows_out": 1.8367, - "cost": 0.0019606, + "cost": 0.002051185, "uses_join_buffering": false } } @@ -12060,7 +12060,7 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) "plan_prefix": "", "table": "t2", "rows_for_plan": 1.8367, - "cost_for_plan": 0.0019606, + "cost_for_plan": 0.002051185, "cost_for_sorting": 0.001155201 } ] @@ -12070,14 +12070,14 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) { "table": "t2", "key": "idx_a", - "org_cost": 0.0019606, + "org_cost": 0.002051185, "postjoin_cost": 0.001135418, - "one_splitting_cost": 0.003096018, + "one_splitting_cost": 0.003186603, "unsplit_postjoin_cost": 0.036032575, "unsplit_cost": 0.060625425, "rows": 1.8367, "outer_rows": 4, - "total_splitting_cost": 0.012384072, + "total_splitting_cost": 0.012746412, "chosen": true } } @@ -12235,7 +12235,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "using_mrr": false, "index_only": false, "rows": 9, - "cost": 0.01235492, + "cost": 0.012445505, "chosen": true }, { @@ -12245,7 +12245,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "using_mrr": false, "index_only": false, "rows": 21, - "cost": 0.027161348, + "cost": 0.027251933, "chosen": false, "cause": "cost" } @@ -12267,7 +12267,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "ranges": ["(NULL) < (a) < (10)"] }, "rows_for_plan": 9, - "cost_for_plan": 0.01235492, + "cost_for_plan": 0.012445505, "chosen": true } } @@ -12324,18 +12324,18 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { { "filter": { "rowid_filter_index": "b", - "index_only_cost": 0.001515222, + "index_only_cost": 0.001605807, "filter_startup_cost": 3.004222e-4, "find_key_and_filter_lookup_cost": 7.827422e-4, "filter_selectivity": 0.021, "original_rows": 9, "new_rows": 0.189, - "original_access_cost": 0.011516778, - "with_filter_access_cost": 0.002507997, + "original_access_cost": 0.011607363, + "with_filter_access_cost": 0.002598582, "original_found_rows_cost": 0.010001556, "with_filter_found_rows_cost": 2.100327e-4, - "org_cost": 0.011804778, - "filter_cost": 0.002814467, + "org_cost": 0.011895363, + "filter_cost": 0.002905052, "filter_used": true }, "access_type": "range", @@ -12343,7 +12343,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "rows": 9, "rows_after_filter": 0.189, "rows_out": 0.017766, - "cost": 0.002814467, + "cost": 0.002905052, "chosen": true } ], @@ -12351,7 +12351,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "type": "range", "rows_read": 0.189, "rows_out": 0.017766, - "cost": 0.002814467, + "cost": 0.002905052, "uses_join_buffering": false, "rowid_filter_index": "b" } @@ -12363,7 +12363,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "plan_prefix": "", "table": "t1", "rows_for_plan": 0.017766, - "cost_for_plan": 0.002814467, + "cost_for_plan": 0.002905052, "pushdown_cond_selectivity": 0.094, "filtered": 0.1974, "rows_out": 0.017766 @@ -12373,7 +12373,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { { "best_join_order": ["t1"], "rows": 0.017766, - "cost": 0.002814467 + "cost": 0.002905052 }, { "table": "t1", @@ -12400,7 +12400,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "using_mrr": false, "index_only": true, "rows": 21, - "cost": 0.004153769, + "cost": 0.004244354, "chosen": true } ] @@ -12413,7 +12413,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "ranges": ["(10) <= (b) <= (50)"] }, "rows_for_plan": 21, - "cost_for_plan": 0.004153769, + "cost_for_plan": 0.004244354, "chosen": true } } @@ -12470,7 +12470,7 @@ EXPLAIN { "query_block": { "select_id": 1, - "cost": 2.30309056, + "cost": 2.303362315, "nested_loop": [ { "table": { @@ -12502,7 +12502,7 @@ EXPLAIN }, "loops": 3, "rows": 1000, - "cost": 2.292585745, + "cost": 2.2928575, "filtered": 43.11999893, "attached_condition": "t1.b < 5000 and t1.c < 1000" } @@ -12652,7 +12652,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and "using_mrr": false, "index_only": false, "rows": 4312, - "cost": 5.325058827, + "cost": 5.325149412, "chosen": false, "cause": "cost" } @@ -12778,22 +12778,22 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and "reason": "not available", "filter": { "rowid_filter_index": "b", - "index_only_cost": 0.092006157, + "index_only_cost": 0.092096742, "filter_startup_cost": 0.149564727, "find_key_and_filter_lookup_cost": 0.129350121, "filter_selectivity": 0.4312, "original_rows": 1000, "new_rows": 431.2, - "original_access_cost": 1.203290157, - "with_filter_access_cost": 0.700541939, + "original_access_cost": 1.203380742, + "with_filter_access_cost": 0.700632524, "original_found_rows_cost": 1.111284, "with_filter_found_rows_cost": 0.479185661, - "org_cost": 3.705870471, - "filter_cost": 2.292585745, + "org_cost": 3.706142226, + "filter_cost": 2.2928575, "filter_used": true }, "rows": 431.2, - "cost": 2.292585745, + "cost": 2.2928575, "chosen": true }, { @@ -12880,7 +12880,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and "using_mrr": false, "index_only": false, "rows": 4312, - "cost": 5.325058827, + "cost": 5.325149412, "chosen": false, "cause": "cost" } @@ -12934,7 +12934,7 @@ EXPLAIN { "query_block": { "select_id": 1, - "cost": 0.003717837, + "cost": 0.003808422, "nested_loop": [ { "table": { @@ -12946,7 +12946,7 @@ EXPLAIN "used_key_parts": ["a"], "loops": 1, "rows": 2, - "cost": 0.003717837, + "cost": 0.003808422, "filtered": 100, "index_condition": "t10.a < 3 and t10.b <> 5", "attached_condition": "t10.c < 10" diff --git a/mysql-test/main/opt_trace_index_merge.result b/mysql-test/main/opt_trace_index_merge.result index fa9d34a8d06..5f111e4836e 100644 --- a/mysql-test/main/opt_trace_index_merge.result +++ b/mysql-test/main/opt_trace_index_merge.result @@ -113,12 +113,12 @@ explain select * from t1 where a=1 or b=1 { "using_mrr": false, "index_only": true, "rows": 1, - "cost": 0.001388369, + "cost": 0.001478954, "chosen": true } ], "index_to_merge": "a", - "cumulated_cost": 0.001388369 + "cumulated_cost": 0.001478954 }, { "range_scan_alternatives": [ @@ -129,15 +129,15 @@ explain select * from t1 where a=1 or b=1 { "using_mrr": false, "index_only": true, "rows": 1, - "cost": 0.001388369, + "cost": 0.001478954, "chosen": true } ], "index_to_merge": "b", - "cumulated_cost": 0.002776738 + "cumulated_cost": 0.002957908 } ], - "cost_of_reading_ranges": 0.002776738, + "cost_of_reading_ranges": 0.002957908, "use_roworder_union": true, "cause": "always cheaper than non roworder retrieval", "analyzing_roworder_scans": [ @@ -160,7 +160,7 @@ explain select * from t1 where a=1 or b=1 { } } ], - "index_roworder_union_cost": 0.005004612, + "index_roworder_union_cost": 0.005185782, "members": 2, "chosen": true } @@ -189,7 +189,7 @@ explain select * from t1 where a=1 or b=1 { ] }, "rows_for_plan": 2, - "cost_for_plan": 0.005004612, + "cost_for_plan": 0.005185782, "chosen": true } } @@ -222,7 +222,7 @@ explain select * from t1 where a=1 or b=1 { "rows": 2, "rows_after_filter": 2, "rows_out": 2, - "cost": 0.005004612, + "cost": 0.005185782, "chosen": true } ], @@ -230,7 +230,7 @@ explain select * from t1 where a=1 or b=1 { "type": "index_merge", "rows_read": 2, "rows_out": 2, - "cost": 0.005004612, + "cost": 0.005185782, "uses_join_buffering": false } } @@ -241,14 +241,14 @@ explain select * from t1 where a=1 or b=1 { "plan_prefix": "", "table": "t1", "rows_for_plan": 2, - "cost_for_plan": 0.005004612 + "cost_for_plan": 0.005185782 } ] }, { "best_join_order": ["t1"], "rows": 2, - "cost": 0.005004612 + "cost": 0.005185782 }, { "substitute_best_equal": { @@ -347,7 +347,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 2243, - "cost": 2.770260666, + "cost": 2.770351251, "chosen": true }, { @@ -358,7 +358,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 2243, - "cost": 2.770260666, + "cost": 2.770351251, "chosen": false, "cause": "cost" }, @@ -370,7 +370,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 2243, - "cost": 2.770260666, + "cost": 2.770351251, "chosen": false, "cause": "cost" } @@ -492,7 +492,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 2243, - "cost": 0.312832109, + "cost": 0.312922694, "chosen": true }, { @@ -503,13 +503,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 2243, - "cost": 0.312832109, + "cost": 0.312922694, "chosen": false, "cause": "cost" } ], "index_to_merge": "key1", - "cumulated_cost": 0.312832109 + "cumulated_cost": 0.312922694 }, { "range_scan_alternatives": @@ -522,7 +522,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 2243, - "cost": 0.312832109, + "cost": 0.312922694, "chosen": true }, { @@ -533,16 +533,16 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": true, "rows": 2243, - "cost": 0.312832109, + "cost": 0.312922694, "chosen": false, "cause": "cost" } ], "index_to_merge": "key3", - "cumulated_cost": 0.625664218 + "cumulated_cost": 0.625845388 } ], - "cost_of_reading_ranges": 0.625664218, + "cost_of_reading_ranges": 0.625845388, "use_roworder_union": true, "cause": "always cheaper than non roworder retrieval", "analyzing_roworder_scans": diff --git a/mysql-test/main/opt_trace_index_merge_innodb.result b/mysql-test/main/opt_trace_index_merge_innodb.result index 6711db9c334..635301b0d18 100644 --- a/mysql-test/main/opt_trace_index_merge_innodb.result +++ b/mysql-test/main/opt_trace_index_merge_innodb.result @@ -118,7 +118,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "using_mrr": false, "index_only": false, "rows": 1000, - "cost": 0.19579056, + "cost": 0.19598856, "chosen": false, "cause": "cost" }, @@ -129,7 +129,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "using_mrr": false, "index_only": false, "rows": 1, - "cost": 0.00415068, + "cost": 0.00424968, "chosen": true } ], @@ -168,7 +168,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "ranges": ["(1) <= (key1) <= (1)"] }, "rows_for_plan": 1, - "cost_for_plan": 0.00415068, + "cost_for_plan": 0.00424968, "chosen": true } } @@ -216,7 +216,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "index": "key1", "used_range_estimates": true, "rows": 1, - "cost": 0.00335956, + "cost": 0.00345856, "chosen": true }, { @@ -229,7 +229,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "type": "ref", "rows_read": 1, "rows_out": 1, - "cost": 0.00335956, + "cost": 0.00345856, "uses_join_buffering": false } } @@ -240,14 +240,14 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "plan_prefix": "", "table": "t1", "rows_for_plan": 1, - "cost_for_plan": 0.00335956 + "cost_for_plan": 0.00345856 } ] }, { "best_join_order": ["t1"], "rows": 1, - "cost": 0.00335956 + "cost": 0.00345856 }, { "substitute_best_equal": { diff --git a/mysql-test/main/opt_trace_selectivity.result b/mysql-test/main/opt_trace_selectivity.result index c813b25cb56..d6abad79637 100644 --- a/mysql-test/main/opt_trace_selectivity.result +++ b/mysql-test/main/opt_trace_selectivity.result @@ -58,7 +58,7 @@ JS "index": "a", "used_range_estimates": true, "rows": 104, - "cost": 0.060906438, + "cost": 0.060988785, "chosen": true }, { @@ -66,7 +66,7 @@ JS "index": "b", "used_range_estimates": true, "rows": 340, - "cost": 0.14153631, + "cost": 0.141618657, "chosen": false, "cause": "cost" }, @@ -75,7 +75,7 @@ JS "index": "c", "used_range_estimates": true, "rows": 632, - "cost": 0.241743894, + "cost": 0.241826241, "chosen": false, "cause": "cost" }, @@ -156,7 +156,7 @@ JS "index": "a", "used_range_estimates": true, "rows": 6, - "cost": 0.005306142, + "cost": 0.005388489, "chosen": true }, { @@ -164,7 +164,7 @@ JS "index": "b", "used_range_estimates": true, "rows": 232, - "cost": 0.104637894, + "cost": 0.104720241, "chosen": false, "cause": "cost" }, @@ -173,7 +173,7 @@ JS "index": "c", "used_range_estimates": true, "rows": 293, - "cost": 0.125478666, + "cost": 0.125561013, "chosen": false, "cause": "cost" }, @@ -188,7 +188,7 @@ JS "type": "ref", "rows_read": 6, "rows_out": 0.6, - "cost": 0.005306142, + "cost": 0.005388489, "uses_join_buffering": false } } @@ -199,7 +199,7 @@ JS "plan_prefix": "", "table": "t1", "rows_for_plan": 0.6, - "cost_for_plan": 0.005306142, + "cost_for_plan": 0.005388489, "pushdown_cond_selectivity": 0.1, "filtered": 10, "rows_out": 0.6 diff --git a/mysql-test/main/opt_trace_ucs2.result b/mysql-test/main/opt_trace_ucs2.result index ff63f976a36..e89750ec3b0 100644 --- a/mysql-test/main/opt_trace_ucs2.result +++ b/mysql-test/main/opt_trace_ucs2.result @@ -41,7 +41,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "using_mrr": false, "index_only": false, "rows": 2, - "cost": 0.003717837, + "cost": 0.003808422, "chosen": true } ], diff --git a/mysql-test/main/optimizer_costs.result b/mysql-test/main/optimizer_costs.result index fefc03ae411..49bfdc09a7c 100644 --- a/mysql-test/main/optimizer_costs.result +++ b/mysql-test/main/optimizer_costs.result @@ -228,7 +228,7 @@ flush tables; explain select sum(t2.p+length(t1.a)) from t1, t2 where t1.p = t2.i; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 2 -1 SIMPLE t2 ref k1 k1 5 test.t1.p 2 +1 SIMPLE t2 ref k1 k1 5 test.t1.p 1 set @@optimizer_scan_setup_cost=0.0, @@global.myisam.optimizer_disk_read_ratio=0.0; flush tables; explain select sum(t2.p+length(t1.a)) from t1, t2 where t1.p = t2.i; diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result index db7bb521c10..96f5d9a49c3 100644 --- a/mysql-test/main/order_by.result +++ b/mysql-test/main/order_by.result @@ -3033,17 +3033,17 @@ EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL PRIMARY 4 NULL 8 Using index -1 SIMPLE t2 ref i_a i_a 5 test.t1.a 2 Using index +1 SIMPLE t2 ref i_a i_a 5 test.t1.a 1 Using index EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 8; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index -1 SIMPLE t2 ref i_a i_a 5 test.t1.a 2 Using index +1 SIMPLE t1 index NULL PRIMARY 4 NULL 6 Using index +1 SIMPLE t2 ref i_a i_a 5 test.t1.a 1 Using index EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 100; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL PRIMARY 4 NULL 8 Using index -1 SIMPLE t2 ref i_a i_a 5 test.t1.a 2 Using index +1 SIMPLE t2 ref i_a i_a 5 test.t1.a 1 Using index DROP TABLE t1,t2; # # MDEV-4974 memory leak in 5.5.32-MariaDB-1~wheezy-log diff --git a/mysql-test/main/partition_pruning.result b/mysql-test/main/partition_pruning.result index 7f07a6c4257..6834cf0e657 100644 --- a/mysql-test/main/partition_pruning.result +++ b/mysql-test/main/partition_pruning.result @@ -2677,12 +2677,12 @@ select * from t1 X, t1 Y where X.b = Y.b and (X.a=1 or X.a=2) and (Y.a=2 or Y.a=3); id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE X p1,p2 range a,b a 4 NULL 4 Using where -1 SIMPLE Y p2,p3 ref|filter a,b b|a 4|4 test.X.b 2 (50%) Using where; Using rowid filter +1 SIMPLE Y p2,p3 ref|filter a,b b|a 4|4 test.X.b 1 (50%) Using where; Using rowid filter explain partitions select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2); id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE X p1,p2 range a a 4 NULL 4 Using where -1 SIMPLE Y p1,p2 ref a a 4 test.X.a 2 +1 SIMPLE Y p1,p2 ref a a 4 test.X.a 1 drop table t1; create table t1 (a int) partition by hash(a) partitions 20; insert into t1 values (1),(2),(3); diff --git a/mysql-test/main/select.result b/mysql-test/main/select.result index af65ca169d6..bf19d5e9b4e 100644 --- a/mysql-test/main/select.result +++ b/mysql-test/main/select.result @@ -2407,7 +2407,7 @@ insert into t2 values (1,3), (2,3), (3,4), (4,4); explain select * from t1 left join t2 on a=c where d in (4); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref c,d d 5 const 2 Using where -1 SIMPLE t1 ref a a 5 test.t2.c 2 +1 SIMPLE t1 ref a a 5 test.t2.c 1 select * from t1 left join t2 on a=c where d in (4); a b c d 3 2 3 4 @@ -2415,7 +2415,7 @@ a b c d explain select * from t1 left join t2 on a=c where d = 4; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref c,d d 5 const 2 Using where -1 SIMPLE t1 ref a a 5 test.t2.c 2 +1 SIMPLE t1 ref a a 5 test.t2.c 1 select * from t1 left join t2 on a=c where d = 4; a b c d 3 2 3 4 @@ -2442,11 +2442,11 @@ INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref a a 23 test.t1.a 2 Using where +1 SIMPLE t2 ref a a 23 test.t1.a 1 Using where EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref a a 23 test.t1.a 2 Using where +1 SIMPLE t2 ref a a 23 test.t1.a 1 Using where DROP TABLE t1, t2; CREATE TABLE t1 ( city char(30) ); INSERT INTO t1 VALUES ('London'); @@ -3926,7 +3926,7 @@ cc 3 7 EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref name name 6 test.t1.name 2 Using where +1 SIMPLE t2 ref name name 6 test.t1.name 1 Using where SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; name name n ccc NULL NULL @@ -4019,7 +4019,7 @@ cc 3 7 EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref name name 6 test.t1.name 2 Using where +1 SIMPLE t2 ref name name 6 test.t1.name 1 Using where SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; name name n ccc NULL NULL diff --git a/mysql-test/main/select_jcl6.result b/mysql-test/main/select_jcl6.result index 74a0dbd8855..4001a6db81a 100644 --- a/mysql-test/main/select_jcl6.result +++ b/mysql-test/main/select_jcl6.result @@ -2418,7 +2418,7 @@ insert into t2 values (1,3), (2,3), (3,4), (4,4); explain select * from t1 left join t2 on a=c where d in (4); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref c,d d 5 const 2 Using where -1 SIMPLE t1 ref a a 5 test.t2.c 2 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t1 ref a a 5 test.t2.c 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan select * from t1 left join t2 on a=c where d in (4); a b c d 3 2 3 4 @@ -2426,7 +2426,7 @@ a b c d explain select * from t1 left join t2 on a=c where d = 4; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref c,d d 5 const 2 Using where -1 SIMPLE t1 ref a a 5 test.t2.c 2 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t1 ref a a 5 test.t2.c 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan select * from t1 left join t2 on a=c where d = 4; a b c d 3 2 3 4 @@ -2453,11 +2453,11 @@ INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref a a 23 test.t1.a 2 Using where +1 SIMPLE t2 ref a a 23 test.t1.a 1 Using where EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref a a 23 test.t1.a 2 Using where +1 SIMPLE t2 ref a a 23 test.t1.a 1 Using where DROP TABLE t1, t2; CREATE TABLE t1 ( city char(30) ); INSERT INTO t1 VALUES ('London'); @@ -3937,7 +3937,7 @@ cc 3 7 EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref name name 6 test.t1.name 2 Using where +1 SIMPLE t2 ref name name 6 test.t1.name 1 Using where SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; name name n ccc NULL NULL @@ -4030,7 +4030,7 @@ cc 3 7 EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref name name 6 test.t1.name 2 Using where +1 SIMPLE t2 ref name name 6 test.t1.name 1 Using where SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; name name n ccc NULL NULL diff --git a/mysql-test/main/select_pkeycache.result b/mysql-test/main/select_pkeycache.result index af65ca169d6..bf19d5e9b4e 100644 --- a/mysql-test/main/select_pkeycache.result +++ b/mysql-test/main/select_pkeycache.result @@ -2407,7 +2407,7 @@ insert into t2 values (1,3), (2,3), (3,4), (4,4); explain select * from t1 left join t2 on a=c where d in (4); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref c,d d 5 const 2 Using where -1 SIMPLE t1 ref a a 5 test.t2.c 2 +1 SIMPLE t1 ref a a 5 test.t2.c 1 select * from t1 left join t2 on a=c where d in (4); a b c d 3 2 3 4 @@ -2415,7 +2415,7 @@ a b c d explain select * from t1 left join t2 on a=c where d = 4; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref c,d d 5 const 2 Using where -1 SIMPLE t1 ref a a 5 test.t2.c 2 +1 SIMPLE t1 ref a a 5 test.t2.c 1 select * from t1 left join t2 on a=c where d = 4; a b c d 3 2 3 4 @@ -2442,11 +2442,11 @@ INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref a a 23 test.t1.a 2 Using where +1 SIMPLE t2 ref a a 23 test.t1.a 1 Using where EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref a a 23 test.t1.a 2 Using where +1 SIMPLE t2 ref a a 23 test.t1.a 1 Using where DROP TABLE t1, t2; CREATE TABLE t1 ( city char(30) ); INSERT INTO t1 VALUES ('London'); @@ -3926,7 +3926,7 @@ cc 3 7 EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref name name 6 test.t1.name 2 Using where +1 SIMPLE t2 ref name name 6 test.t1.name 1 Using where SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; name name n ccc NULL NULL @@ -4019,7 +4019,7 @@ cc 3 7 EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 -1 SIMPLE t2 ref name name 6 test.t1.name 2 Using where +1 SIMPLE t2 ref name name 6 test.t1.name 1 Using where SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; name name n ccc NULL NULL diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result index 4514a35e7e7..ef21df2cfcd 100644 --- a/mysql-test/main/selectivity.result +++ b/mysql-test/main/selectivity.result @@ -755,7 +755,7 @@ EXPLAIN EXTENDED SELECT * FROM v1 INNER JOIN t2 ON ( a = c AND b = d ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where -1 SIMPLE t2 ref idx idx 5 test.t1.b 2 100.00 Using where +1 SIMPLE t2 ref idx idx 5 test.t1.b 1 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`c` = `test`.`t1`.`a` and `test`.`t2`.`d` = `test`.`t1`.`b` SELECT * FROM v1 INNER JOIN t2 ON ( a = c AND b = d ); diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result index b3d69a547d1..77d80405b3b 100644 --- a/mysql-test/main/subselect.result +++ b/mysql-test/main/subselect.result @@ -345,7 +345,7 @@ patient_uq clinic_uq explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t7 index PRIMARY PRIMARY 4 NULL 2 100.00 Using index -1 PRIMARY t6 ref i1 i1 5 test.t7.uq 2 100.00 +1 PRIMARY t6 ref i1 i1 5 test.t7.uq 1 100.00 Warnings: Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t7` join `test`.`t6` where `test`.`t6`.`clinic_uq` = `test`.`t7`.`uq` @@ -4408,7 +4408,7 @@ CREATE INDEX I2 ON t1 (b); EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan -1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition +1 PRIMARY t1 ref I2 I2 13 test.t1.a 1 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); a b CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)); @@ -4418,14 +4418,14 @@ CREATE INDEX I2 ON t2 (b); EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 index I1 I1 4 NULL 2 Using where; Using index; LooseScan -1 PRIMARY t2 ref I2 I2 13 test.t2.a 2 Using index condition +1 PRIMARY t2 ref I2 I2 13 test.t2.a 1 Using index condition SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); a b EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan -1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition +1 PRIMARY t1 ref I2 I2 13 test.t1.a 1 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); a b DROP TABLE t1,t2; @@ -6657,7 +6657,7 @@ SET @@optimizer_switch='semijoin=off,materialization=off,in_to_exists=on,subquer EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index -2 DEPENDENT SUBQUERY t1 index_subquery a a 4 func 2 Using index +2 DEPENDENT SUBQUERY t1 index_subquery a a 4 func 1 Using index SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1); a 2009-01-01 @@ -6860,7 +6860,7 @@ FROM t1 AS alias1, t1 AS alias2, t1 AS alias3 WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 index a a 19 NULL 11 Using where; Using index -1 PRIMARY alias2 ref a a 19 test.alias1.a 2 Using index +1 PRIMARY alias2 ref a a 19 test.alias1.a 1 Using index 1 PRIMARY alias3 index NULL a 19 NULL 11 Using index; Using join buffer (flat, BNL join) 2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where SELECT MAX( alias2.a ) @@ -7011,7 +7011,7 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t2 ALL b NULL NULL NULL 2 Using where -1 PRIMARY t3 ref d d 5 test.t2.b 2 Using index +1 PRIMARY t3 ref d d 5 test.t2.b 1 Using index 3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away set @tmp_mdev410=@@global.userstat; set global userstat=on; @@ -7043,7 +7043,7 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP B id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index +2 SUBQUERY t2 ref b b 5 test.t1.a 1 Using index DROP TABLE t1,t2; # # MDEV-435: Expensive subqueries may be evaluated during optimization in merge_key_fields @@ -7077,7 +7077,7 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP B id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index +2 SUBQUERY t2 ref b b 5 test.t1.a 1 Using index DROP TABLE t1,t2; # # MDEV-5991: crash in Item_field::used_tables diff --git a/mysql-test/main/subselect2.result b/mysql-test/main/subselect2.result index 1af4328aecc..0d2f7372887 100644 --- a/mysql-test/main/subselect2.result +++ b/mysql-test/main/subselect2.result @@ -162,7 +162,7 @@ EXPLAIN SELECT * FROM t2,t3 WHERE (2,9) IN (SELECT DISTINCT a,pk FROM t1) OR a = b; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 index a a 5 NULL 2 Using where; Using index -1 PRIMARY t3 ref b b 5 test.t2.a 2 Using index +1 PRIMARY t3 ref b b 5 test.t2.a 1 Using index 2 SUBQUERY t1 const PRIMARY,a a 9 const,const 1 Using where; Using index SELECT * FROM t2,t3 WHERE (2,9) IN (SELECT DISTINCT a,pk FROM t1) OR a = b; pk a b @@ -171,7 +171,7 @@ EXPLAIN SELECT * FROM t2,t3 WHERE (2,9) IN (SELECT DISTINCT a,pk FROM v1) OR a = b; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 index a a 5 NULL 2 Using where; Using index -1 PRIMARY t3 ref b b 5 test.t2.a 2 Using index +1 PRIMARY t3 ref b b 5 test.t2.a 1 Using index 2 SUBQUERY t1 const PRIMARY,a a 9 const,const 1 Using where; Using index SELECT * FROM t2,t3 WHERE (2,9) IN (SELECT DISTINCT a,pk FROM v1) OR a = b; pk a b @@ -339,7 +339,7 @@ where t1.a = t2.a and ( t1.a = ( select min(a) from t1 ) or 0 ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) -1 PRIMARY t3 ref idx idx 6 func 2 100.00 Using where; Using index +1 PRIMARY t3 ref idx idx 6 func 1 100.00 Using where; Using index 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t1`.`a`) where `test`.`t1`.`a` = (/* select#2 */ select min(`test`.`t1`.`a`) from `test`.`t1`) and `test`.`t2`.`a` = (/* select#2 */ select min(`test`.`t1`.`a`) from `test`.`t1`) diff --git a/mysql-test/main/subselect3.result b/mysql-test/main/subselect3.result index c41b3e3c48f..e8e91ec2cc2 100644 --- a/mysql-test/main/subselect3.result +++ b/mysql-test/main/subselect3.result @@ -193,7 +193,7 @@ t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z from t3; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 -2 DEPENDENT SUBQUERY t1 ref a a 4 func 2 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t1 ref a a 4 func 1 100.00 Using where; Full scan on NULL key 2 DEPENDENT SUBQUERY t2 ref a a 4 test.t1.b 1 100.00 Using where Warnings: Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1 diff --git a/mysql-test/main/subselect3_jcl6.result b/mysql-test/main/subselect3_jcl6.result index 13f61b7d101..4fc6f713088 100644 --- a/mysql-test/main/subselect3_jcl6.result +++ b/mysql-test/main/subselect3_jcl6.result @@ -196,7 +196,7 @@ t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z from t3; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 -2 DEPENDENT SUBQUERY t1 ref a a 4 func 2 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t1 ref a a 4 func 1 100.00 Using where; Full scan on NULL key 2 DEPENDENT SUBQUERY t2 ref a a 4 test.t1.b 1 100.00 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan Warnings: Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1 diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index c4e945c2d10..382e4044081 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -265,7 +265,7 @@ EXPLAIN SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2c.i FROM t2c WHERE t2c.pk = t1.pk); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where -2 DEPENDENT SUBQUERY t2c index_subquery it2c it2c 8 const,test.t1.pk 2 Using index; Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2c index_subquery it2c it2c 8 const,test.t1.pk 1 Using index; Using where; Full scan on NULL key SELECT * FROM t1 WHERE NULL NOT IN (SELECT t2c.i FROM t2c WHERE t2c.pk = t1.pk); pk i SELECT * FROM t1 WHERE NULL IN (SELECT t2c.i FROM t2c WHERE t2c.pk = t1.pk) IS UNKNOWN; @@ -335,7 +335,7 @@ EXPLAIN SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2c.i, t2c.pk FROM t2c WHERE t2c.pk = t1.pk); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where -2 DEPENDENT SUBQUERY t2c index_subquery it2c it2c 8 const,test.t1.pk 2 Using index; Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2c index_subquery it2c it2c 8 const,test.t1.pk 1 Using index; Using where; Full scan on NULL key SELECT * FROM t1 WHERE (NULL, 1) NOT IN (SELECT t2c.i, t2c.pk FROM t2c WHERE t2c.pk = t1.pk); pk i 0 10 @@ -1170,7 +1170,7 @@ WHERE (t2.pk = t1.pk) AND t2.pk IN (SELECT f2 FROM t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 system PRIMARY NULL NULL NULL 1 1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1 -2 DEPENDENT SUBQUERY t1 index_subquery f2 f2 4 func 2 Using index +2 DEPENDENT SUBQUERY t1 index_subquery f2 f2 4 func 1 Using index SELECT t1.f3, MAX(t1.f2) FROM t1, t2 WHERE (t2.pk = t1.pk) AND t2.pk IN (SELECT f2 FROM t1); @@ -2797,7 +2797,7 @@ EXPLAIN SELECT * FROM t2 WHERE (t2.a,t2.b) IN (('abc',1), ('def', 2)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where -1 PRIMARY <derived3> ref key1 key1 4 test.t2.b 2 Using where; FirstMatch(t2) +1 PRIMARY <derived3> ref key1 key1 4 test.t2.b 1 Using where; FirstMatch(t2) 3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used set names default; set @@in_predicate_conversion_threshold= @save_in_predicate_conversion_threshold; diff --git a/mysql-test/main/subselect_exists2in.result b/mysql-test/main/subselect_exists2in.result index 45655afe662..f6a4365f522 100644 --- a/mysql-test/main/subselect_exists2in.result +++ b/mysql-test/main/subselect_exists2in.result @@ -52,7 +52,7 @@ explain extended SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t3 WHERE t3.b = t1.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index aa aa 4 NULL 2 100.00 Using where; Using index -1 PRIMARY t3 ref bb bb 4 test.t1.a 2 50.00 FirstMatch(t1) +1 PRIMARY t3 ref bb bb 4 test.t1.a 1 100.00 FirstMatch(t1) Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where `test`.`t3`.`b` = `test`.`t1`.`a` @@ -65,7 +65,7 @@ explain extended SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t3 WHERE t3.b = t1.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL aa 4 NULL 2 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t3 index_subquery bb bb 4 func 2 100.00 +2 DEPENDENT SUBQUERY t3 index_subquery bb bb 4 func 1 100.00 Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t3 on bb))) @@ -91,7 +91,7 @@ explain extended SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t3 WHERE t3.b = t1.a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL aa 4 NULL 2 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t3 ref bb bb 4 test.t1.a 2 100.00 +2 DEPENDENT SUBQUERY t3 ref bb bb 4 test.t1.a 1 100.00 Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(/* select#2 */ select `test`.`t3`.`a` from `test`.`t3` where `test`.`t3`.`b` = `test`.`t1`.`a` limit 1) @@ -391,7 +391,7 @@ explain extended SELECT * FROM t1 WHERE EXISTS ( SELECT * FROM t3 WHERE t3.b = t1.a and t3.b1 = t1.a1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 index bb bb 8 NULL 2 100.00 Using where; Using index; LooseScan -1 PRIMARY t1 ref aa aa 8 test.t3.b,test.t3.b1 2 50.00 Using index +1 PRIMARY t1 ref aa aa 8 test.t3.b,test.t3.b1 1 50.00 Using index Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.a1' of SELECT #2 was resolved in SELECT #1 @@ -405,7 +405,7 @@ explain extended SELECT * FROM t1 WHERE EXISTS ( SELECT * FROM t3 WHERE t3.b = t1.a and t3.b1 = t1.a1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL aa 8 NULL 2 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t3 index_subquery bb bb 8 func,func 2 100.00 Using index; Using where +2 DEPENDENT SUBQUERY t3 index_subquery bb bb 8 func,func 1 100.00 Using index; Using where Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.a1' of SELECT #2 was resolved in SELECT #1 @@ -433,7 +433,7 @@ explain extended SELECT * FROM t1 WHERE EXISTS ( SELECT * FROM t3 WHERE t3.b = t1.a and t3.b1 = t1.a1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL aa 8 NULL 2 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t3 ref bb bb 8 test.t1.a,test.t1.a1 2 100.00 Using index +2 DEPENDENT SUBQUERY t3 ref bb bb 8 test.t1.a,test.t1.a1 1 100.00 Using index Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.a1' of SELECT #2 was resolved in SELECT #1 diff --git a/mysql-test/main/subselect_extra.result b/mysql-test/main/subselect_extra.result index 057d05e0038..378e8dafd4b 100644 --- a/mysql-test/main/subselect_extra.result +++ b/mysql-test/main/subselect_extra.result @@ -393,7 +393,7 @@ EXPLAIN SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1) +1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 1 FirstMatch(t1) 3 DERIVED t2 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort SELECT * FROM v2; a b @@ -474,7 +474,7 @@ EXPLAIN SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -1 PRIMARY <derived3> ref key0 key0 10 test.t1.b,test.t1.a 2 FirstMatch(t1) +1 PRIMARY <derived3> ref key0 key0 10 test.t1.b,test.t1.a 1 FirstMatch(t1) 3 DERIVED t2 ALL NULL NULL NULL NULL 2 SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); a b diff --git a/mysql-test/main/subselect_extra_no_semijoin.result b/mysql-test/main/subselect_extra_no_semijoin.result index faeaf75c590..e4d38719ff2 100644 --- a/mysql-test/main/subselect_extra_no_semijoin.result +++ b/mysql-test/main/subselect_extra_no_semijoin.result @@ -395,7 +395,7 @@ EXPLAIN SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 10 func,func 2 Using where +2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 10 func,func 1 Using where 3 DERIVED t2 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort SELECT * FROM v2; a b @@ -476,7 +476,7 @@ EXPLAIN SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY <derived3> ref key0 key0 5 test.t1.a 2 Using where +2 DEPENDENT SUBQUERY <derived3> ref key0 key0 5 test.t1.a 1 Using where 3 DERIVED t2 ALL NULL NULL NULL NULL 2 SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); a b diff --git a/mysql-test/main/subselect_mat.result b/mysql-test/main/subselect_mat.result index d939078c897..3d7f6d601b6 100644 --- a/mysql-test/main/subselect_mat.result +++ b/mysql-test/main/subselect_mat.result @@ -1895,7 +1895,7 @@ WHERE alias4.c = alias3.b id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3 MATERIALIZED alias3 ALL NULL NULL NULL NULL 2 Using where -3 MATERIALIZED alias4 ref c c 11 test.alias3.b 2 Using where; Using index +3 MATERIALIZED alias4 ref c c 11 test.alias3.b 1 Using where; Using index DROP TABLE t1,t2; # # BUG#928048: Query containing IN subquery with OR in the where clause returns a wrong result @@ -2283,7 +2283,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch 2 DEPENDENT SUBQUERY t2 range i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY t3 ref i3 i3 5 test.t2.i2 2 100.00 Using index +2 DEPENDENT SUBQUERY t3 ref i3 i3 5 test.t2.i2 1 100.00 Using index Warnings: Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where <expr_cache><`test`.`t1`.`f1`>(exists(/* select#2 */ select 1 from `test`.`t2` semi join (`test`.`t3`) join `test`.`t3` where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t1`.`f1` = `test`.`t3`.`f3` limit 1)) diff --git a/mysql-test/main/subselect_mat_cost.result b/mysql-test/main/subselect_mat_cost.result index 9bed355968a..240332f3c5b 100644 --- a/mysql-test/main/subselect_mat_cost.result +++ b/mysql-test/main/subselect_mat_cost.result @@ -510,7 +510,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY Country index PRIMARY PRIMARY 3 NULL 239 Using index; Using temporary; Using filesort 1 PRIMARY City ref Country Country 3 world.Country.Code 17 2 MATERIALIZED Country ALL Name NULL NULL NULL 239 Using where -Last_query_cost 7.951232 +Last_query_cost 7.972882 EXPLAIN SELECT City.Name, City.Population FROM Country LEFT JOIN City ON City.Country = Country.Code @@ -520,7 +520,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY Country index NULL PRIMARY 3 NULL 239 Using index; Using temporary; Using filesort 1 PRIMARY City ref Country Country 3 world.Country.Code 17 2 MATERIALIZED Country ALL Name NULL NULL NULL 239 Using where -Last_query_cost 7.951232 +Last_query_cost 7.972882 SELECT City.Name, City.Population FROM City JOIN Country ON City.Country = Country.Code GROUP BY City.Name diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result index 9076f05fc08..3a144e70c75 100644 --- a/mysql-test/main/subselect_no_exists_to_in.result +++ b/mysql-test/main/subselect_no_exists_to_in.result @@ -4411,7 +4411,7 @@ CREATE INDEX I2 ON t1 (b); EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan -1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition +1 PRIMARY t1 ref I2 I2 13 test.t1.a 1 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); a b CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)); @@ -4421,14 +4421,14 @@ CREATE INDEX I2 ON t2 (b); EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 index I1 I1 4 NULL 2 Using where; Using index; LooseScan -1 PRIMARY t2 ref I2 I2 13 test.t2.a 2 Using index condition +1 PRIMARY t2 ref I2 I2 13 test.t2.a 1 Using index condition SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); a b EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan -1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition +1 PRIMARY t1 ref I2 I2 13 test.t1.a 1 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); a b DROP TABLE t1,t2; @@ -6659,7 +6659,7 @@ SET @@optimizer_switch='semijoin=off,materialization=off,in_to_exists=on,subquer EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index -2 DEPENDENT SUBQUERY t1 index_subquery a a 4 func 2 Using index +2 DEPENDENT SUBQUERY t1 index_subquery a a 4 func 1 Using index SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1); a 2009-01-01 @@ -6862,7 +6862,7 @@ FROM t1 AS alias1, t1 AS alias2, t1 AS alias3 WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 index a a 19 NULL 11 Using where; Using index -1 PRIMARY alias2 ref a a 19 test.alias1.a 2 Using index +1 PRIMARY alias2 ref a a 19 test.alias1.a 1 Using index 1 PRIMARY alias3 index NULL a 19 NULL 11 Using index; Using join buffer (flat, BNL join) 2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where SELECT MAX( alias2.a ) @@ -7013,7 +7013,7 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t2 ALL b NULL NULL NULL 2 Using where -1 PRIMARY t3 ref d d 5 test.t2.b 2 Using index +1 PRIMARY t3 ref d d 5 test.t2.b 1 Using index 3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away set @tmp_mdev410=@@global.userstat; set global userstat=on; @@ -7045,7 +7045,7 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP B id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index +2 SUBQUERY t2 ref b b 5 test.t1.a 1 Using index DROP TABLE t1,t2; # # MDEV-435: Expensive subqueries may be evaluated during optimization in merge_key_fields @@ -7079,7 +7079,7 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP B id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index +2 SUBQUERY t2 ref b b 5 test.t1.a 1 Using index DROP TABLE t1,t2; # # MDEV-5991: crash in Item_field::used_tables diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result index ad5ead75ccb..12c72545f73 100644 --- a/mysql-test/main/subselect_no_mat.result +++ b/mysql-test/main/subselect_no_mat.result @@ -352,7 +352,7 @@ patient_uq clinic_uq explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t7 index PRIMARY PRIMARY 4 NULL 2 100.00 Using index -1 PRIMARY t6 ref i1 i1 5 test.t7.uq 2 100.00 +1 PRIMARY t6 ref i1 i1 5 test.t7.uq 1 100.00 Warnings: Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t7` join `test`.`t6` where `test`.`t6`.`clinic_uq` = `test`.`t7`.`uq` @@ -4411,7 +4411,7 @@ CREATE INDEX I2 ON t1 (b); EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan -1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition +1 PRIMARY t1 ref I2 I2 13 test.t1.a 1 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); a b CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)); @@ -4421,14 +4421,14 @@ CREATE INDEX I2 ON t2 (b); EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 index I1 I1 4 NULL 2 Using where; Using index; LooseScan -1 PRIMARY t2 ref I2 I2 13 test.t2.a 2 Using index condition +1 PRIMARY t2 ref I2 I2 13 test.t2.a 1 Using index condition SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); a b EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan -1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition +1 PRIMARY t1 ref I2 I2 13 test.t1.a 1 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); a b DROP TABLE t1,t2; @@ -6656,7 +6656,7 @@ SET @@optimizer_switch='semijoin=off,materialization=off,in_to_exists=on,subquer EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index -2 DEPENDENT SUBQUERY t1 index_subquery a a 4 func 2 Using index +2 DEPENDENT SUBQUERY t1 index_subquery a a 4 func 1 Using index SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1); a 2009-01-01 @@ -6859,7 +6859,7 @@ FROM t1 AS alias1, t1 AS alias2, t1 AS alias3 WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 index a a 19 NULL 11 Using where; Using index -1 PRIMARY alias2 ref a a 19 test.alias1.a 2 Using index +1 PRIMARY alias2 ref a a 19 test.alias1.a 1 Using index 1 PRIMARY alias3 index NULL a 19 NULL 11 Using index; Using join buffer (flat, BNL join) 2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where SELECT MAX( alias2.a ) @@ -7009,7 +7009,7 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t2 ALL b NULL NULL NULL 2 Using where -1 PRIMARY t3 ref d d 5 test.t2.b 2 Using index +1 PRIMARY t3 ref d d 5 test.t2.b 1 Using index 3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away set @tmp_mdev410=@@global.userstat; set global userstat=on; @@ -7041,7 +7041,7 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP B id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index +2 SUBQUERY t2 ref b b 5 test.t1.a 1 Using index DROP TABLE t1,t2; # # MDEV-435: Expensive subqueries may be evaluated during optimization in merge_key_fields @@ -7074,7 +7074,7 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP B id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index +2 SUBQUERY t2 ref b b 5 test.t1.a 1 Using index DROP TABLE t1,t2; # # MDEV-5991: crash in Item_field::used_tables diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result index 1d51bd6b976..f9561178ca5 100644 --- a/mysql-test/main/subselect_no_opts.result +++ b/mysql-test/main/subselect_no_opts.result @@ -1509,7 +1509,7 @@ explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1 id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t1 ref a a 5 func 1001 100.00 Using index -2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 66.67 Using where; Using index; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 33.33 Using where; Using index; Using join buffer (flat, BNL join) Warnings: Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`b` and <cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)) select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); @@ -4407,7 +4407,7 @@ CREATE INDEX I2 ON t1 (b); EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 2 Using index; Using where +2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 1 Using index; Using where SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); a b CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)); @@ -4417,14 +4417,14 @@ CREATE INDEX I2 ON t2 (b); EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY t2 index_subquery I1 I1 4 func 2 Using index; Using where +2 DEPENDENT SUBQUERY t2 index_subquery I1 I1 4 func 1 Using index; Using where SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); a b EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 2 Using index; Using where +2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 1 Using index; Using where SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); a b DROP TABLE t1,t2; @@ -6096,7 +6096,7 @@ WHERE col_varchar_nokey IN (SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ot system NULL NULL NULL NULL 1 -2 DEPENDENT SUBQUERY it1 index_subquery idx_cvk_cik idx_cvk_cik 9 func,const 2 Using index; Using where +2 DEPENDENT SUBQUERY it1 index_subquery idx_cvk_cik idx_cvk_cik 9 func,const 1 Using index; Using where SELECT col_int_nokey FROM ot WHERE col_varchar_nokey IN (SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL); @@ -6652,7 +6652,7 @@ SET @@optimizer_switch='semijoin=off,materialization=off,in_to_exists=on,subquer EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index -2 DEPENDENT SUBQUERY t1 index_subquery a a 4 func 2 Using index +2 DEPENDENT SUBQUERY t1 index_subquery a a 4 func 1 Using index SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1); a 2009-01-01 @@ -6855,7 +6855,7 @@ FROM t1 AS alias1, t1 AS alias2, t1 AS alias3 WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 index a a 19 NULL 11 Using where; Using index -1 PRIMARY alias2 ref a a 19 test.alias1.a 2 Using index +1 PRIMARY alias2 ref a a 19 test.alias1.a 1 Using index 1 PRIMARY alias3 index NULL a 19 NULL 11 Using index; Using join buffer (flat, BNL join) 2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where SELECT MAX( alias2.a ) @@ -7006,7 +7006,7 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t2 ALL b NULL NULL NULL 2 Using where -1 PRIMARY t3 ref d d 5 test.t2.b 2 Using index +1 PRIMARY t3 ref d d 5 test.t2.b 1 Using index 3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away set @tmp_mdev410=@@global.userstat; set global userstat=on; @@ -7038,7 +7038,7 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP B id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index +2 SUBQUERY t2 ref b b 5 test.t1.a 1 Using index DROP TABLE t1,t2; # # MDEV-435: Expensive subqueries may be evaluated during optimization in merge_key_fields @@ -7072,7 +7072,7 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP B id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index +2 SUBQUERY t2 ref b b 5 test.t1.a 1 Using index DROP TABLE t1,t2; # # MDEV-5991: crash in Item_field::used_tables diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result index 18be05fe527..8083057eddf 100644 --- a/mysql-test/main/subselect_no_scache.result +++ b/mysql-test/main/subselect_no_scache.result @@ -351,7 +351,7 @@ patient_uq clinic_uq explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t7 index PRIMARY PRIMARY 4 NULL 2 100.00 Using index -1 PRIMARY t6 ref i1 i1 5 test.t7.uq 2 100.00 +1 PRIMARY t6 ref i1 i1 5 test.t7.uq 1 100.00 Warnings: Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t7` join `test`.`t6` where `test`.`t6`.`clinic_uq` = `test`.`t7`.`uq` @@ -4414,7 +4414,7 @@ CREATE INDEX I2 ON t1 (b); EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan -1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition +1 PRIMARY t1 ref I2 I2 13 test.t1.a 1 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); a b CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)); @@ -4424,14 +4424,14 @@ CREATE INDEX I2 ON t2 (b); EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 index I1 I1 4 NULL 2 Using where; Using index; LooseScan -1 PRIMARY t2 ref I2 I2 13 test.t2.a 2 Using index condition +1 PRIMARY t2 ref I2 I2 13 test.t2.a 1 Using index condition SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); a b EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan -1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition +1 PRIMARY t1 ref I2 I2 13 test.t1.a 1 Using index condition SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); a b DROP TABLE t1,t2; @@ -6663,7 +6663,7 @@ SET @@optimizer_switch='semijoin=off,materialization=off,in_to_exists=on,subquer EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index -2 DEPENDENT SUBQUERY t1 index_subquery a a 4 func 2 Using index +2 DEPENDENT SUBQUERY t1 index_subquery a a 4 func 1 Using index SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1); a 2009-01-01 @@ -6866,7 +6866,7 @@ FROM t1 AS alias1, t1 AS alias2, t1 AS alias3 WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 index a a 19 NULL 11 Using where; Using index -1 PRIMARY alias2 ref a a 19 test.alias1.a 2 Using index +1 PRIMARY alias2 ref a a 19 test.alias1.a 1 Using index 1 PRIMARY alias3 index NULL a 19 NULL 11 Using index; Using join buffer (flat, BNL join) 2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where SELECT MAX( alias2.a ) @@ -7017,7 +7017,7 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t2 ALL b NULL NULL NULL 2 Using where -1 PRIMARY t3 ref d d 5 test.t2.b 2 Using index +1 PRIMARY t3 ref d d 5 test.t2.b 1 Using index 3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away set @tmp_mdev410=@@global.userstat; set global userstat=on; @@ -7049,7 +7049,7 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP B id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index +2 SUBQUERY t2 ref b b 5 test.t1.a 1 Using index DROP TABLE t1,t2; # # MDEV-435: Expensive subqueries may be evaluated during optimization in merge_key_fields @@ -7083,7 +7083,7 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP B id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index +2 SUBQUERY t2 ref b b 5 test.t1.a 1 Using index DROP TABLE t1,t2; # # MDEV-5991: crash in Item_field::used_tables diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result index d56be525db6..19dae33c5c1 100644 --- a/mysql-test/main/subselect_no_semijoin.result +++ b/mysql-test/main/subselect_no_semijoin.result @@ -929,7 +929,7 @@ explain extended SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) F id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 2 MATERIALIZED t3 ALL NULL NULL NULL NULL 3 100.00 Using where -2 MATERIALIZED t2 ref a a 5 test.t3.a 2 100.00 Using index +2 MATERIALIZED t2 ref a a 5 test.t3.a 1 100.00 Using index Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where `test`.`t2`.`a` = `test`.`t3`.`a` ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` drop table t1,t2,t3; @@ -1509,7 +1509,7 @@ explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1 id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t1 ref a a 5 func 1001 100.00 Using index -2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 66.67 Using where; Using index; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 33.33 Using where; Using index; Using join buffer (flat, BNL join) Warnings: Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`b` and <cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))) select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); @@ -4407,7 +4407,7 @@ CREATE INDEX I2 ON t1 (b); EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 2 Using index; Using where +2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 1 Using index; Using where SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); a b CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)); @@ -4417,14 +4417,14 @@ CREATE INDEX I2 ON t2 (b); EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY t2 index_subquery I1 I1 4 func 2 Using index; Using where +2 DEPENDENT SUBQUERY t2 index_subquery I1 I1 4 func 1 Using index; Using where SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); a b EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 2 Using index; Using where +2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 1 Using index; Using where SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); a b DROP TABLE t1,t2; @@ -6096,7 +6096,7 @@ WHERE col_varchar_nokey IN (SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ot system NULL NULL NULL NULL 1 -2 DEPENDENT SUBQUERY it1 index_subquery idx_cvk_cik idx_cvk_cik 9 func,const 2 Using index; Using where +2 DEPENDENT SUBQUERY it1 index_subquery idx_cvk_cik idx_cvk_cik 9 func,const 1 Using index; Using where SELECT col_int_nokey FROM ot WHERE col_varchar_nokey IN (SELECT col_varchar_key FROM it1 WHERE col_int_key IS NULL); @@ -6652,7 +6652,7 @@ SET @@optimizer_switch='semijoin=off,materialization=off,in_to_exists=on,subquer EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index -2 DEPENDENT SUBQUERY t1 index_subquery a a 4 func 2 Using index +2 DEPENDENT SUBQUERY t1 index_subquery a a 4 func 1 Using index SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1); a 2009-01-01 @@ -6855,7 +6855,7 @@ FROM t1 AS alias1, t1 AS alias2, t1 AS alias3 WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 index a a 19 NULL 11 Using where; Using index -1 PRIMARY alias2 ref a a 19 test.alias1.a 2 Using index +1 PRIMARY alias2 ref a a 19 test.alias1.a 1 Using index 1 PRIMARY alias3 index NULL a 19 NULL 11 Using index; Using join buffer (flat, BNL join) 2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where SELECT MAX( alias2.a ) @@ -7006,7 +7006,7 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t2 ALL b NULL NULL NULL 2 Using where -1 PRIMARY t3 ref d d 5 test.t2.b 2 Using index +1 PRIMARY t3 ref d d 5 test.t2.b 1 Using index 3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away set @tmp_mdev410=@@global.userstat; set global userstat=on; @@ -7038,7 +7038,7 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP B id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index +2 SUBQUERY t2 ref b b 5 test.t1.a 1 Using index DROP TABLE t1,t2; # # MDEV-435: Expensive subqueries may be evaluated during optimization in merge_key_fields @@ -7072,7 +7072,7 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP B id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index -2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index +2 SUBQUERY t2 ref b b 5 test.t1.a 1 Using index DROP TABLE t1,t2; # # MDEV-5991: crash in Item_field::used_tables diff --git a/mysql-test/main/subselect_sj.result b/mysql-test/main/subselect_sj.result index 677bdfb5ec7..3174b76e177 100644 --- a/mysql-test/main/subselect_sj.result +++ b/mysql-test/main/subselect_sj.result @@ -502,7 +502,7 @@ EXPLAIN EXTENDED SELECT vkey FROM t0 WHERE pk IN id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t0 ALL PRIMARY NULL NULL NULL 5 100.00 1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where -1 PRIMARY t2 ref vkey vkey 4 test.t1.vnokey 2 50.00 Using index; FirstMatch(t1) +1 PRIMARY t2 ref vkey vkey 4 test.t1.vnokey 1 100.00 Using index; FirstMatch(t1) Warnings: Note 1003 select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` semi join (`test`.`t0` `t2`) join `test`.`t0` where `test`.`t1`.`pk` = `test`.`t0`.`pk` and `test`.`t2`.`vkey` = `test`.`t1`.`vnokey` SELECT vkey FROM t0 WHERE pk IN @@ -2154,7 +2154,7 @@ explain SELECT * FROM t1, t2 WHERE (t2.a , t1.b) IN (SELECT a, b FROM t3); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -1 PRIMARY t3 ref b b 5 test.t1.b 2 Using where; Start temporary +1 PRIMARY t3 ref b b 5 test.t1.b 1 Using where; Start temporary 1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t3.a 1 Using index; End temporary SELECT * FROM t1, t2 WHERE (t2.a , t1.b) IN (SELECT a, b FROM t3); b a @@ -2179,7 +2179,7 @@ explain SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t5 index a a 10 NULL 2 Using where; Using index; Start temporary -1 PRIMARY t2 ref b b 5 test.t5.b 2 Using where +1 PRIMARY t2 ref b b 5 test.t5.b 1 Using where 1 PRIMARY t4 ALL NULL NULL NULL NULL 3 1 PRIMARY t3 ALL NULL NULL NULL NULL 15 Using where; End temporary; Using join buffer (flat, BNL join) SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); @@ -2436,9 +2436,9 @@ SET SESSION optimizer_switch='loosescan=off'; EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY t2 range idx idx 4 NULL 2 Using where; Using index -1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index; FirstMatch(t1) +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where +1 PRIMARY t3 range idx idx 4 NULL 2 Using where; Using index +1 PRIMARY t2 ref idx idx 9 test.t3.b,test.t1.a 1 Using index; FirstMatch(t1) SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); a 5 @@ -2446,9 +2446,9 @@ SET SESSION optimizer_switch='loosescan=on'; EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY t2 range idx idx 4 NULL 2 Using where; Using index -1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index; FirstMatch(t1) +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where +1 PRIMARY t3 range idx idx 4 NULL 2 Using where; Using index +1 PRIMARY t2 ref idx idx 9 test.t3.b,test.t1.a 1 Using index; FirstMatch(t1) SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); a 5 @@ -2561,7 +2561,7 @@ INSERT INTO t1 VALUES (6,3),(7,1),(8,4),(9,3),(10,2); CREATE TABLE t2 ( c INT, d INT, KEY(c) ); INSERT INTO t2 VALUES -(1,2),(2,1),(3,3),(4,2),(5,5),(6,3),(7,1); +(1,2),(2,1),(3,3),(4,2),(5,5),(6,3),(7,1),(11,11); analyze table t1,t2; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected @@ -2571,15 +2571,15 @@ test.t2 analyze status OK explain SELECT a, b, d FROM t1, t2 WHERE ( b, d ) IN -( SELECT b, d FROM t1, t2 WHERE b = c ); +( SELECT b, d FROM t1 as t3, t2 as t4 WHERE b = c ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index b b 5 NULL 10 Using where; Using index; Start temporary -1 PRIMARY t2 ref c c 5 test.t1.b 1 +1 PRIMARY t3 index b b 5 NULL 10 Using where; Using index; Start temporary +1 PRIMARY t4 ref c c 5 test.t3.b 1 1 PRIMARY t1 ALL b NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) -1 PRIMARY t2 ALL NULL NULL NULL NULL 7 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 8 Using where; End temporary; Using join buffer (flat, BNL join) SELECT a, b, d FROM t1, t2 WHERE ( b, d ) IN -( SELECT b, d FROM t1, t2 WHERE b = c ); +( SELECT b, d FROM t1 as t3, t2 as t4 WHERE b = c ); a b d 1 2 1 1 2 1 @@ -2768,7 +2768,7 @@ WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_1 ALL NULL NULL NULL NULL 11 Using where 1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 -1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 2 Using where; FirstMatch(t1_2) +1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 1 Using where; FirstMatch(t1_2) 3 DERIVED t1 ALL NULL NULL NULL NULL 11 SELECT * FROM t1 AS t1_1, t1 AS t1_2 WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 ); diff --git a/mysql-test/main/subselect_sj.test b/mysql-test/main/subselect_sj.test index ed2d7c99ec2..3c046c6321c 100644 --- a/mysql-test/main/subselect_sj.test +++ b/mysql-test/main/subselect_sj.test @@ -2292,17 +2292,17 @@ INSERT INTO t1 VALUES CREATE TABLE t2 ( c INT, d INT, KEY(c) ); INSERT INTO t2 VALUES - (1,2),(2,1),(3,3),(4,2),(5,5),(6,3),(7,1); + (1,2),(2,1),(3,3),(4,2),(5,5),(6,3),(7,1),(11,11); analyze table t1,t2; explain SELECT a, b, d FROM t1, t2 WHERE ( b, d ) IN - ( SELECT b, d FROM t1, t2 WHERE b = c ); + ( SELECT b, d FROM t1 as t3, t2 as t4 WHERE b = c ); --sorted_result SELECT a, b, d FROM t1, t2 WHERE ( b, d ) IN - ( SELECT b, d FROM t1, t2 WHERE b = c ); + ( SELECT b, d FROM t1 as t3, t2 as t4 WHERE b = c ); DROP TABLE t1, t2; diff --git a/mysql-test/main/subselect_sj_jcl6.result b/mysql-test/main/subselect_sj_jcl6.result index b416ae210bf..79c05e49e31 100644 --- a/mysql-test/main/subselect_sj_jcl6.result +++ b/mysql-test/main/subselect_sj_jcl6.result @@ -513,7 +513,7 @@ EXPLAIN EXTENDED SELECT vkey FROM t0 WHERE pk IN id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t0 ALL PRIMARY NULL NULL NULL 5 100.00 1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 PRIMARY t2 ref vkey vkey 4 test.t1.vnokey 2 50.00 Using index; FirstMatch(t1) +1 PRIMARY t2 ref vkey vkey 4 test.t1.vnokey 1 100.00 Using index; FirstMatch(t1) Warnings: Note 1003 select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` semi join (`test`.`t0` `t2`) join `test`.`t0` where `test`.`t1`.`pk` = `test`.`t0`.`pk` and `test`.`t2`.`vkey` = `test`.`t1`.`vnokey` SELECT vkey FROM t0 WHERE pk IN @@ -2160,7 +2160,7 @@ explain SELECT * FROM t1, t2 WHERE (t2.a , t1.b) IN (SELECT a, b FROM t3); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -1 PRIMARY t3 ref b b 5 test.t1.b 2 Using where; Start temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 PRIMARY t3 ref b b 5 test.t1.b 1 Using where; Start temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan 1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t3.a 1 Using index; End temporary SELECT * FROM t1, t2 WHERE (t2.a , t1.b) IN (SELECT a, b FROM t3); b a @@ -2185,7 +2185,7 @@ explain SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t5 index a a 10 NULL 2 Using where; Using index; Start temporary -1 PRIMARY t2 ref b b 5 test.t5.b 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 PRIMARY t2 ref b b 5 test.t5.b 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan 1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join) 1 PRIMARY t3 ALL NULL NULL NULL NULL 15 Using where; End temporary; Using join buffer (incremental, BNL join) SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); @@ -2442,9 +2442,9 @@ SET SESSION optimizer_switch='loosescan=off'; EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY t2 range idx idx 4 NULL 2 Using where; Using index -1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index; FirstMatch(t1) +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where +1 PRIMARY t3 range idx idx 4 NULL 2 Using where; Using index +1 PRIMARY t2 ref idx idx 9 test.t3.b,test.t1.a 1 Using index; FirstMatch(t1) SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); a 5 @@ -2452,9 +2452,9 @@ SET SESSION optimizer_switch='loosescan=on'; EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 -1 PRIMARY t2 range idx idx 4 NULL 2 Using where; Using index -1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index; FirstMatch(t1) +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where +1 PRIMARY t3 range idx idx 4 NULL 2 Using where; Using index +1 PRIMARY t2 ref idx idx 9 test.t3.b,test.t1.a 1 Using index; FirstMatch(t1) SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b); a 5 @@ -2567,7 +2567,7 @@ INSERT INTO t1 VALUES (6,3),(7,1),(8,4),(9,3),(10,2); CREATE TABLE t2 ( c INT, d INT, KEY(c) ); INSERT INTO t2 VALUES -(1,2),(2,1),(3,3),(4,2),(5,5),(6,3),(7,1); +(1,2),(2,1),(3,3),(4,2),(5,5),(6,3),(7,1),(11,11); analyze table t1,t2; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected @@ -2577,15 +2577,15 @@ test.t2 analyze status OK explain SELECT a, b, d FROM t1, t2 WHERE ( b, d ) IN -( SELECT b, d FROM t1, t2 WHERE b = c ); +( SELECT b, d FROM t1 as t3, t2 as t4 WHERE b = c ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index b b 5 NULL 10 Using where; Using index; Start temporary -1 PRIMARY t2 ref c c 5 test.t1.b 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 PRIMARY t3 index b b 5 NULL 10 Using where; Using index; Start temporary +1 PRIMARY t4 ref c c 5 test.t3.b 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan 1 PRIMARY t1 ALL b NULL NULL NULL 10 Using where; Using join buffer (incremental, BNL join) -1 PRIMARY t2 ALL NULL NULL NULL NULL 7 Using where; End temporary; Using join buffer (incremental, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 8 Using where; End temporary; Using join buffer (incremental, BNL join) SELECT a, b, d FROM t1, t2 WHERE ( b, d ) IN -( SELECT b, d FROM t1, t2 WHERE b = c ); +( SELECT b, d FROM t1 as t3, t2 as t4 WHERE b = c ); a b d 1 2 1 1 2 1 @@ -2774,7 +2774,7 @@ WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_1 ALL NULL NULL NULL NULL 11 Using where 1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 -1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 2 Using where; FirstMatch(t1_2) +1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 1 Using where; FirstMatch(t1_2) 3 DERIVED t1 ALL NULL NULL NULL NULL 11 SELECT * FROM t1 AS t1_1, t1 AS t1_2 WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 ); @@ -3485,8 +3485,8 @@ SELECT * FROM t1 LEFT JOIN t2 ON (c = b) WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL idx_a NULL NULL NULL 23 +1 PRIMARY t2 ref idx_c idx_c 4 test.t1.b 1 Using where; Using index 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 -1 PRIMARY t2 ref idx_c idx_c 4 test.t1.b 2 Using where; Using index 2 MATERIALIZED t ALL idx_a NULL NULL NULL 23 SELECT * FROM t1 LEFT JOIN t2 ON (c = b) WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; @@ -3499,9 +3499,10 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t3 ON (c = b) WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t ALL idx_a NULL NULL NULL 23 Using where; Start temporary -1 PRIMARY t1 ref idx_a idx_a 4 test.t.a 2 Using where; End temporary -1 PRIMARY t3 ref idx_c idx_c 4 test.t.b 2 Using where +1 PRIMARY t1 ALL idx_a NULL NULL NULL 23 +1 PRIMARY t3 ref idx_c idx_c 4 test.t1.b 1 Using where +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 +2 MATERIALIZED t ALL idx_a NULL NULL NULL 23 SELECT * FROM t1 LEFT JOIN t3 ON (c = b) WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; a b c d @@ -3515,8 +3516,8 @@ SELECT * FROM t1 LEFT JOIN t2 ON (c = b) WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL idx_a NULL NULL NULL 23 +1 PRIMARY t2 ref idx_c idx_c 4 test.t1.b 1 Using where; Using index 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 -1 PRIMARY t2 ref idx_c idx_c 4 test.t1.b 2 Using where; Using index 2 MATERIALIZED t ALL idx_a NULL NULL NULL 23 SELECT * FROM t1 LEFT JOIN t2 ON (c = b) WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; @@ -3529,9 +3530,10 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t3 ON (c = b) WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t ALL idx_a NULL NULL NULL 23 Start temporary -1 PRIMARY t1 ALL idx_a NULL NULL NULL 23 Using where; End temporary; Using join buffer (flat, BNL join) -1 PRIMARY t3 ref idx_c idx_c 4 test.t.b 2 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 PRIMARY t1 ALL idx_a NULL NULL NULL 23 +1 PRIMARY t3 ref idx_c idx_c 4 test.t1.b 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 +2 MATERIALIZED t ALL idx_a NULL NULL NULL 23 SELECT * FROM t1 LEFT JOIN t3 ON (c = b) WHERE (a, b) IN (SELECT a, b FROM t1 t) having t1.a !='z'; a b c d @@ -3560,9 +3562,8 @@ SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a) GROUP BY a HAVING a != 'z'; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t range idx_a idx_a 4 NULL 3 Using where; Using index -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where -2 MATERIALIZED t1 ref idx_a idx_a 4 test.t2.b 2 Using index +1 PRIMARY t1 ref idx_a idx_a 4 test.t.a 1 Using index +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t) SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a) GROUP BY a HAVING a != 'z'; a @@ -3574,9 +3575,8 @@ SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a) GROUP BY a HAVING a != 'z'; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t range idx_a idx_a 4 NULL 3 Using where; Using index -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where -2 MATERIALIZED t1 ref idx_a idx_a 4 test.t2.b 2 Using index +1 PRIMARY t1 ref idx_a idx_a 4 test.t.a 1 Using index +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t) SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a) GROUP BY a HAVING a != 'z'; a diff --git a/mysql-test/main/subselect_sj_mat.result b/mysql-test/main/subselect_sj_mat.result index 68af9e9cd35..6d1366e532b 100644 --- a/mysql-test/main/subselect_sj_mat.result +++ b/mysql-test/main/subselect_sj_mat.result @@ -1141,7 +1141,7 @@ explain extended select a from t1 where a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where; Start temporary -1 PRIMARY t1 ref it1a it1a 4 test.t2.c 2 16.67 Using index; End temporary +1 PRIMARY t1 ref it1a it1a 4 test.t2.c 1 16.67 Using index; End temporary Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t1`.`a` = `test`.`t2`.`c` and `test`.`t2`.`d` >= 20 select a from t1 where a in (select c from t2 where d >= 20); @@ -1155,7 +1155,7 @@ explain extended select a from t1 where a in (select c from t2 where d >= 20); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 7 100.00 Using where; Start temporary -1 PRIMARY t1 ref it1a it1a 4 test.t2.c 2 14.29 Using index; End temporary +1 PRIMARY t1 ref it1a it1a 4 test.t2.c 1 14.29 Using index; End temporary Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t1`.`a` = `test`.`t2`.`c` and `test`.`t2`.`d` >= 20 select a from t1 where a in (select c from t2 where d >= 20); @@ -1208,7 +1208,7 @@ select a from t1 where a in (select c from t2 where d >= some(select e from t3 where b=e)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 7 100.00 Start temporary -1 PRIMARY t1 ref it1a,iab iab 4 test.t2.c 1 14.29 Using where; Using index; End temporary +1 PRIMARY t1 ref it1a,iab iab 4 test.t2.c 1 9.41 Using where; Using index; End temporary 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 @@ -2023,10 +2023,9 @@ WHERE (a, c) IN (SELECT s1.b, s1.c FROM t2 AS s1, t2 AS s2 WHERE s2.d = s1.e AND s1.e = (SELECT MAX(e) FROM t2)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 -1 PRIMARY t2 index c c 5 NULL 8 Using index -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 -2 MATERIALIZED s2 ref d d 4 const 2 Using where; Using index -2 MATERIALIZED s1 ALL c NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t2 range c c 5 NULL 8 Using where; Using index +1 PRIMARY s1 ref c c 5 test.t2.c 1 Using where +1 PRIMARY s2 ref d d 4 const 2 Using where; Using index; FirstMatch(t2) 3 SUBQUERY t2 ALL NULL NULL NULL NULL 8 SELECT a, c FROM t1, t2 WHERE (a, c) IN (SELECT s1.b, s1.c FROM t2 AS s1, t2 AS s2 @@ -2043,10 +2042,9 @@ WHERE (a, c) IN (SELECT s1.b, s1.c FROM t2 AS s1, t2 AS s2 WHERE s2.d = s1.e AND s1.e = (SELECT MAX(e) FROM t2)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 -1 PRIMARY t2 index c c 5 NULL 8 Using index -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 -2 MATERIALIZED s2 ref d d 4 const 2 Using where; Using index -2 MATERIALIZED s1 hash_ALL c #hash#$hj 5 const 8 Using where; Using join buffer (flat, BNLH join) +1 PRIMARY t2 range c c 5 NULL 8 Using where; Using index +1 PRIMARY s1 hash_ALL c #hash#c 5 test.t2.c 8 Using where; Using join buffer (flat, BNLH join) +1 PRIMARY s2 hash_range d #hash#d:d 4:4 const 2 Using where; Using index; FirstMatch(t2); Using join buffer (incremental, BNLH join) 3 SUBQUERY t2 ALL NULL NULL NULL NULL 8 SELECT a, c FROM t1, t2 WHERE (a, c) IN (SELECT s1.b, s1.c FROM t2 AS s1, t2 AS s2 @@ -2311,7 +2309,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch 2 DEPENDENT SUBQUERY t2 range i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY t3 ref i3 i3 5 test.t2.i2 2 100.00 Using index +2 DEPENDENT SUBQUERY t3 ref i3 i3 5 test.t2.i2 1 100.00 Using index Warnings: Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where <expr_cache><`test`.`t1`.`f1`>(exists(/* select#2 */ select 1 from `test`.`t2` semi join (`test`.`t3`) join `test`.`t3` where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t1`.`f1` = `test`.`t3`.`f3` limit 1)) diff --git a/mysql-test/main/table_elim.result b/mysql-test/main/table_elim.result index a9602d90249..580b1cf5a0d 100644 --- a/mysql-test/main/table_elim.result +++ b/mysql-test/main/table_elim.result @@ -563,9 +563,9 @@ JOIN t5 ON t4.f3 ON t3.f1 = t5.f5 ON t2.f4 = t3.f4 WHERE t3.f2 ; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where -1 SIMPLE t5 ref f5 f5 5 test.t3.f1 2 Using where; Using index +1 SIMPLE t5 ref f5 f5 5 test.t3.f1 1 Using where; Using index 1 SIMPLE t4 ALL NULL NULL NULL NULL 3 Using where -1 SIMPLE t2 ref f4 f4 1003 test.t3.f4 2 Using where +1 SIMPLE t2 ref f4 f4 1003 test.t3.f4 1 Using where # ^^ The above must not produce a QEP of t3,t5,t2,t4 # as that violates the "no interleaving of outer join nests" rule. DROP TABLE t1,t2,t3,t4,t5; @@ -970,7 +970,7 @@ group by yyy; explain select t1.* from t1 left join v2e on v2e.yyy=t1.a; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 10 -1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 1 Using where 2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table create table t2 (a int, b int, c int); insert into t2 select A.seq, B.seq, 123 from seq_1_to_3 A, seq_1_to_3 B; @@ -980,14 +980,14 @@ explain select t1.* from t1 left join (select a, count(*) as cnt from t2 group by a, b) D on D.a=t1.a; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 10 -1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 2 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 1 Using where 2 DERIVED t2 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort # Still no elimination 'cause field D.b is just an alias for t2.a explain select t1.* from t1 left join (select a, a as b, count(*) as cnt from t2 group by a, b) D on D.a=t1.a and D.b=t1.b; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 10 -1 PRIMARY <derived2> ref key0 key0 10 test.t1.a,test.t1.b 2 Using where +1 PRIMARY <derived2> ref key0 key0 10 test.t1.a,test.t1.b 1 Using where 2 DERIVED t2 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort Warnings: Warning 1052 Column 'b' in group statement is ambiguous diff --git a/mysql-test/main/table_value_constr.result b/mysql-test/main/table_value_constr.result index bd4f15af3c6..86479c843c2 100644 --- a/mysql-test/main/table_value_constr.result +++ b/mysql-test/main/table_value_constr.result @@ -821,7 +821,7 @@ select * from (values (1)) tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used -3 DEPENDENT UNION <derived4> ref key0 key0 4 func 2 100.00 +3 DEPENDENT UNION <derived4> ref key0 key0 4 func 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: @@ -1054,7 +1054,7 @@ select * from (values (1)) as tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used -3 DEPENDENT UNION <derived4> ref key0 key0 4 func 2 100.00 +3 DEPENDENT UNION <derived4> ref key0 key0 4 func 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: @@ -1147,7 +1147,7 @@ select * from (values (1)) as tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used -3 DEPENDENT UNION <derived4> ref key0 key0 4 func 2 100.00 +3 DEPENDENT UNION <derived4> ref key0 key0 4 func 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: @@ -2837,7 +2837,7 @@ id select_type table type possible_keys key key_len ref rows Extra 6 SUBQUERY <derived2> ALL NULL NULL NULL NULL 2 2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used 3 SUBQUERY t3 ALL NULL NULL NULL NULL 11 Using where -3 SUBQUERY <derived5> ref key0 key0 8 test.t3.a 2 Using where; FirstMatch(t3) +3 SUBQUERY <derived5> ref key0 key0 8 test.t3.a 1 Using where; FirstMatch(t3) 5 DERIVED t3 ALL NULL NULL NULL NULL 11 Using temporary; Using filesort prepare stmt from "select (values ((select * from t3 where a in (select * from v1))))"; @@ -2862,7 +2862,7 @@ id select_type table type possible_keys key key_len ref rows Extra 6 SUBQUERY <derived2> ALL NULL NULL NULL NULL 2 2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used 3 SUBQUERY t3 ALL NULL NULL NULL NULL 11 Using where -3 SUBQUERY <derived5> ref key0 key0 8 test.t3.a 2 Using where; FirstMatch(t3) +3 SUBQUERY <derived5> ref key0 key0 8 test.t3.a 1 Using where; FirstMatch(t3) 5 DERIVED t3 ALL NULL NULL NULL NULL 11 Using temporary; Using filesort prepare stmt from "select (values ((select * from t3 diff --git a/mysql-test/main/type_time_6065.result b/mysql-test/main/type_time_6065.result index a9f64fd9870..e0014ea75d9 100644 --- a/mysql-test/main/type_time_6065.result +++ b/mysql-test/main/type_time_6065.result @@ -220,7 +220,7 @@ t1 force INDEX (col_time_key) WHERE col_time_key = col_datetime_key; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 5 100.00 Using where -1 SIMPLE t1 ref col_time_key col_time_key 4 test.t2.col_datetime_key 2 100.00 Using where; Using index +1 SIMPLE t1 ref col_time_key col_time_key 4 test.t2.col_datetime_key 1 100.00 Using where; Using index Warnings: Note 1003 select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where `test`.`t1`.`col_time_key` = `test`.`t2`.`col_datetime_key` SELECT * FROM @@ -241,7 +241,7 @@ t1 force INDEX (col_time_key) WHERE col_datetime_key = col_time_key; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 5 100.00 Using where -1 SIMPLE t1 ref col_time_key col_time_key 4 test.t2.col_datetime_key 2 100.00 Using where; Using index +1 SIMPLE t1 ref col_time_key col_time_key 4 test.t2.col_datetime_key 1 100.00 Using where; Using index Warnings: Note 1003 select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where `test`.`t2`.`col_datetime_key` = `test`.`t1`.`col_time_key` SELECT * FROM @@ -304,7 +304,7 @@ t1 force INDEX (col_time_key) WHERE col_time_key = col_datetime_key; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using where; Using index -1 SIMPLE t1 ref col_time_key col_time_key 4 test.t2.col_datetime_key 2 100.00 Using where; Using index +1 SIMPLE t1 ref col_time_key col_time_key 4 test.t2.col_datetime_key 1 100.00 Using where; Using index Warnings: Note 1003 select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where `test`.`t1`.`col_time_key` = `test`.`t2`.`col_datetime_key` SELECT * FROM @@ -325,7 +325,7 @@ t1 force INDEX (col_time_key) WHERE col_datetime_key = col_time_key; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using where; Using index -1 SIMPLE t1 ref col_time_key col_time_key 4 test.t2.col_datetime_key 2 100.00 Using where; Using index +1 SIMPLE t1 ref col_time_key col_time_key 4 test.t2.col_datetime_key 1 100.00 Using where; Using index Warnings: Note 1003 select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where `test`.`t2`.`col_datetime_key` = `test`.`t1`.`col_time_key` SELECT * FROM diff --git a/mysql-test/main/view.result b/mysql-test/main/view.result index 41472bdf90a..b5c5564a7da 100644 --- a/mysql-test/main/view.result +++ b/mysql-test/main/view.result @@ -5489,8 +5489,8 @@ from t1 left join v1 on v1.c=t1.b where t1.a < 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range a a 5 NULL 3 100.00 Using index condition -1 SIMPLE t2 ref c c 5 test.t1.b 2 100.00 Using where -1 SIMPLE t3 ref f,e e 5 test.t2.d 2 100.00 Using where +1 SIMPLE t2 ref c c 5 test.t1.b 1 100.00 Using where +1 SIMPLE t3 ref f,e e 5 test.t2.d 1 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`c` = `test`.`t1`.`b` and `test`.`t3`.`e` = `test`.`t2`.`d` and `test`.`t3`.`f` is not null and `test`.`t1`.`b` is not null and `test`.`t2`.`d` is not null) where `test`.`t1`.`a` < 5 explain extended @@ -5500,8 +5500,8 @@ on t2.c=t1.b and t3.f is not null where t1.a < 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range a a 5 NULL 3 100.00 Using index condition -1 SIMPLE t2 ref c c 5 test.t1.b 2 100.00 Using where -1 SIMPLE t3 ref f,e e 5 test.t2.d 2 100.00 Using where +1 SIMPLE t2 ref c c 5 test.t1.b 1 100.00 Using where +1 SIMPLE t3 ref f,e e 5 test.t2.d 1 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`c` = `test`.`t1`.`b` and `test`.`t3`.`e` = `test`.`t2`.`d` and `test`.`t3`.`f` is not null and `test`.`t1`.`b` is not null and `test`.`t2`.`d` is not null) where `test`.`t1`.`a` < 5 explain extended @@ -5511,7 +5511,7 @@ where t1.a < 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range a a 5 NULL 3 100.00 Using index condition 1 SIMPLE t3 eq_ref f,e f 4 test.t1.a 1 100.00 Using where -1 SIMPLE t2 ref c c 5 test.t1.b 2 100.00 Using where +1 SIMPLE t2 ref c c 5 test.t1.b 1 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`c` = `test`.`t1`.`b` and `test`.`t3`.`f` = `test`.`t1`.`a` and `test`.`t2`.`d` = `test`.`t3`.`e` and `test`.`t1`.`a` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null) where `test`.`t1`.`a` < 5 explain extended @@ -5522,7 +5522,7 @@ where t1.a < 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range a a 5 NULL 3 100.00 Using index condition 1 SIMPLE t3 eq_ref f,e f 4 test.t1.a 1 100.00 Using where -1 SIMPLE t2 ref c c 5 test.t1.b 2 100.00 Using where +1 SIMPLE t2 ref c c 5 test.t1.b 1 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`c` = `test`.`t1`.`b` and `test`.`t3`.`f` = `test`.`t1`.`a` and `test`.`t2`.`d` = `test`.`t3`.`e` and `test`.`t1`.`a` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null) where `test`.`t1`.`a` < 5 drop view v1; diff --git a/mysql-test/suite/compat/oracle/r/table_value_constr.result b/mysql-test/suite/compat/oracle/r/table_value_constr.result index 630c5932276..65e31761b90 100644 --- a/mysql-test/suite/compat/oracle/r/table_value_constr.result +++ b/mysql-test/suite/compat/oracle/r/table_value_constr.result @@ -819,7 +819,7 @@ select * from (values (1)) tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used -3 DEPENDENT UNION <derived4> ref key0 key0 4 func 2 100.00 +3 DEPENDENT UNION <derived4> ref key0 key0 4 func 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: @@ -1052,7 +1052,7 @@ select * from (values (1)) as tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used -3 DEPENDENT UNION <derived4> ref key0 key0 4 func 2 100.00 +3 DEPENDENT UNION <derived4> ref key0 key0 4 func 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: @@ -1145,7 +1145,7 @@ select * from (values (1)) as tvc_0); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used -3 DEPENDENT UNION <derived4> ref key0 key0 4 func 2 100.00 +3 DEPENDENT UNION <derived4> ref key0 key0 4 func 1 100.00 4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result index 59ca0bb2fec..34056d0c696 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.result +++ b/mysql-test/suite/federated/federatedx_create_handlers.result @@ -150,7 +150,7 @@ FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t WHERE federated.t3.name=t.name; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 7 -1 PRIMARY <derived2> ref key0 key0 18 federated.t3.name 2 +1 PRIMARY <derived2> ref key0 key0 18 federated.t3.name 1 2 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL EXPLAIN FORMAT=JSON SELECT * @@ -182,7 +182,7 @@ EXPLAIN "used_key_parts": ["name"], "ref": ["federated.t3.name"], "loops": 7, - "rows": 2, + "rows": 1, "cost": "COST_REPLACED", "filtered": 100, "materialized": { @@ -204,7 +204,7 @@ FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t WHERE federated.t3.name=t.name; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 7 7.00 100.00 100.00 -1 PRIMARY <derived2> ref key0 key0 18 federated.t3.name 2 0.00 100.00 100.00 +1 PRIMARY <derived2> ref key0 key0 18 federated.t3.name 1 0.00 100.00 100.00 2 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL SELECT * FROM federated.t3, (SELECT t1.name FROM federated.t1 @@ -221,7 +221,7 @@ FROM federated.t2 GROUP BY name)) t WHERE federated.t3.name=t.name; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 7 -1 PRIMARY <derived2> ref key0 key0 18 federated.t3.name 2 +1 PRIMARY <derived2> ref key0 key0 18 federated.t3.name 1 2 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL ANALYZE FORMAT=JSON SELECT * @@ -266,7 +266,7 @@ ANALYZE "ref": ["federated.t3.name"], "loops": 7, "r_loops": 7, - "rows": 2, + "rows": 1, "r_rows": 0, "cost": "REPLACED", "r_table_time_ms": "REPLACED", @@ -308,7 +308,7 @@ SELECT * FROM federated.t1 WHERE id >= 5) t WHERE federated.t3.name=t.name; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 7 -1 PRIMARY <derived2> ref key1 key1 18 federated.t3.name 2 +1 PRIMARY <derived2> ref key1 key1 18 federated.t3.name 1 2 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL # # MDEV-21887: federatedx crashes on SELECT ... INTO query in select_handler code diff --git a/mysql-test/suite/innodb/r/gap_locks.result b/mysql-test/suite/innodb/r/gap_locks.result index cd60b1fab22..d98b71982c8 100644 --- a/mysql-test/suite/innodb/r/gap_locks.result +++ b/mysql-test/suite/innodb/r/gap_locks.result @@ -1,6 +1,6 @@ CREATE TABLE t1(a INT PRIMARY KEY, b VARCHAR(40), c INT, INDEX(b,c)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1,'1',1),(2,'2',1); +INSERT INTO t1 VALUES (1,'1',1),(2,'2',1),(3,'3',1); SET @save_locks= @@GLOBAL.innodb_status_output_locks; SET GLOBAL INNODB_STATUS_OUTPUT_LOCKS = 'ON'; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; diff --git a/mysql-test/suite/innodb/t/gap_locks.test b/mysql-test/suite/innodb/t/gap_locks.test index 77ce2c842b1..575a966ec42 100644 --- a/mysql-test/suite/innodb/t/gap_locks.test +++ b/mysql-test/suite/innodb/t/gap_locks.test @@ -2,7 +2,7 @@ CREATE TABLE t1(a INT PRIMARY KEY, b VARCHAR(40), c INT, INDEX(b,c)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1,'1',1),(2,'2',1); +INSERT INTO t1 VALUES (1,'1',1),(2,'2',1),(3,'3',1); SET @save_locks= @@GLOBAL.innodb_status_output_locks; SET GLOBAL INNODB_STATUS_OUTPUT_LOCKS = 'ON'; diff --git a/mysql-test/suite/innodb_gis/r/rtree.result b/mysql-test/suite/innodb_gis/r/rtree.result index 5b6ea14e228..9ddcb841cbc 100644 --- a/mysql-test/suite/innodb_gis/r/rtree.result +++ b/mysql-test/suite/innodb_gis/r/rtree.result @@ -61,9 +61,9 @@ name ST_AsText(square) small POLYGON((0 0,0 1,1 1,1 0,0 0)) SELECT name, ST_AsText(square) from t1 where MBRDisjoint(@p, square); name ST_AsText(square) -right3 POLYGON((3 0,3 2,5 2,5 0,3 0)) up3 POLYGON((0 3,0 5,2 5,2 3,0 3)) down3 POLYGON((0 -3,0 -1,2 -1,2 -3,0 -3)) +right3 POLYGON((3 0,3 2,5 2,5 0,3 0)) left3 POLYGON((-3 0,-3 2,-1 2,-1 0,-3 0)) SELECT name, ST_AsText(square) from t1 where MBREquals(@p, square); name ST_AsText(square) diff --git a/mysql-test/suite/maria/mrr.result b/mysql-test/suite/maria/mrr.result index 326f3ca6a6c..2c8c289f4a6 100644 --- a/mysql-test/suite/maria/mrr.result +++ b/mysql-test/suite/maria/mrr.result @@ -405,7 +405,7 @@ WHERE table1.col_varchar_1024_latin1_key = table2.col_varchar_10_latin1 AND table1.pk<>0 ; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE table2 ALL NULL NULL NULL NULL 2 Using where -1 SIMPLE table1 ref PRIMARY,col_varchar_1024_latin1_key col_varchar_1024_latin1_key 1027 test.table2.col_varchar_10_latin1 2 Using index condition(BKA); Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE table1 ref PRIMARY,col_varchar_1024_latin1_key col_varchar_1024_latin1_key 1027 test.table2.col_varchar_10_latin1 1 Using index condition(BKA); Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan SELECT count(*) FROM t1 AS table1, t2 AS table2 WHERE diff --git a/mysql-test/suite/vcol/r/vcol_select_myisam.result b/mysql-test/suite/vcol/r/vcol_select_myisam.result index 0468f00e89b..8964eda1ba8 100644 --- a/mysql-test/suite/vcol/r/vcol_select_myisam.result +++ b/mysql-test/suite/vcol/r/vcol_select_myisam.result @@ -73,8 +73,8 @@ a b c 1 -1 -1 explain select * from t1 where c in (select c from t3 where c between -2 and -1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 range c c 5 NULL 3 Using index condition -1 PRIMARY t3 eq_ref c c 5 test.t1.c 1 Using index +1 PRIMARY t3 range c c 5 NULL 2 Using where; Using index +1 PRIMARY t1 ref c c 5 test.t3.c 1 # select_type=UNION, type=system # select_type=UNION RESULT, type=<union1,2> select * from t1 union select * from t2; diff --git a/mysql-test/suite/versioning/r/cte.result b/mysql-test/suite/versioning/r/cte.result index 53b0e7c3efb..11d478ac456 100644 --- a/mysql-test/suite/versioning/r/cte.result +++ b/mysql-test/suite/versioning/r/cte.result @@ -61,7 +61,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 100.00 2 DERIVED e ALL NULL NULL NULL NULL 4 100.00 Using where 3 RECURSIVE UNION e ALL mgr-fk NULL NULL NULL 4 100.00 Using where -3 RECURSIVE UNION <derived2> ref key0 key0 5 test.e.mgr 2 100.00 +3 RECURSIVE UNION <derived2> ref key0 key0 5 test.e.mgr 1 100.00 NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 with recursive ancestors as (/* select#2 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` where `test`.`e`.`name` = 'bill' and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1` union /* select#3 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` join `ancestors` `a` where `a`.`emp_id` = `test`.`e`.`mgr` and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1`)/* select#1 */ select `ancestors`.`emp_id` AS `emp_id`,`ancestors`.`name` AS `name`,`ancestors`.`mgr` AS `mgr`,`ancestors`.`salary` AS `salary` from `ancestors` @@ -102,7 +102,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 100.00 2 DERIVED e ALL NULL NULL NULL NULL 4 100.00 Using where 3 RECURSIVE UNION e ALL mgr-fk NULL NULL NULL 4 100.00 Using where -3 RECURSIVE UNION <derived2> ref key0 key0 5 test.e.mgr 2 100.00 +3 RECURSIVE UNION <derived2> ref key0 key0 5 test.e.mgr 1 100.00 NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 with recursive ancestors as (/* select#2 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` where `test`.`e`.`name` = 'bill' and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1` union /* select#3 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` join `ancestors` `a` where `a`.`emp_id` = `test`.`e`.`mgr` and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1`)/* select#1 */ select `ancestors`.`emp_id` AS `emp_id`,`ancestors`.`name` AS `name`,`ancestors`.`mgr` AS `mgr`,`ancestors`.`salary` AS `salary` from `ancestors` @@ -140,10 +140,10 @@ where e.mgr = a.emp_id select name from emp where emp_id in (select emp_id from ancestors for system_time as of timestamp @ts_1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY emp ALL PRIMARY NULL NULL NULL 4 100.00 Using where -1 PRIMARY <derived2> ref key0 key0 5 test.emp.emp_id 2 50.00 FirstMatch(emp) +1 PRIMARY <derived2> ref key0 key0 5 test.emp.emp_id 1 100.00 FirstMatch(emp) 2 DERIVED e ALL NULL NULL NULL NULL 4 100.00 Using where 3 RECURSIVE UNION e ALL mgr-fk NULL NULL NULL 4 100.00 Using where -3 RECURSIVE UNION <derived2> ref key0 key0 5 test.e.mgr 2 100.00 +3 RECURSIVE UNION <derived2> ref key0 key0 5 test.e.mgr 1 100.00 NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 with recursive ancestors as (/* select#2 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` where `test`.`e`.`name` = 'bill' and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1` union /* select#3 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` join `ancestors` `a` where `a`.`emp_id` = `test`.`e`.`mgr` and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1`)/* select#1 */ select `test`.`emp`.`name` AS `name` from `test`.`emp` semi join (`ancestors`) where `ancestors`.`emp_id` = `test`.`emp`.`emp_id` and `test`.`emp`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999' diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet4.result b/plugin/type_inet/mysql-test/type_inet/type_inet4.result index 7763b28e1fb..30cb6f7fe94 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet4.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet4.result @@ -1337,7 +1337,7 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT * FROM t1 WHERE b IN (SELECT a AS a_inner FROM t1 GROUP BY a_inner); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 Using index; Using where +2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1 Using index; Using where SET @@optimizer_switch=DEFAULT; DROP TABLE t1; # diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6.result b/plugin/type_inet/mysql-test/type_inet/type_inet6.result index 8d52e85cb91..b399400ab87 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.result @@ -1330,7 +1330,7 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT * FROM t1 WHERE b IN (SELECT a AS a_inner FROM t1 GROUP BY a_inner); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY t1 index_subquery a a 17 func 2 Using index; Using where +2 DEPENDENT SUBQUERY t1 index_subquery a a 17 func 1 Using index; Using where SET @@optimizer_switch=DEFAULT; DROP TABLE t1; # diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result b/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result index ab30c262148..b3955d09735 100644 --- a/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result @@ -2524,7 +2524,7 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT * FROM t1 WHERE b IN (SELECT a AS a_inner FROM t1 GROUP BY a_inner); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY t1 index_subquery a a 17 func 2 Using index; Using where +2 DEPENDENT SUBQUERY t1 index_subquery a a 17 func 1 Using index; Using where SET @@optimizer_switch=DEFAULT; DROP TABLE t1; # diff --git a/sql/handler.h b/sql/handler.h index c45f78f786d..924b065057e 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -4140,7 +4140,7 @@ public: virtual int multi_range_read_next(range_id_t *range_info); private: inline void calculate_costs(Cost_estimate *cost, uint keyno, - uint ranges, uint flags, + uint ranges, uint multi_row_ranges, uint flags, ha_rows total_rows, ulonglong io_blocks, ulonglong unassigned_single_point_ranges); diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index a71667ab9fe..7f930c9d9ae 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -27,10 +27,25 @@ static void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted, -/* The following calculation is the same as in multi_range_read_info() */ +/* + The following calculation is the same as in multi_range_read_info() + + @param cost Total cost is stored here + @param keyno Key number + @param n_ranges Number of different ranges + @param multi_row_ranges Number of ranges that are not EQ_REF + @param flags Flags. Only HA_MRR_INDEX_ONLY is used. + @param total_rows Number of rows expected to be read. + @param io_blocks Number of blocks we expect to read for + a not clustered index. + @param unassigned_single_point_ranges + Number of blocks we have not yet read for + a clustered index. +*/ void handler::calculate_costs(Cost_estimate *cost, uint keyno, - uint n_ranges, uint flags, + uint n_ranges, uint multi_row_ranges, + uint flags, ha_rows total_rows, ulonglong io_blocks, ulonglong unassigned_single_point_ranges) @@ -39,7 +54,9 @@ void handler::calculate_costs(Cost_estimate *cost, uint keyno, if (!is_clustering_key(keyno)) { - cost->index_cost= ha_keyread_time(keyno, n_ranges, total_rows, io_blocks); + cost->index_cost= ha_keyread_time(keyno, n_ranges, + total_rows + multi_row_ranges, + io_blocks); if (!(flags & HA_MRR_INDEX_ONLY)) { @@ -58,7 +75,9 @@ void handler::calculate_costs(Cost_estimate *cost, uint keyno, { /* Clustered index */ io_blocks= unassigned_single_point_ranges; - cost->index_cost= ha_keyread_time(keyno, n_ranges, total_rows, io_blocks); + cost->index_cost= ha_keyread_time(keyno, n_ranges, + total_rows + multi_row_ranges, + io_blocks); cost->copy_cost= rows2double(total_rows) * ROW_COPY_COST; } /* Adjust io cost to data size */ @@ -355,7 +374,9 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, { set_if_smaller(total_rows, max_rows); *flags |= HA_MRR_USE_DEFAULT_IMPL; - calculate_costs(cost, keyno, n_ranges, *flags, total_rows, + calculate_costs(cost, keyno, n_ranges, + n_ranges - (uint) single_point_ranges, + *flags, total_rows, io_blocks, unassigned_single_point_ranges); if (top_limit < total_rows) { @@ -365,8 +386,10 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, when we find the 'accepted rows' at once. */ Cost_estimate limit_cost; - calculate_costs(&limit_cost, keyno, n_ranges, *flags, top_limit, - io_blocks, unassigned_single_point_ranges); + calculate_costs(&limit_cost, keyno, n_ranges, + n_ranges - (uint)single_point_ranges, + *flags, top_limit, io_blocks, + unassigned_single_point_ranges); cost->limit_cost= limit_cost.total_cost(); } DBUG_PRINT("statistics", diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2e768df1699..df5eb3afd38 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7848,6 +7848,8 @@ static double matching_candidates_in_table(JOIN_TAB *s, /* Calculate the cost of reading a set of rows trough an index + @param eq_ref True if there is only one matching key (EQ_REF) + Logically this is identical to the code in multi_range_read_info_const() excepts the function also takes into account io_blocks and multiple ranges. @@ -7863,15 +7865,20 @@ static double matching_candidates_in_table(JOIN_TAB *s, KEY_COPY_COST as for filtering there is no copying of not accepted keys. + If eq_ref is not set, it means that we have to do one extra 'read_next' + on the index to verify that there is not more keys with the same value. + WHERE_COST cost is not added to any result. */ static ALL_READ_COST cost_for_index_read(const THD *thd, const TABLE *table, - uint key, ha_rows records) + uint key, ha_rows records, + bool eq_ref) { ALL_READ_COST cost; handler *file= table->file; ha_rows max_seeks; + ha_rows extra_reads= eq_ref ? 0 : 1; DBUG_ENTER("cost_for_index_read"); max_seeks= (ha_rows) thd->variables.max_seeks_for_key; @@ -7880,7 +7887,7 @@ static ALL_READ_COST cost_for_index_read(const THD *thd, const TABLE *table, if (file->is_clustering_key(key)) { cost.index_cost= - file->ha_keyread_clustered_time(key, 1, records, 0); + file->ha_keyread_clustered_time(key, 1, records+extra_reads, 0); cost.copy_cost= rows2double(records) * file->ROW_COPY_COST; /* There is no 'index_only_read' with a clustered index */ cost.row_cost= {0,0}; @@ -7890,7 +7897,7 @@ static ALL_READ_COST cost_for_index_read(const THD *thd, const TABLE *table, } else if (table->covering_keys.is_set(key) && !table->no_keyread) { - cost.index_cost= file->ha_keyread_time(key, 1, records, 0); + cost.index_cost= file->ha_keyread_time(key, 1, records + extra_reads, 0); cost.row_cost= {0,0}; cost.copy_cost= rows2double(records) * file->KEY_COPY_COST; cost.max_index_blocks= MY_MIN(file->index_blocks(key), max_seeks); @@ -7898,7 +7905,7 @@ static ALL_READ_COST cost_for_index_read(const THD *thd, const TABLE *table, } else { - cost.index_cost= file->ha_keyread_time(key, 1, records, 0); + cost.index_cost= file->ha_keyread_time(key, 1, records + extra_reads, 0); /* ha_rnd_pos_time() includes time for copying the row */ cost.row_cost= file->ha_rnd_pos_time(records); cost.max_index_blocks= MY_MIN(file->index_blocks(key), max_seeks); @@ -8341,7 +8348,7 @@ best_access_path(JOIN *join, } else { - tmp= cost_for_index_read(thd, table, key, 1); + tmp= cost_for_index_read(thd, table, key, 1, 1); } /* Calculate an adjusted cost based on how many records are read @@ -8407,8 +8414,8 @@ best_access_path(JOIN *join, ((double) (table->s->max_key_length-keyinfo->key_length) / (double) table->s->max_key_length))); set_if_smaller(records, (double)s->records); - if (records < 2.0) - records=2.0; /* Can't be as good as a unique */ + if (records < 1.0) + records= 1.0; /* Can't be as good as a unique */ } /* @@ -8449,7 +8456,7 @@ best_access_path(JOIN *join, } /* Calculate the cost of the index access */ tmp= cost_for_index_read(thd, table, key, - (ha_rows) records); + (ha_rows) records, 0); } } else @@ -8633,7 +8640,7 @@ best_access_path(JOIN *join, } set_if_smaller(records, (double) s->records); - tmp= cost_for_index_read(thd, table, key, (ha_rows)records); + tmp= cost_for_index_read(thd, table, key, (ha_rows)records, 0); tmp.copy_cost+= extra_cost; } else @@ -9078,7 +9085,7 @@ best_access_path(JOIN *join, { ALL_READ_COST cost= cost_for_index_read(thd, table, forced_index, - s->records); + s->records, 0); cur_cost= file->cost(cost); /* Calculate cost of checking the attached WHERE */ cur_cost= COST_ADD(cur_cost, @@ -30403,7 +30410,7 @@ static bool get_range_limit_read_cost(const POSITION *pos, <=> N > refkey_rows_estimate. */ ALL_READ_COST cost= cost_for_index_read(table->in_use, table, keynr, - rows_to_scan); + rows_to_scan, 0); *read_cost= (table->file->cost(&cost) + rows_to_scan * WHERE_COST_THD(table->in_use)); *read_rows= rows2double(rows_to_scan); diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result index 789478457d9..7a9c58e6f36 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result @@ -72,11 +72,8 @@ connection child2_1; SET NAMES utf8; SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 11 order by `b` -select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 12 order by `b` -select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 13 order by `b` -select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 14 order by `b` -select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 15 order by `b` +select `a`,`b` from `auto_test_remote`.`ta_r2` order by `a`,`b` +select `a`,`b` from `auto_test_remote`.`ta_r3` order by `a`,`b` SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, c FROM ta_r2 ORDER BY a ; SELECT a, b, c FROM ta_r3 ORDER BY a; diff --git a/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result index b2c4a209016..ff4f211faf5 100644 --- a/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result +++ b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result @@ -87,7 +87,7 @@ NULL NULL NULL 3 connection child2_1; SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r` t0) on ((t2.`b` = t3.`b`) and (t2.`c` = t1.`c`) and (t0.`a` = t1.`a`) and (t1.`a` is not null) and (t3.`b` is not null)) where 1 order by t3.`a` desc +select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r` t0) on ((t2.`b` = t3.`b`) and (t1.`c` = t2.`c`) and (t0.`a` = t1.`a`) and (t3.`b` is not null) and (t1.`a` is not null)) where 1 order by t3.`a` desc SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result index 9a2f1882b94..840328508fa 100644 --- a/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result +++ b/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result @@ -87,7 +87,7 @@ NULL c 2000-01-03 00:00:00 3 connection child2_1; SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null))) on ((t2.`b` = t3.`b`) and (t2.`c` = t1.`c`) and (t3.`b` is not null)) where 1 order by t3.`a` desc +select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null))) on ((t2.`b` = t3.`b`) and (t1.`c` = t2.`c`) and (t3.`b` is not null)) where 1 order by t3.`a` desc SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') |