diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index 3b7de95118b..fdd83143b05 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -18387,7 +18387,7 @@ explain extended select t2.a,t2.b,t2.c,t.c as t_c,t.max,t.min from t2, t3, (select c, max(b) max, min(b) min from t4 group by c) t where t2.b < 40 and t2.a=t3.a and t3.c=t.c; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 90 63.28 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 90 53.33 Using where 1 PRIMARY t3 ref idx_a idx_a 5 test.t2.a 1 100.00 Using where 1 PRIMARY ref key0 key0 128 test.t3.c 10 100.00 2 DERIVED t4 ALL idx_c NULL NULL NULL 160 100.00 Using temporary; Using filesort @@ -18406,7 +18406,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 90, - "filtered": 63.28125, + "filtered": 53.33333206, "attached_condition": "t2.b < 40 and t2.a is not null" } }, @@ -18910,7 +18910,7 @@ explain extended select * from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t where t2.b < 40 and t2.a=t3.a and t3.c=t.c; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 90 63.28 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 90 53.33 Using where 1 PRIMARY t3 ref idx_a idx_a 5 test.t2.a 1 100.00 Using where 1 PRIMARY ref key0 key0 128 test.t3.c 10 100.00 2 DERIVED t4 ALL idx_c NULL NULL NULL 160 100.00 Using temporary @@ -18929,7 +18929,7 @@ EXPLAIN "table_name": "t2", "access_type": "ALL", "rows": 90, - "filtered": 63.28125, + "filtered": 53.33333206, "attached_condition": "t2.b < 40 and t2.a is not null" } }, diff --git a/mysql-test/main/group_min_max.result b/mysql-test/main/group_min_max.result index c7164fcc74c..3195ec79c2d 100644 --- a/mysql-test/main/group_min_max.result +++ b/mysql-test/main/group_min_max.result @@ -2080,19 +2080,19 @@ id select_type table type possible_keys key key_len ref rows Extra explain extended select a1,a2,min(b),max(b) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 99.22 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 98.44 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2` explain extended select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 40.43 Using where; Using temporary; Using filesort +1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 26.95 Using where; Using temporary; Using filesort Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain extended select a1,a2,b,c from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 40.43 Using where; Using temporary; Using filesort +1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 26.95 Using where; Using temporary; Using filesort Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c` explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1; @@ -2100,7 +2100,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 99.22 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 98.44 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1; diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result index 36e045dc2bd..359739fecf8 100644 --- a/mysql-test/main/join_cache.result +++ b/mysql-test/main/join_cache.result @@ -6220,7 +6220,7 @@ EXPLAIN "key_length": "10", "used_key_parts": ["kp1", "kp2"], "rows": 836, - "filtered": 76.43428802, + "filtered": 76, "index_condition": "b.kp2 <= 10", "attached_condition": "b.kp2 <= 10 and b.col1 + 1 < 33333" }, diff --git a/mysql-test/main/join_outer.result b/mysql-test/main/join_outer.result index fcffeb6d161..522b668e07b 100644 --- a/mysql-test/main/join_outer.result +++ b/mysql-test/main/join_outer.result @@ -2795,7 +2795,7 @@ test.t3 analyze status OK explain extended select * from t1 left join t3 on t1.a=t3.b and t3.a<5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 -1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 1.96 Using where +1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 0.50 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` left join `test`.`t3` on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5) where 1 # t3.filtered must less than 100%, too: @@ -2803,7 +2803,7 @@ explain extended select * from t1 left join (t3 join t2) on t1.a=t3.b and t3.a<5 id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 -1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 1.96 Using where +1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 0.50 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5) where 1 drop table t1,t2,t3; diff --git a/mysql-test/main/join_outer_jcl6.result b/mysql-test/main/join_outer_jcl6.result index 721989c3368..b579cfc6ac0 100644 --- a/mysql-test/main/join_outer_jcl6.result +++ b/mysql-test/main/join_outer_jcl6.result @@ -2802,7 +2802,7 @@ test.t3 analyze status OK explain extended select * from t1 left join t3 on t1.a=t3.b and t3.a<5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 -1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 1.96 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 0.50 Using where; Using join buffer (flat, BNLH join) Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` left join `test`.`t3` on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5 and `test`.`t1`.`a` is not null) where 1 # t3.filtered must less than 100%, too: @@ -2810,7 +2810,7 @@ explain extended select * from t1 left join (t3 join t2) on t1.a=t3.b and t3.a<5 id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 1.96 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 0.50 Using where; Using join buffer (incremental, BNLH join) Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5 and `test`.`t1`.`a` is not null) where 1 drop table t1,t2,t3; diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index d2799d6e009..a1c67544cac 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -1551,7 +1551,7 @@ gtid-pos-auto-engines gtid-strict-mode FALSE help TRUE histogram-size 254 -histogram-type DOUBLE_PREC_HB +histogram-type JSON_HB host-cache-size 279 idle-readonly-transaction-timeout 0 idle-transaction-timeout 0 diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 255aad4450b..ab385ac3064 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -2091,12 +2091,12 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { { "column_name": "a", "ranges": ["1 <= a <= 1"], - "selectivity_from_histogram": 0.1796875 + "selectivity_from_histogram": 0.181 }, { "column_name": "b", "ranges": ["2 <= b <= 2"], - "selectivity_from_histogram": 0.015625 + "selectivity_from_histogram": 0.021 } ], "cond_selectivity": 0.021 @@ -8083,20 +8083,20 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", - "resulting_rows": 5.9375, - "cost": 2.829589844, + "resulting_rows": 4, + "cost": 3.217089844, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records": 5.9375, - "cost": 2.829589844, + "records": 4, + "cost": 3.217089844, "uses_join_buffering": false } }, - "rows_for_plan": 5.9375, + "rows_for_plan": 4, "cost_for_plan": 4.017089844, "rest_of_plan": [ @@ -8114,22 +8114,22 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", - "resulting_rows": 804.6875, - "cost": 256.8548584, + "resulting_rows": 800, + "cost": 176.7890625, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records": 804.6875, - "cost": 256.8548584, + "records": 800, + "cost": 176.7890625, "uses_join_buffering": false } }, - "rows_for_plan": 4777.832031, - "cost_for_plan": 1216.438354, - "estimated_join_cardinality": 4777.832031 + "rows_for_plan": 3200, + "cost_for_plan": 820.8061523, + "estimated_join_cardinality": 3200 } ] }, @@ -8146,20 +8146,20 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", - "resulting_rows": 804.6875, - "cost": 43.25976562, + "resulting_rows": 800, + "cost": 44.19726562, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records": 804.6875, - "cost": 43.25976562, + "records": 800, + "cost": 44.19726562, "uses_join_buffering": false } }, - "rows_for_plan": 804.6875, + "rows_for_plan": 800, "cost_for_plan": 204.1972656, "pruned_by_heuristic": true } @@ -8230,8 +8230,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", - "resulting_rows": 804.6875, - "cost": 43.25976562, + "resulting_rows": 800, + "cost": 44.19726562, "chosen": false } ], @@ -8245,8 +8245,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) }, "rows_for_plan": 10, "cost_for_plan": 26.02294779, - "selectivity": 0.8046875, - "estimated_join_cardinality": 8.046875 + "selectivity": 0.8, + "estimated_join_cardinality": 8 } ] }, @@ -8263,20 +8263,20 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) { "access_type": "scan", - "resulting_rows": 804.6875, - "cost": 43.25976562, + "resulting_rows": 800, + "cost": 44.19726562, "chosen": true } ], "chosen_access_method": { "type": "scan", - "records": 804.6875, - "cost": 43.25976562, + "records": 800, + "cost": 44.19726562, "uses_join_buffering": false } }, - "rows_for_plan": 804.6875, + "rows_for_plan": 800, "cost_for_plan": 204.1972656, "pruned_by_cost": true } @@ -8564,7 +8564,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN EXTENDED SELECT * from t1 WHERE a between 1 and 5 and b <= 5; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 100 0.22 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 0.25 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` between 1 and 5 and `test`.`t1`.`b` <= 5 select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; @@ -8579,7 +8579,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) [ "1 <= a <= 5" ], - "selectivity_from_histogram": 0.046875 + "selectivity_from_histogram": 0.05 }, { @@ -8588,13 +8588,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) [ "NULL < b <= 5" ], - "selectivity_from_histogram": 0.046875 + "selectivity_from_histogram": 0.05 } ] ] EXPLAIN EXTENDED SELECT * from t1 WHERE a != 5; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 98.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` <> 5 select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; @@ -8610,13 +8610,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) "NULL < a < 5", "5 < a" ], - "selectivity_from_histogram": 1 + "selectivity_from_histogram": 0.98 } ] ] EXPLAIN EXTENDED SELECT * from t1 WHERE b >= 10 and b < 25; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 100 15.62 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 14.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` >= 10 and `test`.`t1`.`b` < 25 select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; @@ -8631,7 +8631,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) [ "10 <= b < 25" ], - "selectivity_from_histogram": 0.15625 + "selectivity_from_histogram": 0.14 } ] ] diff --git a/mysql-test/main/partition.result b/mysql-test/main/partition.result index 58d0464b86f..a5d84072d11 100644 --- a/mysql-test/main/partition.result +++ b/mysql-test/main/partition.result @@ -2741,7 +2741,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t2 p1,p2 ALL NULL NULL NULL NULL 400 Using where explain extended select * from t2 where b=5; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 19.61 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 0.10 Using where Warnings: Note 1003 select `test`.`t2`.`part_key` AS `part_key`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where `test`.`t2`.`b` = 5 explain partitions select * from t2 where b=5; @@ -2749,7 +2749,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t2 p0,p1,p2,p3,p4 ALL NULL NULL NULL NULL 1000 Using where explain extended select * from t2 partition(p0) where b=1; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 200 19.61 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 200 20.00 Using where Warnings: Note 1003 select `test`.`t2`.`part_key` AS `part_key`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` PARTITION (`p0`) where `test`.`t2`.`b` = 1 set @@use_stat_tables= @save_use_stat_tables; diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result index 40ab309fffd..d559d3c39f7 100644 --- a/mysql-test/main/selectivity.result +++ b/mysql-test/main/selectivity.result @@ -1372,14 +1372,14 @@ test.t2 analyze status Table is already up to date explain extended select * from t1 straight_join t2 where t1.a=t2.a and t1.a<10; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.96 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.00 Using where 1 SIMPLE t2 ref a a 5 test.t1.a 10 100.00 Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 10 explain extended select * from t1 straight_join t2 where t1.a=t2.a and t2.a<10; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.96 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.00 Using where 1 SIMPLE t2 ref a a 5 test.t1.a 10 100.00 Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 10 @@ -1649,12 +1649,12 @@ test.t1 analyze status Table is already up to date # Check what info the optimizer has about selectivities explain extended select * from t1 use index () where a in (17,51,5); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 3.90 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.90 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`a` in (17,51,5) explain extended select * from t1 use index () where b=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 5.47 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 5.90 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`b` = 2 # Now, the equality is used for ref access, while the range condition @@ -1895,7 +1895,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN EXTENDED SELECT * from t1 where t1.a >= 81; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 3 66.41 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 66.67 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` >= 81 SELECT HEX(a), b from t1 where t1.a >= 81; @@ -1919,7 +1919,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 5 39.84 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 40.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 2 SET optimizer_use_condition_selectivity=3; diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result index 5457db21436..6e6517f7e08 100644 --- a/mysql-test/main/selectivity_innodb.result +++ b/mysql-test/main/selectivity_innodb.result @@ -1384,14 +1384,14 @@ test.t2 analyze status OK explain extended select * from t1 straight_join t2 where t1.a=t2.a and t1.a<10; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.96 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.00 Using where 1 SIMPLE t2 ref a a 5 test.t1.a 10 100.00 Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 10 explain extended select * from t1 straight_join t2 where t1.a=t2.a and t2.a<10; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.96 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.00 Using where 1 SIMPLE t2 ref a a 5 test.t1.a 10 100.00 Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 10 @@ -1661,12 +1661,12 @@ test.t1 analyze status OK # Check what info the optimizer has about selectivities explain extended select * from t1 use index () where a in (17,51,5); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 3.90 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.90 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`a` in (17,51,5) explain extended select * from t1 use index () where b=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 5.47 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 5.90 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`b` = 2 # Now, the equality is used for ref access, while the range condition @@ -1907,7 +1907,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN EXTENDED SELECT * from t1 where t1.a >= 81; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 3 66.41 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 66.67 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` >= 81 SELECT HEX(a), b from t1 where t1.a >= 81; @@ -1931,7 +1931,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 5 39.84 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 40.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 2 SET optimizer_use_condition_selectivity=3; diff --git a/mysql-test/main/statistics.result b/mysql-test/main/statistics.result index 3299c8904a9..313e9b843b3 100644 --- a/mysql-test/main/statistics.result +++ b/mysql-test/main/statistics.result @@ -1,6 +1,6 @@ set @SINGLE_PREC_TYPE='single_prec_hb'; set @DOUBLE_PREC_TYPE='double_prec_hb'; -set @DEFAULT_HIST_TYPE=@@histogram_type; +set @DEFAULT_HIST_TYPE='double_prec_hb'; drop table if exists t1,t2; set @save_use_stat_tables=@@use_stat_tables; set @save_histogram_size=@@global.histogram_size; diff --git a/mysql-test/main/statistics.test b/mysql-test/main/statistics.test index e39a95300af..5fde72cdbfa 100644 --- a/mysql-test/main/statistics.test +++ b/mysql-test/main/statistics.test @@ -1,6 +1,6 @@ set @SINGLE_PREC_TYPE='single_prec_hb'; set @DOUBLE_PREC_TYPE='double_prec_hb'; -set @DEFAULT_HIST_TYPE=@@histogram_type; +set @DEFAULT_HIST_TYPE='double_prec_hb'; if ($histogram_type_override) { eval set @SINGLE_PREC_TYPE=$histogram_type_override; diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result index 537233ef2c2..762f869fae5 100644 --- a/mysql-test/main/statistics_json.result +++ b/mysql-test/main/statistics_json.result @@ -3,7 +3,7 @@ # set @SINGLE_PREC_TYPE='single_prec_hb'; set @DOUBLE_PREC_TYPE='double_prec_hb'; -set @DEFAULT_HIST_TYPE=@@histogram_type; +set @DEFAULT_HIST_TYPE='double_prec_hb'; set @SINGLE_PREC_TYPE='JSON_HB'; set @DOUBLE_PREC_TYPE='JSON_HB'; set @DEFAULT_HIST_TYPE='JSON_HB'; @@ -4244,15 +4244,15 @@ test t1_json a a-0 a-9 0.0000 3.0000 1.0000 10 JSON_HB { } explain extended select * from t1_json where a between 'a-3a' and 'zzzzzzzzz'; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 58.71 Using where +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 68.71 Using where Warnings: Note 1003 select `test`.`t1_json`.`a` AS `a` from `test`.`t1_json` where `test`.`t1_json`.`a` between 'a-3a' and 'zzzzzzzzz' analyze select * from t1_json where a between 'a-3a' and 'zzzzzzzzz'; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 10.00 58.71 60.00 Using where +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 10.00 68.71 60.00 Using where explain extended select * from t1_json where a < 'b-1a'; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 90.00 Using where +1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 100.00 Using where Warnings: Note 1003 select `test`.`t1_json`.`a` AS `a` from `test`.`t1_json` where `test`.`t1_json`.`a` < 'b-1a' analyze select * from t1_json where a > 'zzzzzzzzz'; @@ -7529,7 +7529,7 @@ test.t1 analyze status OK analyze select c from t1 where c > '1'; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 16 16.00 75.00 75.00 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 16 16.00 80.47 75.00 Using where drop table t1; # # MDEV-26849: JSON Histograms: point selectivity estimates are off for non-existent values diff --git a/mysql-test/main/subselect_mat.result b/mysql-test/main/subselect_mat.result index 5f38d2a5d35..980db9f3ee1 100644 --- a/mysql-test/main/subselect_mat.result +++ b/mysql-test/main/subselect_mat.result @@ -61,7 +61,7 @@ explain extended select * from t1 where a1 in (select b1 from t2 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <`test`.`t1`.`a1`>((`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( (/* select#2 */ select `test`.`t2`.`b1` from `test`.`t2` where `test`.`t2`.`b1` > '0' ), (`test`.`t1`.`a1` in on distinct_key where `test`.`t1`.`a1` = ``.`b1`)))) select * from t1 where a1 in (select b1 from t2 where b1 > '0'); @@ -72,7 +72,7 @@ explain extended select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <`test`.`t1`.`a1`>((`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( (/* select#2 */ select `test`.`t2`.`b1` from `test`.`t2` where `test`.`t2`.`b1` > '0' ), (`test`.`t1`.`a1` in on distinct_key where `test`.`t1`.`a1` = ``.`b1`)))) select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1); @@ -83,7 +83,7 @@ explain extended select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <`test`.`t1`.`a1`,`test`.`t1`.`a2`>(((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( (/* select#2 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` > '0' ), (`test`.`t1`.`a1` in on distinct_key where `test`.`t1`.`a1` = ``.`b1` and `test`.`t1`.`a2` = ``.`b2`)))) select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2); @@ -94,7 +94,7 @@ explain extended select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where; Using temporary +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <`test`.`t1`.`a1`,`test`.`t1`.`a2`>(((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( (/* select#2 */ select `test`.`t2`.`b1`,min(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`b1` > '0' group by `test`.`t2`.`b1` ), (`test`.`t1`.`a1` in on distinct_key where `test`.`t1`.`a1` = ``.`b1` and `test`.`t1`.`a2` = ``.`min(b2)`)))) select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1); @@ -321,7 +321,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 4 MATERIALIZED t2i index it2i2 it2i3 18 NULL 5 100.00 Using where; Using index -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <`test`.`t1`.`a1`,`test`.`t1`.`a2`>(((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( (/* select#2 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` > '0' ), (`test`.`t1`.`a1` in on distinct_key where `test`.`t1`.`a1` = ``.`b1` and `test`.`t1`.`a2` = ``.`b2`)))) and <`test`.`t1`.`a1`,`test`.`t1`.`a2`>(((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( (/* select#3 */ select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <`test`.`t3`.`c1`,`test`.`t3`.`c2`>(((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( (/* select#4 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), (`test`.`t3`.`c1` in on distinct_key where `test`.`t3`.`c1` = ``.`b1` and `test`.`t3`.`c2` = ``.`b2`)))) ), (`test`.`t1`.`a1` in on distinct_key where `test`.`t1`.`a1` = ``.`c1` and `test`.`t1`.`a2` = ``.`c2`)))) select * from t1 @@ -451,8 +451,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 5 MATERIALIZED t2i index it2i2 it2i3 18 NULL 5 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where -3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <`test`.`t1`.`a1`,`test`.`t1`.`a2`>(((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and (`test`.`t1`.`a1`) = `test`.`t1`.`a1` and (`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and (`test`.`t1`.`a1`) = `test`.`t2`.`b1` and (`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and <`test`.`t1`.`a1`,`test`.`t1`.`a2`>(((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( (/* select#4 */ select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <`test`.`t3`.`c1`,`test`.`t3`.`c2`>(((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( (/* select#5 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), (`test`.`t3`.`c1` in on distinct_key where `test`.`t3`.`c1` = ``.`b1` and `test`.`t3`.`c2` = ``.`b2`)))) ), (`test`.`t1`.`a1` in on distinct_key where `test`.`t1`.`a1` = ``.`c1` and `test`.`t1`.`a2` = ``.`c2`)))) @@ -474,8 +474,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) 4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 5 MATERIALIZED t2i index it2i2 it2i3 18 NULL 5 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where -3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`c1` = `test`.`t1`.`a1` and <`test`.`t1`.`a1`,`test`.`t1`.`a2`>(((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and (`test`.`t1`.`a1`) = `test`.`t1`.`a1` and (`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and (`test`.`t1`.`a1`) = `test`.`t2`.`b1` and (`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and <`test`.`t3`.`c1`,`test`.`t3`.`c2`>(((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( (/* select#4 */ select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <`test`.`t3`.`c1`,`test`.`t3`.`c2`>(((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( (/* select#5 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), (`test`.`t3`.`c1` in on distinct_key where `test`.`t3`.`c1` = ``.`b1` and `test`.`t3`.`c2` = ``.`b2`)))) ), (`test`.`t3`.`c1` in on distinct_key where `test`.`t3`.`c1` = ``.`c1` and `test`.`t3`.`c2` = ``.`c2`)))) @@ -496,8 +496,8 @@ select * from t3 where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where -3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <`test`.`t3`.`c1`>((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`a1` from `test`.`t1` where `test`.`t1`.`a1` > '0' and (`test`.`t3`.`c1`) = `test`.`t1`.`a1` union /* select#3 */ select `test`.`t2`.`b1` from `test`.`t2` where `test`.`t2`.`b1` < '9' and (`test`.`t3`.`c1`) = `test`.`t2`.`b1`))) @@ -711,7 +711,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 3 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where 3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join) -4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 99.22 Using where +4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where ((concat(`test`.`t1`.`a1`,'x'),(/* select#2 */ select left(`test`.`t1_16`.`a1`,8) from `test`.`t1_16` where <`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`>(((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),(/* select#3 */ select `test`.`t2_16`.`b1`,`test`.`t2_16`.`b2` from `test`.`t2_16` join `test`.`t2` where `test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6) and <`test`.`t2`.`b1`>((`test`.`t2`.`b1`,`test`.`t2`.`b1` in ( (/* select#4 */ select `test`.`t3`.`c1` from `test`.`t3` where `test`.`t3`.`c2` > '0' ), (`test`.`t2`.`b1` in on distinct_key where `test`.`t2`.`b1` = ``.`c1`)))) and (`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1` and (`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`))) and (concat(`test`.`t1`.`a1`,'x')) = left(`test`.`t1_16`.`a1`,8)))) drop table t1_16, t2_16, t3_16; diff --git a/mysql-test/main/subselect_sj_mat.result b/mysql-test/main/subselect_sj_mat.result index 695c010692c..97dcf07705c 100644 --- a/mysql-test/main/subselect_sj_mat.result +++ b/mysql-test/main/subselect_sj_mat.result @@ -59,9 +59,9 @@ set @@optimizer_switch='materialization=on,in_to_exists=off,firstmatch=off'; explain extended select * from t1 where a1 in (select b1 from t2 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY eq_ref distinct_key distinct_key 8 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`b1` > '0' select * from t1 where a1 in (select b1 from t2 where b1 > '0'); @@ -71,9 +71,9 @@ a1 a2 explain extended select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY eq_ref distinct_key distinct_key 8 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`b1` > '0' select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1); @@ -83,9 +83,9 @@ a1 a2 explain extended select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`b1` > '0' select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2); @@ -97,7 +97,7 @@ select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' gr id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 1 PRIMARY eq_ref distinct_key distinct_key 16 test.t1.a1,test.t1.a2 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where; Using temporary +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from (/* select#2 */ select `test`.`t2`.`b1`,min(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`b1` > '0' group by `test`.`t2`.`b1`) join `test`.`t1` where ``.`b1` = `test`.`t1`.`a1` and ``.`min(b2)` = `test`.`t1`.`a2` select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1); @@ -331,12 +331,12 @@ where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and (a1, a2) in (select c1, c2 from t3 where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 98.44 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 -3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 98.44 Using where +3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 3 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 98.44 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and `test`.`t2`.`b1` > '0' and `test`.`t3`.`c2` > '0' select * from t1 @@ -375,12 +375,12 @@ b2 in (select c2 from t3 where c2 LIKE '%03')) and (a1, a2) in (select c1, c2 from t3 where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 -5 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 99.22 Using where +5 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where 4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: @@ -401,10 +401,10 @@ b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and (a1, a2) in (select c1, c2 from t3 t3c where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22 +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 -1 PRIMARY t2 ALL NULL NULL NULL NULL 5 99.22 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) -5 MATERIALIZED t3c ALL NULL NULL NULL NULL 4 99.22 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) +5 MATERIALIZED t3c ALL NULL NULL NULL NULL 4 100.00 Using where 5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3c.c1,test.t3c.c2 1 100.00 Using index 4 MATERIALIZED t3b ALL NULL NULL NULL NULL 4 100.00 Using where 3 DEPENDENT SUBQUERY t3a ALL NULL NULL NULL NULL 4 100.00 Using where @@ -434,12 +434,12 @@ where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and (a1, a2) in (select c1, c2 from t3i where (c1, c2) in (select b1, b2 from t2i where b2 > '0'))); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL # # # 3 99.22 # +1 PRIMARY t1 ALL NULL # # # 3 100.00 # 1 PRIMARY eq_ref distinct_key # # # 1 100.00 # 1 PRIMARY eq_ref distinct_key # # # 1 100.00 # -5 MATERIALIZED t3 ALL NULL # # # 4 99.22 # +5 MATERIALIZED t3 ALL NULL # # # 4 100.00 # 5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 # -2 MATERIALIZED t2 ALL NULL # # # 5 99.22 # +2 MATERIALIZED t2 ALL NULL # # # 5 100.00 # 4 MATERIALIZED t3 ALL NULL # # # 4 100.00 # 3 MATERIALIZED t3 ALL NULL # # # 4 100.00 # 7 UNION t1i range it1i1,it1i2,it1i3 # # # 3 100.00 # @@ -472,12 +472,12 @@ where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where (a1, a2) in (select c1, c2 from t3 where (c1, c2) in (select b1, b2 from t2i where b2 > '0')); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22 Using where +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 -4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 99.22 Using where +4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 4 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where -3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and <`test`.`t1`.`a1`,`test`.`t1`.`a2`>(((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and (`test`.`t1`.`a1`) = `test`.`t1`.`a1` and (`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and (`test`.`t1`.`a1`) = `test`.`t2`.`b1` and (`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and `test`.`t3`.`c2` > '0' @@ -496,12 +496,12 @@ where (c1, c2) in (select b1, b2 from t2i where b2 > '0')) and a1 = c1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -1 PRIMARY t3 ALL NULL NULL NULL NULL 4 99.22 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) 1 PRIMARY eq_ref distinct_key distinct_key 16 func,func 1 100.00 -4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 99.22 Using where +4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where 4 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where -3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) join `test`.`t3` where `test`.`t3`.`c1` = `test`.`t1`.`a1` and `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and <`test`.`t1`.`a1`,`test`.`t1`.`a2`>(((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and (`test`.`t1`.`a1`) = `test`.`t1`.`a1` and (`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and (`test`.`t1`.`a1`) = `test`.`t2`.`b1` and (`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and `test`.`t3`.`c2` > '0' @@ -522,8 +522,8 @@ select * from t3 where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where -3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <`test`.`t3`.`c1`>((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`a1` from `test`.`t1` where `test`.`t1`.`a1` > '0' and (`test`.`t3`.`c1`) = `test`.`t1`.`a1` union /* select#3 */ select `test`.`t2`.`b1` from `test`.`t2` where `test`.`t2`.`b1` < '9' and (`test`.`t3`.`c1`) = `test`.`t2`.`b1`))) @@ -738,7 +738,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; Using join buffer (flat, BNL join) 1 PRIMARY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) -1 PRIMARY t3 ALL NULL NULL NULL NULL 4 99.22 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2_16` join `test`.`t2` join `test`.`t1_16`) where `test`.`t2`.`b1` = `test`.`t3`.`c1` and `test`.`t2_16`.`b1` = `test`.`t1_16`.`a1` and `test`.`t2_16`.`b2` = `test`.`t1_16`.`a2` and `test`.`t2`.`b2` = substr(`test`.`t1_16`.`a2`,1,6) and `test`.`t3`.`c2` > '0' and concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8) diff --git a/mysql-test/suite/sys_vars/r/histogram_type_basic.result b/mysql-test/suite/sys_vars/r/histogram_type_basic.result index db42204ac1f..8dbd32512f8 100644 --- a/mysql-test/suite/sys_vars/r/histogram_type_basic.result +++ b/mysql-test/suite/sys_vars/r/histogram_type_basic.result @@ -1,16 +1,16 @@ SET @start_global_value = @@global.histogram_type; SELECT @start_global_value; @start_global_value -DOUBLE_PREC_HB +JSON_HB SET @start_session_value = @@session.histogram_type; SELECT @start_session_value; @start_session_value -DOUBLE_PREC_HB +JSON_HB SET @@global.histogram_type = 1; SET @@global.histogram_type = DEFAULT; SELECT @@global.histogram_type; @@global.histogram_type -DOUBLE_PREC_HB +JSON_HB SET @@global.histogram_type = 0; SELECT @@global.histogram_type; @@global.histogram_type @@ -71,9 +71,9 @@ HISTOGRAM_TYPE DOUBLE_PREC_HB SET @@global.histogram_type = @start_global_value; SELECT @@global.histogram_type; @@global.histogram_type -DOUBLE_PREC_HB +JSON_HB SET @@session.histogram_type = @start_session_value; SELECT @@session.histogram_type; @@session.histogram_type -DOUBLE_PREC_HB +JSON_HB set sql_mode=''; diff --git a/sql/opt_histogram_json.cc b/sql/opt_histogram_json.cc index 82828a35f44..842f9a5ce67 100644 --- a/sql/opt_histogram_json.cc +++ b/sql/opt_histogram_json.cc @@ -136,7 +136,7 @@ public: We may end up producing a histogram with fewer buckets than intended, but this is considered tolerable. */ - bucket_capacity= round(rows2double(records) / histogram->get_width() + 0.5); + bucket_capacity= (longlong)round(rows2double(records) / histogram->get_width() + 0.5); if (bucket_capacity == 0) bucket_capacity= 1; hist_width= histogram->get_width(); diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 447c1f07310..690c3533dad 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -6499,7 +6499,7 @@ static Sys_var_enum Sys_histogram_type( "DOUBLE_PREC_HB - double precision height-balanced, " "JSON_HB - height-balanced, stored as JSON.", SESSION_VAR(histogram_type), CMD_LINE(REQUIRED_ARG), - histogram_types, DEFAULT(1)); + histogram_types, DEFAULT(2)); static Sys_var_mybool Sys_no_thread_alarm( "debug_no_thread_alarm",