Skip to content

Commit

Permalink
MDEV-27062: Make histogram_type=JSON_HB the new default
Browse files Browse the repository at this point in the history
  • Loading branch information
spetrunia committed Jan 19, 2022
1 parent eb6a9ad commit be55ad0
Show file tree
Hide file tree
Showing 18 changed files with 119 additions and 119 deletions.
8 changes: 4 additions & 4 deletions mysql-test/main/derived_cond_pushdown.result
Expand Up @@ -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
Expand All @@ -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"
}
},
Expand Down Expand Up @@ -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
Expand All @@ -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"
}
},
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/main/group_min_max.result
Expand Up @@ -2080,27 +2080,27 @@ 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;
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;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/join_cache.result
Expand Up @@ -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"
},
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/join_outer.result
Expand Up @@ -2795,15 +2795,15 @@ 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:
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;
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/join_outer_jcl6.result
Expand Up @@ -2802,15 +2802,15 @@ 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:
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;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/mysqld--help.result
Expand Up @@ -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
Expand Down
70 changes: 35 additions & 35 deletions mysql-test/main/opt_trace.result
Expand Up @@ -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
Expand Down Expand Up @@ -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":
[
Expand All @@ -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
}
]
},
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
],
Expand All @@ -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
}
]
},
Expand All @@ -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
}
Expand Down Expand Up @@ -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;
Expand All @@ -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
},

{
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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
}
]
]
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/partition.result
Expand Up @@ -2741,15 +2741,15 @@ 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;
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;
Expand Down

0 comments on commit be55ad0

Please sign in to comment.