Commit be55ad0d authored by Sergei Petrunia's avatar Sergei Petrunia

MDEV-27062: Make histogram_type=JSON_HB the new default

parent eb6a9ad7
......@@ -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 <derived2> ref key0 key0 128 test.t3.c 10 100.00
2 DERIVED t4 ALL idx_c NULL NULL NULL 160 100.00 Using temporary; Using filesort
......@@ -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 <derived2> ref key0 key0 128 test.t3.c 10 100.00
2 DERIVED t4 ALL idx_c NULL NULL NULL 160 100.00 Using temporary
......@@ -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"
}
},
......
......@@ -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;
......
......@@ -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"
},
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
......@@ -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
}
]
]
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
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;
......
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;
......
......@@ -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
......
This diff is collapsed.
This diff is collapsed.
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='';
......@@ -136,7 +136,7 @@ class Histogram_json_builder : public Histogram_builder
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();
......
......@@ -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",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment