Skip to content

Commit da78030

Browse files
committed
Merge MDEV-26519: JSON_HB histograms into 10.8
2 parents e222e44 + ce4956f commit da78030

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+11232
-439
lines changed

include/json_lib.h

+10-4
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,9 @@ int json_find_paths_first(json_engine_t *je, json_find_paths_t *state,
373373
int json_find_paths_next(json_engine_t *je, json_find_paths_t *state);
374374

375375

376+
#define JSON_ERROR_OUT_OF_SPACE (-1)
377+
#define JSON_ERROR_ILLEGAL_SYMBOL (-2)
378+
376379
/*
377380
Converst JSON string constant into ordinary string constant
378381
which can involve unpacking json escapes and changing character set.
@@ -385,10 +388,13 @@ int json_unescape(CHARSET_INFO *json_cs,
385388
uchar *res, uchar *res_end);
386389

387390
/*
388-
Converst ordinary string constant into JSON string constant.
389-
which can involve appropriate escaping and changing character set.
390-
Returns negative integer in the case of an error,
391-
the length of the result otherwise.
391+
Convert a string constant into JSON string constant.
392+
This can involve appropriate escaping and changing the character set.
393+
Returns the length of the result on success,
394+
on error returns a negative error code.
395+
Some error codes:
396+
JSON_ERROR_OUT_OF_SPACE Not enough space in the provided buffer
397+
JSON_ERROR_ILLEGAL_SYMBOL Source symbol cannot be represented in JSON
392398
*/
393399
int json_escape(CHARSET_INFO *str_cs, const uchar *str, const uchar *str_end,
394400
CHARSET_INFO *json_cs, uchar *json, uchar *json_end);

libmysqld/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
138138
../sql/opt_trace.cc
139139
../sql/xa.cc
140140
../sql/json_table.cc
141+
../sql/opt_histogram_json.cc
141142
${GEN_SOURCES}
142143
${MYSYS_LIBWRAP_SOURCE}
143144
)

mysql-test/include/default_mysqld.cnf

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ binlog-direct-non-transactional-updates
118118

119119
default-storage-engine=myisam
120120
use_stat_tables=preferably
121+
histogram_type=json_hb
121122

122123
loose-ssl-ca[email protected]_TEST_DIR/std_data/cacert.pem
123124
loose-ssl-cert[email protected]_TEST_DIR/std_data/server-cert.pem
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--source include/json_hb_histogram.inc
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Remove non-deterministic parts of JSON_HB histogram
2+
3+
--replace_regex /("(collected_at|collected_by)": )"[^"]*"/\1"REPLACED"/

mysql-test/main/derived_cond_pushdown.result

+4-4
Original file line numberDiff line numberDiff line change
@@ -18387,7 +18387,7 @@ explain extended select t2.a,t2.b,t2.c,t.c as t_c,t.max,t.min
1838718387
from t2, t3, (select c, max(b) max, min(b) min from t4 group by c) t
1838818388
where t2.b < 40 and t2.a=t3.a and t3.c=t.c;
1838918389
id select_type table type possible_keys key key_len ref rows filtered Extra
18390-
1 PRIMARY t2 ALL NULL NULL NULL NULL 90 63.28 Using where
18390+
1 PRIMARY t2 ALL NULL NULL NULL NULL 90 60.00 Using where
1839118391
1 PRIMARY t3 ref idx_a idx_a 5 test.t2.a 1 100.00 Using where
1839218392
1 PRIMARY <derived2> ref key0 key0 128 test.t3.c 10 100.00
1839318393
2 DERIVED t4 ALL idx_c NULL NULL NULL 160 100.00 Using temporary; Using filesort
@@ -18406,7 +18406,7 @@ EXPLAIN
1840618406
"table_name": "t2",
1840718407
"access_type": "ALL",
1840818408
"rows": 90,
18409-
"filtered": 63.28125,
18409+
"filtered": 60,
1841018410
"attached_condition": "t2.b < 40 and t2.a is not null"
1841118411
}
1841218412
},
@@ -18910,7 +18910,7 @@ explain extended select *
1891018910
from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t
1891118911
where t2.b < 40 and t2.a=t3.a and t3.c=t.c;
1891218912
id select_type table type possible_keys key key_len ref rows filtered Extra
18913-
1 PRIMARY t2 ALL NULL NULL NULL NULL 90 63.28 Using where
18913+
1 PRIMARY t2 ALL NULL NULL NULL NULL 90 60.00 Using where
1891418914
1 PRIMARY t3 ref idx_a idx_a 5 test.t2.a 1 100.00 Using where
1891518915
1 PRIMARY <derived2> ref key0 key0 128 test.t3.c 10 100.00
1891618916
2 DERIVED t4 ALL idx_c NULL NULL NULL 160 100.00 Using temporary
@@ -18929,7 +18929,7 @@ EXPLAIN
1892918929
"table_name": "t2",
1893018930
"access_type": "ALL",
1893118931
"rows": 90,
18932-
"filtered": 63.28125,
18932+
"filtered": 60,
1893318933
"attached_condition": "t2.b < 40 and t2.a is not null"
1893418934
}
1893518935
},

mysql-test/main/group_min_max.result

+4-4
Original file line numberDiff line numberDiff line change
@@ -2080,27 +2080,27 @@ id select_type table type possible_keys key key_len ref rows Extra
20802080
explain extended select a1,a2,min(b),max(b) from t1
20812081
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2;
20822082
id select_type table type possible_keys key key_len ref rows filtered Extra
2083-
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
2083+
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
20842084
Warnings:
20852085
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`
20862086
explain extended select a1,a2,b,min(c),max(c) from t1
20872087
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b;
20882088
id select_type table type possible_keys key key_len ref rows filtered Extra
2089-
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
2089+
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
20902090
Warnings:
20912091
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`
20922092
explain extended select a1,a2,b,c from t1
20932093
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c;
20942094
id select_type table type possible_keys key key_len ref rows filtered Extra
2095-
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
2095+
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
20962096
Warnings:
20972097
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`
20982098
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1;
20992099
id select_type table type possible_keys key key_len ref rows Extra
21002100
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index
21012101
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;
21022102
id select_type table type possible_keys key key_len ref rows filtered Extra
2103-
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
2103+
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
21042104
Warnings:
21052105
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`
21062106
explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;

mysql-test/main/join_cache.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -6220,7 +6220,7 @@ EXPLAIN
62206220
"key_length": "10",
62216221
"used_key_parts": ["kp1", "kp2"],
62226222
"rows": 836,
6223-
"filtered": 76.43428802,
6223+
"filtered": 76,
62246224
"index_condition": "b.kp2 <= 10",
62256225
"attached_condition": "b.kp2 <= 10 and b.col1 + 1 < 33333"
62266226
},

mysql-test/main/join_outer.result

+2-2
Original file line numberDiff line numberDiff line change
@@ -2795,15 +2795,15 @@ test.t3 analyze status OK
27952795
explain extended select * from t1 left join t3 on t1.a=t3.b and t3.a<5;
27962796
id select_type table type possible_keys key key_len ref rows filtered Extra
27972797
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00
2798-
1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 1.96 Using where
2798+
1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 0.50 Using where
27992799
Warnings:
28002800
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
28012801
# t3.filtered must less than 100%, too:
28022802
explain extended select * from t1 left join (t3 join t2) on t1.a=t3.b and t3.a<5;
28032803
id select_type table type possible_keys key key_len ref rows filtered Extra
28042804
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00
28052805
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00
2806-
1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 1.96 Using where
2806+
1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 0.50 Using where
28072807
Warnings:
28082808
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
28092809
drop table t1,t2,t3;

mysql-test/main/join_outer_jcl6.result

+2-2
Original file line numberDiff line numberDiff line change
@@ -2802,15 +2802,15 @@ test.t3 analyze status OK
28022802
explain extended select * from t1 left join t3 on t1.a=t3.b and t3.a<5;
28032803
id select_type table type possible_keys key key_len ref rows filtered Extra
28042804
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00
2805-
1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 1.96 Using where; Using join buffer (flat, BNLH join)
2805+
1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 0.50 Using where; Using join buffer (flat, BNLH join)
28062806
Warnings:
28072807
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
28082808
# t3.filtered must less than 100%, too:
28092809
explain extended select * from t1 left join (t3 join t2) on t1.a=t3.b and t3.a<5;
28102810
id select_type table type possible_keys key key_len ref rows filtered Extra
28112811
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00
28122812
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2813-
1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 1.96 Using where; Using join buffer (incremental, BNLH join)
2813+
1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 0.50 Using where; Using join buffer (incremental, BNLH join)
28142814
Warnings:
28152815
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
28162816
drop table t1,t2,t3;

mysql-test/main/mysqld--help.result

+2-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ The following specify which files/extra groups are read (specified before remain
368368
Specifies type of the histograms created by ANALYZE.
369369
Possible values are: SINGLE_PREC_HB - single precision
370370
height-balanced, DOUBLE_PREC_HB - double precision
371-
height-balanced.
371+
height-balanced, JSON_HB - height-balanced, stored as
372+
JSON.
372373
--host-cache-size=# How many host names should be cached to avoid resolving.
373374
(Automatically configured unless set explicitly)
374375
--idle-readonly-transaction-timeout=#

mysql-test/main/opt_trace.result

+35-35
Original file line numberDiff line numberDiff line change
@@ -2091,12 +2091,12 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
20912091
{
20922092
"column_name": "a",
20932093
"ranges": ["1 <= a <= 1"],
2094-
"selectivity_from_histogram": 0.1796875
2094+
"selectivity_from_histogram": 0.181
20952095
},
20962096
{
20972097
"column_name": "b",
20982098
"ranges": ["2 <= b <= 2"],
2099-
"selectivity_from_histogram": 0.015625
2099+
"selectivity_from_histogram": 0.021
21002100
}
21012101
],
21022102
"cond_selectivity": 0.021
@@ -8083,20 +8083,20 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
80838083

80848084
{
80858085
"access_type": "scan",
8086-
"resulting_rows": 5.9375,
8087-
"cost": 2.829589844,
8086+
"resulting_rows": 5,
8087+
"cost": 3.017089844,
80888088
"chosen": true
80898089
}
80908090
],
80918091
"chosen_access_method":
80928092
{
80938093
"type": "scan",
8094-
"records": 5.9375,
8095-
"cost": 2.829589844,
8094+
"records": 5,
8095+
"cost": 3.017089844,
80968096
"uses_join_buffering": false
80978097
}
80988098
},
8099-
"rows_for_plan": 5.9375,
8099+
"rows_for_plan": 5,
81008100
"cost_for_plan": 4.017089844,
81018101
"rest_of_plan":
81028102
[
@@ -8114,22 +8114,22 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
81148114

81158115
{
81168116
"access_type": "scan",
8117-
"resulting_rows": 804.6875,
8118-
"cost": 256.8548584,
8117+
"resulting_rows": 800,
8118+
"cost": 220.9863281,
81198119
"chosen": true
81208120
}
81218121
],
81228122
"chosen_access_method":
81238123
{
81248124
"type": "scan",
8125-
"records": 804.6875,
8126-
"cost": 256.8548584,
8125+
"records": 800,
8126+
"cost": 220.9863281,
81278127
"uses_join_buffering": false
81288128
}
81298129
},
8130-
"rows_for_plan": 4777.832031,
8131-
"cost_for_plan": 1216.438354,
8132-
"estimated_join_cardinality": 4777.832031
8130+
"rows_for_plan": 4000,
8131+
"cost_for_plan": 1025.003418,
8132+
"estimated_join_cardinality": 4000
81338133
}
81348134
]
81358135
},
@@ -8146,20 +8146,20 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
81468146

81478147
{
81488148
"access_type": "scan",
8149-
"resulting_rows": 804.6875,
8150-
"cost": 43.25976562,
8149+
"resulting_rows": 800,
8150+
"cost": 44.19726562,
81518151
"chosen": true
81528152
}
81538153
],
81548154
"chosen_access_method":
81558155
{
81568156
"type": "scan",
8157-
"records": 804.6875,
8158-
"cost": 43.25976562,
8157+
"records": 800,
8158+
"cost": 44.19726562,
81598159
"uses_join_buffering": false
81608160
}
81618161
},
8162-
"rows_for_plan": 804.6875,
8162+
"rows_for_plan": 800,
81638163
"cost_for_plan": 204.1972656,
81648164
"pruned_by_heuristic": true
81658165
}
@@ -8230,8 +8230,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
82308230

82318231
{
82328232
"access_type": "scan",
8233-
"resulting_rows": 804.6875,
8234-
"cost": 43.25976562,
8233+
"resulting_rows": 800,
8234+
"cost": 44.19726562,
82358235
"chosen": false
82368236
}
82378237
],
@@ -8245,8 +8245,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
82458245
},
82468246
"rows_for_plan": 10,
82478247
"cost_for_plan": 26.02294779,
8248-
"selectivity": 0.8046875,
8249-
"estimated_join_cardinality": 8.046875
8248+
"selectivity": 0.8,
8249+
"estimated_join_cardinality": 8
82508250
}
82518251
]
82528252
},
@@ -8263,20 +8263,20 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
82638263

82648264
{
82658265
"access_type": "scan",
8266-
"resulting_rows": 804.6875,
8267-
"cost": 43.25976562,
8266+
"resulting_rows": 800,
8267+
"cost": 44.19726562,
82688268
"chosen": true
82698269
}
82708270
],
82718271
"chosen_access_method":
82728272
{
82738273
"type": "scan",
8274-
"records": 804.6875,
8275-
"cost": 43.25976562,
8274+
"records": 800,
8275+
"cost": 44.19726562,
82768276
"uses_join_buffering": false
82778277
}
82788278
},
8279-
"rows_for_plan": 804.6875,
8279+
"rows_for_plan": 800,
82808280
"cost_for_plan": 204.1972656,
82818281
"pruned_by_cost": true
82828282
}
@@ -8564,7 +8564,7 @@ test.t1 analyze status Engine-independent statistics collected
85648564
test.t1 analyze status OK
85658565
EXPLAIN EXTENDED SELECT * from t1 WHERE a between 1 and 5 and b <= 5;
85668566
id select_type table type possible_keys key key_len ref rows filtered Extra
8567-
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 0.22 Using where
8567+
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 0.25 Using where
85688568
Warnings:
85698569
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
85708570
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'))
85798579
[
85808580
"1 <= a <= 5"
85818581
],
8582-
"selectivity_from_histogram": 0.046875
8582+
"selectivity_from_histogram": 0.05
85838583
},
85848584

85858585
{
@@ -8588,13 +8588,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns'))
85888588
[
85898589
"NULL < b <= 5"
85908590
],
8591-
"selectivity_from_histogram": 0.046875
8591+
"selectivity_from_histogram": 0.05
85928592
}
85938593
]
85948594
]
85958595
EXPLAIN EXTENDED SELECT * from t1 WHERE a != 5;
85968596
id select_type table type possible_keys key key_len ref rows filtered Extra
8597-
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 100.00 Using where
8597+
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 99.00 Using where
85988598
Warnings:
85998599
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` <> 5
86008600
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'))
86108610
"NULL < a < 5",
86118611
"5 < a"
86128612
],
8613-
"selectivity_from_histogram": 1
8613+
"selectivity_from_histogram": 0.99
86148614
}
86158615
]
86168616
]
86178617
EXPLAIN EXTENDED SELECT * from t1 WHERE b >= 10 and b < 25;
86188618
id select_type table type possible_keys key key_len ref rows filtered Extra
8619-
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 15.62 Using where
8619+
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 15.00 Using where
86208620
Warnings:
86218621
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
86228622
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'))
86318631
[
86328632
"10 <= b < 25"
86338633
],
8634-
"selectivity_from_histogram": 0.15625
8634+
"selectivity_from_histogram": 0.15
86358635
}
86368636
]
86378637
]

0 commit comments

Comments
 (0)