Commit 4ab2b78b authored by Sergei Petrunia's avatar Sergei Petrunia

Histogram code cleanup and fixes

Factor the code that updates count, count_distinct,
count_distinct_single_occurrence into class Basic_stats_collector

Change from Histogram_builder and its descendant Histogram_builder_json
to  Histogram_builder (the interface), and Histogram_binary_builder,
Histogram_json_builder.

In Histogram_json_builder, do not forget to collect the right bound
of the right-most bucket.
parent a9c1feea
......@@ -232,12 +232,12 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
test t1 a 0 49 0.0000 1.0000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2239222C20223139222C20223331222C20223430225D0A7D
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A202020202276767676767676767676767676222C0A202020202277777777777777777777777777777777777777777777777777777777222C0A2020202022797979222C0A20202020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A20205D0A7D
test t1 c aaaa dddddddd 0.1250 7.0000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2261616161222C2022626262626262222C2022636363636363636363222C20226464646464646464225D0A7D
test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B22313938392D30332D3132222C2022313939302D30352D3135222C2022313939302D30352D3135222C2022313939392D30372D3233225D0A7D
test t1 e 0.01 0.112 0.2250 6.2000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B22302E3031222C2022302E303132222C2022302E3035222C2022302E31225D0A7D
test t1 f 1 5 0.2000 6.4000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2202222C202203222C202204222C202204225D0A7D
test t1 a 0 49 0.0000 1.0000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2230222C20223131222C20223234222C20223338222C20223439225D0A7D
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A202020202276767676767676767676767676222C0A202020202277777777777777777777777777777777777777777777777777777777222C0A20202020227878787878787878787878787878787878787878787878787878222C0A2020202022797979222C0A20202020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A20205D0A7D
test t1 c aaaa dddddddd 0.1250 7.0000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2261616161222C202261616161222C2022636363636363636363222C20226464646464646464222C20226464646464646464225D0A7D
test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A2020202022313938392D30332D3132222C0A2020202022313938392D30332D3132222C0A2020202022313939302D30352D3135222C0A2020202022313939382D30382D3238222C0A2020202022313939392D30372D3233220A20205D0A7D
test t1 e 0.01 0.112 0.2250 6.2000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B22302E3031222C2022302E3031222C2022302E3035222C2022302E31222C2022302E313132225D0A7D
test t1 f 1 5 0.2000 6.4000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2201222C202202222C202203222C202204222C202205225D0A7D
DELETE FROM mysql.column_stats;
set histogram_size=8;
set histogram_type=@DOUBLE_PREC_TYPE;
......@@ -251,12 +251,12 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
test t1 a 0 49 0.0000 1.0000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2234222C202239222C20223135222C20223231222C20223239222C20223333222C20223339222C20223433225D0A7D
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A202020202276767676767676767676767676222C0A202020202276767676767676767676767676222C0A202020202277777777777777777777777777777777777777777777777777777777222C0A202020202277777777777777777777777777777777777777777777777777777777222C0A20202020227878787878787878787878787878787878787878787878787878222C0A2020202022797979222C0A2020202022797979222C0A20202020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A20205D0A7D
test t1 c aaaa dddddddd 0.1250 7.0000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A202020202261616161222C0A202020202261616161222C0A2020202022626262626262222C0A2020202022626262626262222C0A2020202022636363636363636363222C0A2020202022636363636363636363222C0A20202020226464646464646464222C0A20202020226464646464646464220A20205D0A7D
test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A2020202022313938392D30332D3132222C0A2020202022313938392D30332D3132222C0A2020202022313939302D30352D3135222C0A2020202022313939302D30352D3135222C0A2020202022313939302D30352D3135222C0A2020202022313939302D30352D3135222C0A2020202022313939392D30372D3233222C0A2020202022313939392D30372D3233220A20205D0A7D
test t1 e 0.01 0.112 0.2250 6.2000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A2020202022302E3031222C0A2020202022302E3031222C0A2020202022302E3031222C0A2020202022302E303132222C0A2020202022302E3035222C0A2020202022302E31222C0A2020202022302E31222C0A2020202022302E313132220A20205D0A7D
test t1 f 1 5 0.2000 6.4000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2201222C202202222C202202222C202203222C202203222C202204222C202204222C202205225D0A7D
test t1 a 0 49 0.0000 1.0000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2230222C202235222C20223131222C20223138222C20223234222C20223332222C20223338222C20223433222C20223439225D0A7D
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A202020202276767676767676767676767676222C0A202020202276767676767676767676767676222C0A202020202277777777777777777777777777777777777777777777777777777777222C0A202020202277777777777777777777777777777777777777777777777777777777222C0A20202020227878787878787878787878787878787878787878787878787878222C0A2020202022797979222C0A2020202022797979222C0A20202020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A222C0A20202020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A20205D0A7D
test t1 c aaaa dddddddd 0.1250 7.0000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A202020202261616161222C0A202020202261616161222C0A202020202261616161222C0A2020202022626262626262222C0A2020202022636363636363636363222C0A2020202022636363636363636363222C0A20202020226464646464646464222C0A20202020226464646464646464222C0A20202020226464646464646464220A20205D0A7D
test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A2020202022313938392D30332D3132222C0A2020202022313938392D30332D3132222C0A2020202022313938392D30332D3132222C0A2020202022313939302D30352D3135222C0A2020202022313939302D30352D3135222C0A2020202022313939302D30352D3135222C0A2020202022313939382D30382D3238222C0A2020202022313939392D30372D3233222C0A2020202022313939392D30372D3233220A20205D0A7D
test t1 e 0.01 0.112 0.2250 6.2000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A2020202022302E3031222C0A2020202022302E3031222C0A2020202022302E3031222C0A2020202022302E3031222C0A2020202022302E3035222C0A2020202022302E31222C0A2020202022302E31222C0A2020202022302E313132222C0A2020202022302E313132220A20205D0A7D
test t1 f 1 5 0.2000 6.4000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2201222C202202222C202202222C202203222C202203222C202204222C202204222C202205222C202205225D0A7D
DELETE FROM mysql.column_stats;
set histogram_size= 0;
set histogram_type=@SINGLE_PREC_TYPE;
......@@ -1502,7 +1502,7 @@ avg_length 4.0000
avg_frequency 2.7640
hist_size 100
hist_type JSON_HB
hex(histogram) 7B0A202022686973746F6772616D5F68625F7631223A205B0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E31222C0A2020202022302E31222C0A2020202022302E32222C0A2020202022302E32222C0A2020202022302E33222C0A2020202022302E33222C0A2020202022302E34222C0A2020202022302E34222C0A2020202022302E34222C0A2020202022302E35222C0A2020202022302E35222C0A2020202022302E36222C0A2020202022302E36222C0A2020202022302E37222C0A2020202022302E37222C0A2020202022302E38222C0A2020202022302E39222C0A2020202022312E31222C0A2020202022312E32222C0A2020202022312E33222C0A2020202022312E34222C0A2020202022312E34222C0A2020202022312E36222C0A2020202022312E36222C0A2020202022312E37222C0A2020202022312E39222C0A2020202022322E30222C0A2020202022322E32222C0A2020202022322E32222C0A2020202022322E33222C0A2020202022322E35222C0A2020202022322E36222C0A2020202022322E38222C0A2020202022322E39222C0A2020202022332E31222C0A2020202022332E32222C0A2020202022332E34222C0A2020202022332E36222C0A2020202022332E38222C0A2020202022342E30222C0A2020202022342E33222C0A2020202022342E35222C0A2020202022342E38222C0A2020202022352E31222C0A2020202022352E34222C0A2020202022352E37222C0A2020202022352E38222C0A2020202022362E31222C0A2020202022362E34222C0A2020202022362E38222C0A2020202022372E32222C0A2020202022372E35222C0A2020202022372E37222C0A2020202022382E31222C0A2020202022382E35222C0A2020202022382E38222C0A2020202022392E31222C0A2020202022392E35222C0A202020202231302E31222C0A202020202231302E38222C0A202020202231312E33222C0A202020202231322E30222C0A202020202231322E36222C0A202020202231332E35222C0A202020202231342E32222C0A202020202231362E31222C0A202020202231362E38222C0A202020202231382E31222C0A202020202232302E30222C0A202020202232312E36222C0A202020202232332E34222C0A202020202232382E33222C0A202020202233312E37222C0A202020202233342E31222C0A202020202233372E35222C0A202020202234312E39222C0A202020202234362E34222C0A202020202235302E37222C0A202020202235352E31222C0A202020202236302E34222C0A202020202236352E36222C0A202020202237322E36222C0A202020202237372E31222C0A202020202238312E32222C0A202020202238352E36222C0A202020202238372E37222C0A202020202238392E39222C0A202020202239322E31222C0A202020202239342E32222C0A202020202239352E39222C0A202020202239372E33222C0A202020202239382E31222C0A202020202239392E30222C0A202020202239392E39220A20205D0A7D
hex(histogram) 7B0A202022686973746F6772616D5F68625F7631223A205B0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E31222C0A2020202022302E31222C0A2020202022302E32222C0A2020202022302E32222C0A2020202022302E33222C0A2020202022302E33222C0A2020202022302E34222C0A2020202022302E34222C0A2020202022302E34222C0A2020202022302E35222C0A2020202022302E35222C0A2020202022302E36222C0A2020202022302E36222C0A2020202022302E37222C0A2020202022302E38222C0A2020202022302E39222C0A2020202022312E30222C0A2020202022312E31222C0A2020202022312E33222C0A2020202022312E33222C0A2020202022312E34222C0A2020202022312E35222C0A2020202022312E36222C0A2020202022312E37222C0A2020202022312E38222C0A2020202022312E39222C0A2020202022322E30222C0A2020202022322E32222C0A2020202022322E33222C0A2020202022322E34222C0A2020202022322E35222C0A2020202022322E37222C0A2020202022322E38222C0A2020202022332E30222C0A2020202022332E32222C0A2020202022332E33222C0A2020202022332E35222C0A2020202022332E37222C0A2020202022332E38222C0A2020202022342E31222C0A2020202022342E33222C0A2020202022342E37222C0A2020202022342E39222C0A2020202022352E33222C0A2020202022352E35222C0A2020202022352E37222C0A2020202022352E39222C0A2020202022362E34222C0A2020202022362E37222C0A2020202022372E30222C0A2020202022372E34222C0A2020202022372E36222C0A2020202022372E38222C0A2020202022382E32222C0A2020202022382E37222C0A2020202022392E30222C0A2020202022392E33222C0A2020202022392E37222C0A202020202231302E35222C0A202020202231312E30222C0A202020202231312E38222C0A202020202231322E34222C0A202020202231332E32222C0A202020202231342E30222C0A202020202231352E38222C0A202020202231362E35222C0A202020202231382E30222C0A202020202231392E37222C0A202020202232312E32222C0A202020202232332E32222C0A202020202232372E38222C0A202020202233312E30222C0A202020202233322E39222C0A202020202233362E34222C0A202020202234312E36222C0A202020202234352E37222C0A202020202235302E32222C0A202020202235322E36222C0A202020202236302E33222C0A202020202236352E33222C0A202020202237322E31222C0A202020202237362E37222C0A202020202238312E32222C0A202020202238352E36222C0A202020202238372E36222C0A202020202238392E37222C0A202020202239322E31222C0A202020202239342E31222C0A202020202239352E38222C0A202020202239372E32222C0A202020202239382E31222C0A202020202239392E30222C0A202020202239392E39222C0A202020202239392E39220A20205D0A7D
decode_histogram(hist_type,histogram) {
"histogram_hb_v1": [
"0.0",
......@@ -1511,6 +1511,7 @@ decode_histogram(hist_type,histogram) {
"0.0",
"0.0",
"0.0",
"0.0",
"0.1",
"0.1",
"0.2",
......@@ -1525,85 +1526,85 @@ decode_histogram(hist_type,histogram) {
"0.6",
"0.6",
"0.7",
"0.7",
"0.8",
"0.9",
"1.0",
"1.1",
"1.2",
"1.3",
"1.3",
"1.4",
"1.4",
"1.6",
"1.5",
"1.6",
"1.7",
"1.8",
"1.9",
"2.0",
"2.2",
"2.2",
"2.3",
"2.4",
"2.5",
"2.6",
"2.7",
"2.8",
"2.9",
"3.1",
"3.0",
"3.2",
"3.4",
"3.6",
"3.3",
"3.5",
"3.7",
"3.8",
"4.0",
"4.1",
"4.3",
"4.5",
"4.8",
"5.1",
"5.4",
"4.7",
"4.9",
"5.3",
"5.5",
"5.7",
"5.8",
"6.1",
"5.9",
"6.4",
"6.8",
"7.2",
"7.5",
"7.7",
"8.1",
"8.5",
"8.8",
"9.1",
"9.5",
"10.1",
"10.8",
"11.3",
"12.0",
"12.6",
"13.5",
"14.2",
"16.1",
"16.8",
"18.1",
"20.0",
"21.6",
"23.4",
"28.3",
"31.7",
"34.1",
"37.5",
"41.9",
"46.4",
"50.7",
"55.1",
"60.4",
"65.6",
"72.6",
"77.1",
"6.7",
"7.0",
"7.4",
"7.6",
"7.8",
"8.2",
"8.7",
"9.0",
"9.3",
"9.7",
"10.5",
"11.0",
"11.8",
"12.4",
"13.2",
"14.0",
"15.8",
"16.5",
"18.0",
"19.7",
"21.2",
"23.2",
"27.8",
"31.0",
"32.9",
"36.4",
"41.6",
"45.7",
"50.2",
"52.6",
"60.3",
"65.3",
"72.1",
"76.7",
"81.2",
"85.6",
"87.7",
"89.9",
"87.6",
"89.7",
"92.1",
"94.2",
"95.9",
"97.3",
"94.1",
"95.8",
"97.2",
"98.1",
"99.0",
"99.9",
"99.9"
]
}
......@@ -1618,263 +1619,264 @@ avg_length 4.0000
avg_frequency 1.0467
hist_size 254
hist_type JSON_HB
hex(histogram) 7B0A202022686973746F6772616D5F68625F7631223A205B0A202020202231343338222C0A202020202235303535222C0A20202020223133303030222C0A20202020223235383838222C0A20202020223530363939222C0A20202020223839303533222C0A20202020223839333838222C0A20202020223839383831222C0A20202020223930313131222C0A20202020223930363031222C0A20202020223930393531222C0A20202020223931323030222C0A20202020223931373737222C0A20202020223932323234222C0A20202020223932353833222C0A20202020223932393838222C0A20202020223933333030222C0A20202020223933383138222C0A20202020223934313030222C0A20202020223934363030222C0A20202020223934393334222C0A20202020223935343030222C0A20202020223935393333222C0A20202020223936323931222C0A20202020223936383030222C0A20202020223937313030222C0A20202020223937343531222C0A20202020223938303830222C0A20202020223938333432222C0A20202020223938373831222C0A20202020223939333637222C0A20202020223939373939222C0A2020202022313030313138222C0A2020202022313030343738222C0A2020202022313030383837222C0A2020202022313031323035222C0A2020202022313031353734222C0A2020202022313031393834222C0A2020202022313032323934222C0A2020202022313032363831222C0A2020202022313033313731222C0A2020202022313033353434222C0A2020202022313033393834222C0A2020202022313034373030222C0A2020202022313035313139222C0A2020202022313035363930222C0A2020202022313036303031222C0A2020202022313036343134222C0A2020202022313037303030222C0A2020202022313037333239222C0A2020202022313037373631222C0A2020202022313038313030222C0A2020202022313038353734222C0A2020202022313039313231222C0A2020202022313039353030222C0A2020202022313039393635222C0A2020202022313130333838222C0A2020202022313131313030222C0A2020202022313131373532222C0A2020202022313132333735222C0A2020202022313133303830222C0A2020202022313133383030222C0A2020202022313134323333222C0A2020202022313134383736222C0A2020202022313135353332222C0A2020202022313136313738222C0A2020202022313136363935222C0A2020202022313137323237222C0A2020202022313137383635222C0A2020202022313138373138222C0A2020202022313139323833222C0A2020202022313139373936222C0A2020202022313230323635222C0A2020202022313231303030222C0A2020202022313231363030222C0A2020202022313231393534222C0A2020202022313232373035222C0A2020202022313233333539222C0A2020202022313233383635222C0A2020202022313234323037222C0A2020202022313234373335222C0A2020202022313235323535222C0A2020202022313235373636222C0A2020202022313236323832222C0A2020202022313236383230222C0A2020202022313237323232222C0A2020202022313237383031222C0A2020202022313238333030222C0A2020202022313239333030222C0A2020202022313330303030222C0A2020202022313331303030222C0A2020202022313331373137222C0A2020202022313332343535222C0A2020202022313333313036222C0A2020202022313333363432222C0A2020202022313334303337222C0A2020202022313335303130222C0A2020202022313336323136222C0A2020202022313337303238222C0A2020202022313337373736222C0A2020202022313338343138222C0A2020202022313339323833222C0A2020202022313430303330222C0A2020202022313430383030222C0A2020202022313432303434222C0A2020202022313432363539222C0A2020202022313433373236222C0A2020202022313434353832222C0A2020202022313435383030222C0A2020202022313436343339222C0A2020202022313437353233222C0A2020202022313438313035222C0A2020202022313439313436222C0A2020202022313530313030222C0A2020202022313531303630222C0A2020202022313532343432222C0A2020202022313533333634222C0A2020202022313534393830222C0A2020202022313535383030222C0A2020202022313537333030222C0A2020202022313538333335222C0A2020202022313539363332222C0A2020202022313631313631222C0A2020202022313632333030222C0A2020202022313633383439222C0A2020202022313634373437222C0A2020202022313636343637222C0A2020202022313637343631222C0A2020202022313639333030222C0A2020202022313730343238222C0A2020202022313731353332222C0A2020202022313732373031222C0A2020202022313733383935222C0A2020202022313734393835222C0A2020202022313736353736222C0A2020202022313738313832222C0A2020202022313739323038222C0A2020202022313830323130222C0A2020202022313831383035222C0A2020202022313833313030222C0A2020202022313834303631222C0A2020202022313835343031222C0A2020202022313836393030222C0A2020202022313838333434222C0A2020202022313839353639222C0A2020202022313930393035222C0A2020202022313933303035222C0A2020202022313934333030222C0A2020202022313935353030222C0A2020202022313937323534222C0A2020202022313939303030222C0A2020202022323030393031222C0A2020202022323032313334222C0A2020202022323033373933222C0A2020202022323036313538222C0A2020202022323037353838222C0A2020202022323130303638222C0A2020202022323132393736222C0A2020202022323134393530222C0A2020202022323136373335222C0A2020202022323138343437222C0A2020202022323231303030222C0A2020202022323232353138222C0A2020202022323234383837222C0A2020202022323237363537222C0A2020202022323239343235222C0A2020202022323333303431222C0A2020202022323336303030222C0A2020202022323339313234222C0A2020202022323431363439222C0A2020202022323433373432222C0A2020202022323435373732222C0A2020202022323438323435222C0A2020202022323532333836222C0A2020202022323534383432222C0A2020202022323537383132222C0A2020202022323632303030222C0A2020202022323634303831222C0A2020202022323636323831222C0A2020202022323730323531222C0A2020202022323732393638222C0A2020202022323736343231222C0A2020202022323739333430222C0A2020202022323832393431222C0A2020202022323836393030222C0A2020202022323931303030222C0A2020202022323934303536222C0A2020202022323938393030222C0A2020202022333031323736222C0A2020202022333034343737222C0A2020202022333039373530222C0A2020202022333133353330222C0A2020202022333137363030222C0A2020202022333232323637222C0A2020202022333236333939222C0A2020202022333330323736222C0A2020202022333334353633222C0A2020202022333339313331222C0A2020202022333432373338222C0A2020202022333439323436222C0A2020202022333533363332222C0A2020202022333539313437222C0A2020202022333632343730222C0A2020202022333636353439222C0A2020202022333732383430222C0A2020202022333830373535222C0A2020202022333835323031222C0A2020202022333932383330222C0A2020202022343030393937222C0A2020202022343039313030222C0A2020202022343136393838222C0A2020202022343231353839222C0A2020202022343238353232222C0A2020202022343335393634222C0A2020202022343433373237222C0A2020202022343532393736222C0A2020202022343631303030222C0A2020202022343639373335222C0A2020202022343736383030222C0A2020202022343833313535222C0A2020202022343933343039222C0A2020202022353038383939222C0A2020202022353139373933222C0A2020202022353239393030222C0A2020202022353430383238222C0A2020202022353633363632222C0A2020202022353830303030222C0A2020202022353934353031222C0A2020202022363136373030222C0A2020202022363336373635222C0A2020202022363536393235222C0A2020202022363830333332222C0A2020202022373033353932222C0A2020202022373335313637222C0A2020202022373634393032222C0A2020202022373937373335222C0A2020202022383330303030222C0A2020202022383737323339222C0A2020202022393430353839222C0A2020202022393933343030222C0A202020202231303432373430222C0A202020202231313030303030222C0A202020202231313536313030222C0A202020202231323137383138222C0A202020202231333030393737222C0A202020202231333932383630222C0A202020202231353137353530222C0A202020202231363832303030222C0A202020202231393639383638222C0A202020202232313534333736222C0A202020202232353935363734222C0A202020202232393634363338222C0A202020202234323536333030222C0A202020202236373538383435220A20205D0A7D
hex(histogram) 7B0A202022686973746F6772616D5F68625F7631223A205B0A20202020223432222C0A202020202231353030222C0A202020202235323030222C0A20202020223133313534222C0A20202020223237303235222C0A20202020223531393639222C0A20202020223839303633222C0A20202020223839343030222C0A20202020223839393030222C0A20202020223930323030222C0A20202020223930363033222C0A20202020223930393539222C0A20202020223931323033222C0A20202020223931373739222C0A20202020223932323339222C0A20202020223932353833222C0A20202020223933303030222C0A20202020223933333436222C0A20202020223933393030222C0A20202020223934313933222C0A20202020223934363835222C0A20202020223935303030222C0A20202020223935343438222C0A20202020223936303030222C0A20202020223936333232222C0A20202020223936383030222C0A20202020223937313638222C0A20202020223937363030222C0A20202020223938313233222C0A20202020223938333939222C0A20202020223938393030222C0A20202020223939343030222C0A20202020223939383931222C0A2020202022313030313439222C0A2020202022313030353435222C0A2020202022313030393430222C0A2020202022313031323935222C0A2020202022313031363536222C0A2020202022313032303532222C0A2020202022313032333631222C0A2020202022313032373136222C0A2020202022313033323737222C0A2020202022313033353739222C0A2020202022313034313436222C0A2020202022313034373635222C0A2020202022313035313939222C0A2020202022313035373030222C0A2020202022313036303738222C0A2020202022313036363030222C0A2020202022313037303036222C0A2020202022313037343030222C0A2020202022313037373939222C0A2020202022313038323737222C0A2020202022313038373234222C0A2020202022313039323235222C0A2020202022313039353736222C0A2020202022313130303136222C0A2020202022313130353331222C0A2020202022313131323538222C0A2020202022313131383832222C0A2020202022313132343530222C0A2020202022313133313335222C0A2020202022313133393538222C0A2020202022313134333935222C0A2020202022313134393830222C0A2020202022313135363938222C0A2020202022313136323536222C0A2020202022313136393239222C0A2020202022313137353339222C0A2020202022313138323030222C0A2020202022313138383538222C0A2020202022313139343030222C0A2020202022313139393930222C0A2020202022313230363435222C0A2020202022313231303937222C0A2020202022313231373038222C0A2020202022313232313036222C0A2020202022313233313030222C0A2020202022313233343030222C0A2020202022313233393538222C0A2020202022313234323739222C0A2020202022313234393433222C0A2020202022313235343037222C0A2020202022313235393937222C0A2020202022313236333436222C0A2020202022313237303030222C0A2020202022313237343834222C0A2020202022313237393639222C0A2020202022313238373330222C0A2020202022313239373030222C0A2020202022313330323135222C0A2020202022313331313338222C0A2020202022313331383631222C0A2020202022313332373434222C0A2020202022313333333030222C0A2020202022313333383539222C0A2020202022313334343139222C0A2020202022313335363033222C0A2020202022313336363937222C0A2020202022313337323635222C0A2020202022313337393934222C0A2020202022313338393033222C0A2020202022313339363732222C0A2020202022313430343539222C0A2020202022313431343638222C0A2020202022313432333032222C0A2020202022313433303732222C0A2020202022313434313538222C0A2020202022313435313530222C0A2020202022313436303836222C0A2020202022313437303030222C0A2020202022313437373434222C0A2020202022313438353833222C0A2020202022313439373032222C0A2020202022313530363234222C0A2020202022313531373538222C0A2020202022313532393833222C0A2020202022313534323937222C0A2020202022313535323434222C0A2020202022313536343638222C0A2020202022313538303030222C0A2020202022313539313033222C0A2020202022313630363339222C0A2020202022313631393130222C0A2020202022313633333531222C0A2020202022313634343633222C0A2020202022313635353833222C0A2020202022313637303531222C0A2020202022313638373032222C0A2020202022313639393330222C0A2020202022313731303536222C0A2020202022313732333537222C0A2020202022313733363030222C0A2020202022313734353030222C0A2020202022313735363631222C0A2020202022313737353232222C0A2020202022313738373438222C0A2020202022313739383138222C0A2020202022313831333339222C0A2020202022313832363339222C0A2020202022313833353030222C0A2020202022313834383539222C0A2020202022313836303030222C0A2020202022313837363931222C0A2020202022313839303336222C0A2020202022313930313233222C0A2020202022313932323437222C0A2020202022313934303030222C0A2020202022313935333436222C0A2020202022313936353139222C0A2020202022313938313833222C0A2020202022323030313731222C0A2020202022323031353638222C0A2020202022323033323936222C0A2020202022323035353630222C0A2020202022323037313030222C0A2020202022323039303338222C0A2020202022323131373030222C0A2020202022323134323934222C0A2020202022323135353837222C0A2020202022323137383034222C0A2020202022323139373733222C0A2020202022323232303330222C0A2020202022323233383931222C0A2020202022323236353039222C0A2020202022323239303630222C0A2020202022323331373234222C0A2020202022323335303733222C0A2020202022323337373133222C0A2020202022323430393030222C0A2020202022323432383230222C0A2020202022323434393734222C0A2020202022323437343532222C0A2020202022323531333438222C0A2020202022323534333530222C0A2020202022323536343030222C0A2020202022323630353132222C0A2020202022323633323437222C0A2020202022323635343530222C0A2020202022323639363030222C0A2020202022323732303538222C0A2020202022323735383037222C0A2020202022323738333137222C0A2020202022323832303730222C0A2020202022323836303030222C0A2020202022323839333736222C0A2020202022323933313035222C0A2020202022323937303030222C0A2020202022333030353030222C0A2020202022333033343437222C0A2020202022333038353731222C0A2020202022333132393237222C0A2020202022333136343338222C0A2020202022333230303935222C0A2020202022333235303030222C0A2020202022333239383530222C0A2020202022333333323030222C0A2020202022333337393737222C0A2020202022333432323030222C0A2020202022333438303730222C0A2020202022333533303436222C0A2020202022333537353532222C0A2020202022333631393538222C0A2020202022333635333832222C0A2020202022333731363031222C0A2020202022333739353230222C0A2020202022333834303030222C0A2020202022333931313730222C0A2020202022333939313735222C0A2020202022343037303138222C0A2020202022343136323839222C0A2020202022343230303030222C0A2020202022343237363532222C0A2020202022343334333734222C0A2020202022343431393638222C0A2020202022343530323838222C0A2020202022343539383834222C0A2020202022343639303030222C0A2020202022343735363537222C0A2020202022343832333030222C0A2020202022343930353234222C0A2020202022353038303030222C0A2020202022353138323832222C0A2020202022353239303933222C0A2020202022353430333330222C0A2020202022353633323130222C0A2020202022353737333532222C0A2020202022353933333231222C0A2020202022363130303030222C0A2020202022363334303635222C0A2020202022363536353632222C0A2020202022363734313030222C0A2020202022373033303030222C0A2020202022373330303030222C0A2020202022373632303030222C0A2020202022373932383538222C0A2020202022383233333031222C0A2020202022383734303030222C0A2020202022393335333631222C0A2020202022393839393735222C0A202020202231303430303030222C0A202020202231303936383239222C0A202020202231313531323734222C0A202020202231323137333539222C0A202020202231323937353236222C0A202020202231333738303837222C0A202020202231353033343531222C0A202020202231363734303030222C0A202020202231393638343030222C0A202020202232313339313235222C0A202020202232353539343234222C0A202020202232393430363233222C0A202020202234303137373333222C0A202020202236343634363933222C0A20202020223130353030303030220A20205D0A7D
decode_histogram(hist_type,histogram) {
"histogram_hb_v1": [
"1438",
"5055",
"13000",
"25888",
"50699",
"89053",
"89388",
"89881",
"90111",
"90601",
"90951",
"91200",
"91777",
"92224",
"42",
"1500",
"5200",
"13154",
"27025",
"51969",
"89063",
"89400",
"89900",
"90200",
"90603",
"90959",
"91203",
"91779",
"92239",
"92583",
"92988",
"93300",
"93818",
"94100",
"94600",
"94934",
"95400",
"95933",
"96291",
"93000",
"93346",
"93900",
"94193",
"94685",
"95000",
"95448",
"96000",
"96322",
"96800",
"97100",
"97451",
"98080",
"98342",
"98781",
"99367",
"99799",
"100118",
"100478",
"100887",
"101205",
"101574",
"101984",
"102294",
"102681",
"103171",
"103544",
"103984",
"104700",
"105119",
"105690",
"106001",
"106414",
"107000",
"107329",
"107761",
"108100",
"108574",
"109121",
"109500",
"109965",
"110388",
"111100",
"111752",
"112375",
"113080",
"113800",
"114233",
"114876",
"115532",
"116178",
"116695",
"117227",
"117865",
"118718",
"119283",
"119796",
"120265",
"121000",
"121600",
"121954",
"122705",
"123359",
"123865",
"124207",
"124735",
"125255",
"125766",
"126282",
"126820",
"127222",
"127801",
"128300",
"129300",
"130000",
"131000",
"131717",
"132455",
"133106",
"133642",
"134037",
"135010",
"136216",
"137028",
"137776",
"138418",
"139283",
"140030",
"140800",
"142044",
"142659",
"143726",
"144582",
"145800",
"146439",
"147523",
"148105",
"149146",
"150100",
"151060",
"152442",
"153364",
"154980",
"155800",
"157300",
"158335",
"159632",
"161161",
"162300",
"163849",
"164747",
"166467",
"167461",
"169300",
"170428",
"171532",
"172701",
"173895",
"174985",
"176576",
"178182",
"179208",
"180210",
"181805",
"183100",
"184061",
"185401",
"186900",
"188344",
"189569",
"190905",
"193005",
"194300",
"195500",
"197254",
"199000",
"200901",
"202134",
"203793",
"206158",
"207588",
"210068",
"212976",
"214950",
"216735",
"218447",
"221000",
"222518",
"224887",
"227657",
"229425",
"233041",
"236000",
"239124",
"241649",
"243742",
"245772",
"248245",
"252386",
"254842",
"257812",
"262000",
"264081",
"266281",
"270251",
"272968",
"276421",
"279340",
"282941",
"286900",
"291000",
"294056",
"298900",
"301276",
"304477",
"309750",
"313530",
"317600",
"322267",
"326399",
"330276",
"334563",
"339131",
"342738",
"349246",
"353632",
"359147",
"362470",
"366549",
"372840",
"380755",
"385201",
"392830",
"400997",
"409100",
"416988",
"421589",
"428522",
"435964",
"443727",
"452976",
"461000",
"469735",
"476800",
"483155",
"493409",
"508899",
"519793",
"529900",
"540828",
"563662",
"580000",
"594501",
"616700",
"636765",
"656925",
"680332",
"703592",
"735167",
"764902",
"797735",
"830000",
"877239",
"940589",
"993400",
"1042740",
"1100000",
"1156100",
"1217818",
"1300977",
"1392860",
"1517550",
"1682000",
"1969868",
"2154376",
"2595674",
"2964638",
"4256300",
"6758845"
"97168",
"97600",
"98123",
"98399",
"98900",
"99400",
"99891",
"100149",
"100545",
"100940",
"101295",
"101656",
"102052",
"102361",
"102716",
"103277",
"103579",
"104146",
"104765",
"105199",
"105700",
"106078",
"106600",
"107006",
"107400",
"107799",
"108277",
"108724",
"109225",
"109576",
"110016",
"110531",
"111258",
"111882",
"112450",
"113135",
"113958",
"114395",
"114980",
"115698",
"116256",
"116929",
"117539",
"118200",
"118858",
"119400",
"119990",
"120645",
"121097",
"121708",
"122106",
"123100",
"123400",
"123958",
"124279",
"124943",
"125407",
"125997",
"126346",
"127000",
"127484",
"127969",
"128730",
"129700",
"130215",
"131138",
"131861",
"132744",
"133300",
"133859",
"134419",
"135603",
"136697",
"137265",
"137994",
"138903",
"139672",
"140459",
"141468",
"142302",
"143072",
"144158",
"145150",
"146086",
"147000",
"147744",
"148583",
"149702",
"150624",
"151758",
"152983",
"154297",
"155244",
"156468",
"158000",
"159103",
"160639",
"161910",
"163351",
"164463",
"165583",
"167051",
"168702",
"169930",
"171056",
"172357",
"173600",
"174500",
"175661",
"177522",
"178748",
"179818",
"181339",
"182639",
"183500",
"184859",
"186000",
"187691",
"189036",
"190123",
"192247",
"194000",
"195346",
"196519",
"198183",
"200171",
"201568",
"203296",
"205560",
"207100",
"209038",
"211700",
"214294",
"215587",
"217804",
"219773",
"222030",
"223891",
"226509",
"229060",
"231724",
"235073",
"237713",
"240900",
"242820",
"244974",
"247452",
"251348",
"254350",
"256400",
"260512",
"263247",
"265450",
"269600",
"272058",
"275807",
"278317",
"282070",
"286000",
"289376",
"293105",
"297000",
"300500",
"303447",
"308571",
"312927",
"316438",
"320095",
"325000",
"329850",
"333200",
"337977",
"342200",
"348070",
"353046",
"357552",
"361958",
"365382",
"371601",
"379520",
"384000",
"391170",
"399175",
"407018",
"416289",
"420000",
"427652",
"434374",
"441968",
"450288",
"459884",
"469000",
"475657",
"482300",
"490524",
"508000",
"518282",
"529093",
"540330",
"563210",
"577352",
"593321",
"610000",
"634065",
"656562",
"674100",
"703000",
"730000",
"762000",
"792858",
"823301",
"874000",
"935361",
"989975",
"1040000",
"1096829",
"1151274",
"1217359",
"1297526",
"1378087",
"1503451",
"1674000",
"1968400",
"2139125",
"2559424",
"2940623",
"4017733",
"6464693",
"10500000"
]
}
set histogram_type=@SINGLE_PREC_TYPE;
......@@ -1947,7 +1949,7 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
test t1 a 1 3 0.0000 1.0000 10 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2231222C202231222C202231222C202232222C202232222C202232222C202232222C202233222C202233222C202233225D0A7D
test t1 a 1 3 0.0000 1.0000 10 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2231222C202231222C202231222C202231222C202232222C202232222C202232222C202233222C202233222C202233222C202233225D0A7D
set histogram_size=default;
drop table t1;
#
......@@ -1972,7 +1974,7 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
test t1 a 1 5 0.0000 1.0000 10 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2231222C202231222C202232222C202232222C202233222C202233222C202234222C202234222C202235222C202235225D0A7D
test t1 a 1 5 0.0000 1.0000 10 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2231222C202231222C202232222C202232222C202233222C202233222C202234222C202234222C202235222C202235222C202235225D0A7D
set histogram_size=0;
set histogram_type=@SINGLE_PREC_TYPE;
drop table t1;
......@@ -2013,7 +2015,7 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
test t2 id 1 1024 0.0000 8.0000 63 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A20202020223137222C0A20202020223333222C0A20202020223439222C0A20202020223635222C0A20202020223831222C0A20202020223937222C0A2020202022313133222C0A2020202022313239222C0A2020202022313435222C0A2020202022313631222C0A2020202022313737222C0A2020202022313933222C0A2020202022323039222C0A2020202022323235222C0A2020202022323431222C0A2020202022323537222C0A2020202022323733222C0A2020202022323839222C0A2020202022333035222C0A2020202022333231222C0A2020202022333337222C0A2020202022333533222C0A2020202022333639222C0A2020202022333835222C0A2020202022343031222C0A2020202022343137222C0A2020202022343333222C0A2020202022343439222C0A2020202022343635222C0A2020202022343831222C0A2020202022343937222C0A2020202022353133222C0A2020202022353239222C0A2020202022353435222C0A2020202022353631222C0A2020202022353737222C0A2020202022353933222C0A2020202022363039222C0A2020202022363235222C0A2020202022363431222C0A2020202022363537222C0A2020202022363733222C0A2020202022363839222C0A2020202022373035222C0A2020202022373231222C0A2020202022373337222C0A2020202022373533222C0A2020202022373639222C0A2020202022373835222C0A2020202022383031222C0A2020202022383137222C0A2020202022383333222C0A2020202022383439222C0A2020202022383635222C0A2020202022383831222C0A2020202022383937222C0A2020202022393133222C0A2020202022393239222C0A2020202022393435222C0A2020202022393631222C0A2020202022393737222C0A2020202022393933222C0A202020202231303039220A20205D0A7D
test t2 id 1 1024 0.0000 8.0000 63 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A202020202231222C0A20202020223137222C0A20202020223333222C0A20202020223439222C0A20202020223636222C0A20202020223832222C0A20202020223938222C0A2020202022313134222C0A2020202022313331222C0A2020202022313437222C0A2020202022313633222C0A2020202022313739222C0A2020202022313936222C0A2020202022323132222C0A2020202022323238222C0A2020202022323434222C0A2020202022323631222C0A2020202022323737222C0A2020202022323933222C0A2020202022333039222C0A2020202022333236222C0A2020202022333432222C0A2020202022333538222C0A2020202022333734222C0A2020202022333931222C0A2020202022343037222C0A2020202022343233222C0A2020202022343339222C0A2020202022343536222C0A2020202022343732222C0A2020202022343838222C0A2020202022353034222C0A2020202022353231222C0A2020202022353337222C0A2020202022353533222C0A2020202022353639222C0A2020202022353836222C0A2020202022363032222C0A2020202022363138222C0A2020202022363334222C0A2020202022363531222C0A2020202022363637222C0A2020202022363833222C0A2020202022363939222C0A2020202022373136222C0A2020202022373332222C0A2020202022373438222C0A2020202022373634222C0A2020202022373831222C0A2020202022373937222C0A2020202022383133222C0A2020202022383239222C0A2020202022383436222C0A2020202022383632222C0A2020202022383738222C0A2020202022383934222C0A2020202022393131222C0A2020202022393237222C0A2020202022393433222C0A2020202022393539222C0A2020202022393736222C0A2020202022393932222C0A202020202231303038222C0A202020202231303234220A20205D0A7D
set histogram_size=0;
drop table t1, t2;
set use_stat_tables=@save_use_stat_tables;
......@@ -2175,16 +2177,17 @@ from mysql.column_stats;
table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram)
t1 id 1 17384 0.0000 4.0000 14.0000 {
"histogram_hb_v1": [
"1490",
"2979",
"4469",
"5958",
"7448",
"9937",
"11427",
"12916",
"14406",
"15895"
"1",
"1639",
"3277",
"4916",
"6554",
"9193",
"10831",
"12469",
"14108",
"15746",
"17384"
]
}
set analyze_sample_percentage=0.1;
......@@ -2201,16 +2204,17 @@ from mysql.column_stats;
table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram)
t1 id 111 17026 0.0000 4.0000 10.4739 {
"histogram_hb_v1": [
"832",
"2446",
"3422",
"5411",
"6687",
"9390",
"10738",
"12738",
"14365",
"15411"
"111",
"988",
"2490",
"4088",
"5743",
"7806",
"10217",
"12072",
"14178",
"15144",
"17026"
]
}
#
......@@ -2227,16 +2231,17 @@ from mysql.column_stats;
table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram)
t1 id 1 17384 0.0000 4.0000 14.0401 {
"histogram_hb_v1": [
"1478",
"2954",
"4441",
"5894",
"7397",
"9888",
"11391",
"12895",
"14370",
"15880"
"1",
"1623",
"3252",
"4868",
"6483",
"8151",
"10789",
"12433",
"14077",
"15724",
"17384"
]
}
set analyze_sample_percentage=0;
......@@ -2253,16 +2258,17 @@ from mysql.column_stats;
table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram)
t1 id 1 17384 0.0000 4.0000 13.9812 {
"histogram_hb_v1": [
"1500",
"3009",
"4501",
"5997",
"7493",
"9981",
"11456",
"12932",
"14408",
"15903"
"1",
"1651",
"3306",
"4948",
"6596",
"9239",
"10863",
"12495",
"14113",
"15757",
"17384"
]
}
#
......@@ -2285,16 +2291,17 @@ from mysql.column_stats;
table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram)
t1 id 1 17384 0.0000 4.0000 14.0000 {
"histogram_hb_v1": [
"1490",
"2979",
"4469",
"5958",
"7448",
"9937",
"11427",
"12916",
"14406",
"15895"
"1",
"1639",
"3277",
"4916",
"6554",
"9193",
"10831",
"12469",
"14108",
"15746",
"17384"
]
}
explain select * from t1;
......@@ -2439,20 +2446,21 @@ test t1_json a a-0 a-9 0.0000 3.0000 1.0000 100 JSON_HB {
"a-9",
"a-9",
"a-9",
"a-9",
"a-9"
]
}
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 59.87 Using where
1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 60.27 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 59.87 60.00 Using where
1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 10.00 60.27 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 99.00 Using where
1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 99.01 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';
......@@ -2476,12 +2484,12 @@ test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status OK
explain extended select * from t2 where city = 'Moscow';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 101 96.08 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 101 98.04 Using where
Warnings:
Note 1003 select `test`.`t2`.`city` AS `city` from `test`.`t2` where `test`.`t2`.`city` = 'Moscow'
analyze select * from t2 where city = 'Moscow';
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 101 101.00 96.08 98.02 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 101 101.00 98.04 98.02 Using where
explain extended select * from t2 where city = 'Helsinki';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 101 2.00 Using where
......@@ -2508,386 +2516,394 @@ SELECT column_name, min_value, max_value, hist_size, hist_type, histogram FROM m
column_name min_value max_value hist_size hist_type histogram
Code ABW ZWE 50 JSON_HB {
"histogram_hb_v1": [
"ABW",
"ALB",
"ARM",
"AUS",
"BEL",
"BEN",
"BHR",
"BMU",
"BRN",
"CAN",
"CIV",
"COK",
"CUB",
"DEU",
"DOM",
"ESH",
"FJI",
"FSM",
"GIB",
"GNQ",
"GUF",
"HMD",
"IDN",
"IRQ",
"JAM",
"KGZ",
"KWT",
"LBY",
"LTU",
"MCO",
"MEX",
"MMR",
"MSR",
"MYS",
"NFK",
"NOR",
"PAK",
"PHL",
"PRK",
"QAT",
"RWA",
"SGS",
"SLV",
"STP",
"SWZ",
"TGO",
"BTN",
"CCK",
"CMR",
"COL",
"CXR",
"DJI",
"ECU",
"ESP",
"FLK",
"GBR",
"GLP",
"GRD",
"GUM",
"HRV",
"IOT",
"ISR",
"JPN",
"KIR",
"LBN",
"LKA",
"MAC",
"MDG",
"MLI",
"MOZ",
"MWI",
"NCL",
"NIU",
"NZL",
"PER",
"PRI",
"PSE",
"RUS",
"SGP",
"SLE",
"SPM",
"SWE",
"TCD",
"TKM",
"TUR",
"UKR",
"UGA",
"UZB",
"VIR",
"YEM"
"YEM",
"ZWE"
]
}
Name Afghanistan Zimbabwe 50 JSON_HB {
"histogram_hb_v1": [
"Afghanistan",
"Andorra",
"Argentina",
"Azerbaijan",
"Barbados",
"Belarus",
"Bermuda",
"Bouvet Island",
"Bulgaria",
"Canada",
"Chile",
"Colombia",
"Costa Rica",
"Côte d’Ivoire",
"Dominican Republic",
"Equatorial Guinea",
"Faroe Islands",
"French Guiana",
"Georgia",
"Greenland",
"Guinea",
"Heard Island and McDonald Islands",
"Iceland",
"Ireland",
"Japan",
"Kuwait",
"Lesotho",
"Lithuania",
"Malawi",
"Marshall Islands",
"Mayotte",
"Mongolia",
"Namibia",
"Netherlands Antilles",
"Nigeria",
"Norway",
"Panama",
"Philippines",
"Qatar",
"Saint Helena",
"Saint Vincent and the Grenadines",
"Senegal",
"Slovenia",
"South Georgia and the South Sandwich Islands",
"Suriname",
"Syria",
"Burkina Faso",
"Cape Verde",
"China",
"Comoros",
"Croatia",
"Denmark",
"Ecuador",
"Eritrea",
"Fiji Islands",
"French Southern territories",
"Ghana",
"Guadeloupe",
"Guinea-Bissau",
"Honduras",
"Indonesia",
"Italy",
"Kazakstan",
"Laos",
"Libyan Arab Jamahiriya",
"Macedonia",
"Mali",
"Mauritania",
"Moldova",
"Mozambique",
"Netherlands",
"Nicaragua",
"North Korea",
"Palau",
"Peru",
"Puerto Rico",
"Rwanda",
"Saint Pierre and Miquelon",
"Saudi Arabia",
"Slovakia",
"South Africa",
"Sudan",
"Switzerland",
"Thailand",
"Tunisia",
"Uganda",
"Tuvalu",
"United States",
"Venezuela",
"Western Sahara"
"Western Sahara",
"Zimbabwe"
]
}
SurfaceArea 0.40 17075400.00 50 JSON_HB {
"histogram_hb_v1": [
"0.40",
"14.00",
"36.00",
"78.00",
"151.00",
"160.00",
"200.00",
"264.00",
"344.00",
"347.00",
"430.00",
"464.00",
"622.00",
"751.00",
"1399.00",
"2510.00",
"4033.00",
"8875.00",
"11000.00",
"14874.00",
"20256.00",
"25713.00",
"28051.00",
"30518.00",
"41526.00",
"48511.00",
"56785.00",
"69700.00",
"78866.00",
"90000.00",
"103000.00",
"111369.00",
"120538.00",
"147181.00",
"181035.00",
"214969.00",
"242900.00",
"274000.00",
"309500.00",
"331689.00",
"390757.00",
"447400.00",
"505992.00",
"581730.00",
"637657.00",
"774815.00",
"912050.00",
"468.00",
"650.00",
"800.00",
"1705.00",
"2831.00",
"5130.00",
"9251.00",
"12173.00",
"17818.00",
"21056.00",
"26338.00",
"28896.00",
"36125.00",
"45227.00",
"51100.00",
"64589.00",
"71740.00",
"86600.00",
"99434.00",
"110861.00",
"117600.00",
"143100.00",
"175016.00",
"199900.00",
"238533.00",
"267668.00",
"301316.00",
"329758.00",
"357022.00",
"446550.00",
"488100.00",
"580367.00",
"622984.00",
"756626.00",
"883749.00",
"1098581.00",
"1246700.00",
"1648195.00",
"1566500.00",
"2149690.00",
"2724900.00",
"9363520.00"
"9363520.00",
"17075400.00"
]
}
Population 0 1277558000 50 JSON_HB {
"histogram_hb_v1": [
"0",
"0",
"1000",
"2500",
"8000",
"11000",
"17000",
"27000",
"38000",
"43000",
"68000",
"78000",
"99000",
"149000",
"190000",
"241000",
"307000",
"428000",
"456000",
"638000",
"885000",
"1295000",
"1726000",
"2153000",
"2662000",
"3101000",
"3520000",
"3850000",
"4023000",
"4629000",
"5074000",
"5398700",
"6188000",
"6782000",
"7733000",
"8329000",
"9586000",
"10239000",
"10730000",
"11385000",
"14786000",
"15942000",
"18886000",
"22244000",
"23115000",
"25662000",
"31471000",
"83000",
"103000",
"154000",
"214000",
"279000",
"328000",
"435700",
"578000",
"754700",
"1158000",
"1305000",
"1987800",
"2441000",
"2856000",
"3282000",
"3615000",
"3869000",
"4473000",
"4854000",
"5171300",
"5605000",
"6485000",
"7651000",
"8190900",
"9169000",
"10097000",
"10640000",
"11234000",
"12646000",
"15864000",
"18827000",
"21778000",
"22720000",
"24318000",
"31147000",
"39441700",
"50456000",
"61399000",
"59623400",
"68470000",
"111506000",
"170115000"
"170115000",
"1277558000"
]
}
Capital 1 4074 50 JSON_HB {
"histogram_hb_v1": [
"1",
"35",
"63",
"129",
"150",
"187",
"191",
"204",
"538",
"554",
"586",
"652",
"764",
"904",
"917",
"926",
"937",
"1365",
"1464",
"1532",
"1800",
"1864",
"2256",
"2317",
"2409",
"2434",
"2441",
"2454",
"2463",
"2507",
"2514",
"2696",
"2728",
"2754",
"2821",
"2884",
"2914",
"2973",
"3018",
"3064",
"3161",
"3172",
"3208",
"3225",
"3248",
"3315",
"539",
"583",
"587",
"653",
"766",
"905",
"919",
"927",
"938",
"1447",
"1522",
"1786",
"1822",
"1889",
"2295",
"2331",
"2429",
"2438",
"2447",
"2460",
"2484",
"2509",
"2690",
"2710",
"2734",
"2807",
"2882",
"2912",
"2972",
"3017",
"3063",
"3068",
"3171",
"3207",
"3217",
"3244",
"3306",
"3334",
"3358",
"3349",
"3425",
"3499",
"3537",
"3791"
"3791",
"4074"
]
}
ID 1 4079 50 JSON_HB {
"histogram_hb_v1": [
"80",
"160",
"240",
"320",
"400",
"480",
"560",
"640",
"720",
"800",
"880",
"960",
"1040",
"1120",
"1200",
"1280",
"1360",
"1440",
"1520",
"1600",
"1680",
"1760",
"1840",
"1920",
"2000",
"2080",
"2160",
"2240",
"2320",
"2400",
"2480",
"2560",
"2640",
"2720",
"2800",
"2880",
"2960",
"3040",
"3120",
"3200",
"3280",
"3360",
"3440",
"3520",
"3600",
"3680",
"3760",
"3840",
"3920",
"4000"
"1",
"82",
"164",
"245",
"327",
"408",
"490",
"572",
"653",
"735",
"816",
"898",
"979",
"1061",
"1143",
"1224",
"1306",
"1387",
"1469",
"1551",
"1632",
"1714",
"1795",
"1877",
"1958",
"2040",
"2122",
"2203",
"2285",
"2366",
"2448",
"2529",
"2611",
"2693",
"2774",
"2856",
"2937",
"3019",
"3101",
"3182",
"3264",
"3345",
"3427",
"3508",
"3590",
"3672",
"3753",
"3835",
"3916",
"3998",
"4079"
]
}
Name A Coruña (La Coruña) Ürgenc 50 JSON_HB {
"histogram_hb_v1": [
"Allentown",
"Araguari",
"Bahtim",
"Batangas",
"Bialystok",
"Brampton",
"Calama",
"Changchun",
"Ciomas",
"Cuautla",
"Detroit",
"Effon-Alaiye",
"Firozabad",
"Gebze",
"Guangyuan",
"Hangzhou",
"Hradec Králové",
"Inazawa",
"Jalib al-Shuyukh",
"Jubayl",
"Kassel",
"Kitakyushu",
"Kunshan",
"Le Mans",
"Longueuil",
"Malang",
"Mati",
"Mishan",
"Muroran",
"Natal",
"North York",
"Omsk",
"Palu",
"Phoenix",
"Poznan",
"Quezon",
"Rishra",
"Salem",
"Sancti-Spíritus",
"Sekondi-Takoradi",
"Silao",
"Stoke-on-Trent",
"Taegu",
"Teheran",
"Tomsk",
"Târgu Mures",
"Varginha",
"Weifang",
"Yangjiang",
"Zhaodong"
"A Coruña (La Coruña)",
"Almere",
"Araraquara",
"Bairiki",
"Bawshar",
"Bikaner",
"Brescia",
"Camaragibe",
"Charleroi",
"Ciudad de México",
"Córdoba",
"Dire Dawa",
"Elgin",
"Francisco Morato",
"Gijón",
"Guntur",
"Helsingborg",
"Hunjiang",
"Isesaki",
"Jevpatorija",
"Kalookan",
"Khandwa",
"Korla",
"La Rioja",
"Lilongwe",
"Lübeck",
"Maracanaú",
"Meru",
"Moradabad",
"Nakuru",
"Niihama",
"Ocumare del Tuy",
"Oxnard",
"Penza",
"Porbandar",
"Qarchak",
"Resende",
"Saint Helens",
"San Miguel",
"Saskatoon",
"Shomolu",
"Srinagar",
"São Paulo",
"Taubaté",
"Tokorozawa",
"Tšerepovets",
"Vanadzor",
"Waru",
"Yamoussoukro",
"Zhangjiang",
"Ürgenc"
]
}
Country ABW ZWE 50 JSON_HB {
"histogram_hb_v1": [
"ARM",
"BHS",
"ABW",
"ASM",
"BLR",
"BRA",
"BRA",
"BRA",
......@@ -2896,208 +2912,211 @@ Country ABW ZWE 50 JSON_HB {
"CHN",
"CHN",
"CHN",
"CHN",
"COL",
"CIV",
"CUB",
"DEU",
"DZA",
"EGY",
"ESP",
"FRA",
"GBR",
"IDN",
"GHA",
"IDN",
"IND",
"IND",
"IND",
"IND",
"IRN",
"ITA",
"ISR",
"JPN",
"JPN",
"JPN",
"KAZ",
"KOR",
"LKA",
"MDV",
"MEX",
"MEX",
"MMR",
"NGA",
"NZL",
"PER",
"NLD",
"PAK",
"PHL",
"POL",
"QAT",
"PHL",
"PRK",
"RUS",
"RUS",
"SAU",
"TCD",
"SYC",
"TUR",
"UKR",
"USA",
"USA",
"USA",
"USA",
"VNM"
"VNM",
"ZWE"
]
}
Population 42 10500000 50 JSON_HB {
"histogram_hb_v1": [
"50699",
"90601",
"92583",
"94600",
"96800",
"98781",
"100887",
"102681",
"105119",
"107329",
"109500",
"112375",
"115532",
"118718",
"121600",
"124207",
"126820",
"130000",
"133642",
"137776",
"142044",
"146439",
"151060",
"157300",
"163849",
"170428",
"176576",
"183100",
"189569",
"197254",
"206158",
"216735",
"227657",
"241649",
"254842",
"270251",
"286900",
"304477",
"326399",
"349246",
"372840",
"409100",
"443727",
"483155",
"540828",
"636765",
"764902",
"993400",
"1300977",
"2154376"
"42",
"55810",
"90646",
"92686",
"94784",
"96921",
"99155",
"101046",
"103104",
"105643",
"107761",
"110000",
"113126",
"116278",
"119503",
"122400",
"125070",
"127634",
"131480",
"135000",
"139283",
"143922",
"148362",
"154125",
"160510",
"167051",
"173627",
"179956",
"186332",
"194265",
"202134",
"212977",
"222859",
"237206",
"249263",
"265200",
"281928",
"300148",
"320296",
"342584",
"366549",
"401281",
"438638",
"479884",
"531800",
"623457",
"753778",
"977856",
"1266461",
"2130359",
"10500000"
]
}
Country ABW ZWE 50 JSON_HB {
"histogram_hb_v1": [
"ABW",
"ALB",
"ASM",
"ATG",
"AZE",
"BFA",
"BHS",
"BRA",
"CAF",
"CHE",
"CIV",
"COD",
"CPV",
"CZE",
"DOM",
"EST",
"FRA",
"GBR",
"GIN",
"GRC",
"HKG",
"BIH",
"BRB",
"CAN",
"CHL",
"CMR",
"COG",
"CRI",
"DEU",
"ECU",
"ETH",
"FRO",
"GEO",
"GMB",
"GTM",
"HND",
"IDN",
"IND",
"ISL",
"JPN",
"KGZ",
"LAO",
"LIE",
"LVA",
"MDA",
"MLI",
"MNG",
"MRT",
"MYS",
"NER",
"NIU",
"NRU",
"PAN",
"PLW",
"PYF",
"IRN",
"ITA",
"KAZ",
"KHM",
"LBR",
"LTU",
"MAR",
"MHL",
"MMR",
"MOZ",
"MUS",
"NAM",
"NGA",
"NPL",
"PAK",
"PHL",
"PRY",
"RUS",
"SDN",
"SLE",
"SVN",
"TCD",
"SVK",
"TCA",
"THA",
"TUR",
"TUN",
"TZA",
"UKR",
"UZB",
"VNM",
"ZAF"
"ZAF",
"ZWE"
]
}
Language Abhyasi [South]Mande 50 JSON_HB {
"histogram_hb_v1": [
"Abhyasi",
"Amhara",
"Arabic",
"Araucan",
"Bakhtyari",
"Arawakan",
"Balante",
"Belorussian",
"Bubi",
"Cebuano",
"Bulgariana",
"Chakma",
"Chinese",
"Comorian",
"Comorian-madagassi",
"Creole French",
"Danish",
"Embera",
"Dinka",
"English",
"English",
"English",
"Ewe",
"French",
"French",
"Futuna",
"Ful",
"Garifuna",
"German",
"Greek",
"Hakka",
"Hui",
"Gujarati",
"Herero",
"Hungarian",
"Italian",
"Joruba",
"Kazakh",
"Kongo",
"Kurdish",
"Luchazi",
"Makua",
"Malinke",
"Marshallese",
"Mixed Languages",
"Nauru",
"Nung",
"Pangasinan",
"Polish",
"Kanuri",
"Khoekhoe",
"Kosrean",
"Lithuanian",
"Macedonian",
"Malay-English",
"Maori",
"Meru",
"Mossi",
"Norwegian",
"Ouaddai",
"Pilipino",
"Portuguese",
"Romanian",
"Romani",
"Russian",
"Sara",
"Shona",
"Songhai",
"San",
"Shambala",
"Somali",
"Spanish",
"Spanish",
"Tamashek",
"Thai",
"Tswana",
"Tuvalu",
"Urdu",
"Wolea"
"Tagalog",
"Teso",
"Tswa",
"Turkmenian",
"Ukrainian and Russian",
"Wolea",
"[South]Mande"
]
}
Percentage 0.0 99.9 50 JSON_HB {
......@@ -3105,6 +3124,7 @@ Percentage 0.0 99.9 50 JSON_HB {
"0.0",
"0.0",
"0.0",
"0.0",
"0.1",
"0.2",
"0.3",
......@@ -3112,46 +3132,46 @@ Percentage 0.0 99.9 50 JSON_HB {
"0.5",
"0.6",
"0.7",
"0.8",
"0.9",
"1.1",
"1.3",
"1.4",
"1.6",
"1.8",
"2.1",
"2.3",
"2.5",
"2.9",
"3.2",
"3.5",
"3.8",
"4.4",
"4.9",
"5.5",
"5.9",
"6.6",
"7.4",
"7.8",
"8.6",
"9.2",
"10.3",
"11.5",
"12.9",
"14.6",
"17.1",
"20.3",
"23.8",
"31.8",
"39.4",
"47.5",
"55.1",
"66.5",
"77.2",
"86.0",
"89.9",
"94.3",
"97.3",
"99.0"
"1.5",
"1.7",
"1.9",
"2.2",
"2.4",
"2.7",
"3.0",
"3.3",
"3.7",
"4.1",
"4.7",
"5.3",
"5.7",
"6.4",
"7.0",
"7.6",
"8.2",
"9.0",
"9.7",
"11.0",
"12.4",
"14.0",
"16.5",
"19.7",
"23.2",
"31.0",
"36.4",
"45.7",
"52.6",
"65.3",
"76.7",
"85.6",
"89.7",
"94.1",
"97.2",
"99.0",
"99.9"
]
}
explain extended select * from Country where 'Code' between 'BBC' and 'GGG';
......
......@@ -1363,7 +1363,8 @@ bool Histogram_json_hb::parse(MEM_ROOT *mem_root, Field *field,
break;
}
}
size= histogram_bounds.size();
// n_buckets = n_bounds - 1 :
size= histogram_bounds.size()-1;
DBUG_RETURN(false);
error:
......@@ -1852,6 +1853,45 @@ class Stat_table_write_iter
}
};
/*
This is used to collect the the basic statistics from a Unique object:
- count of values
- count of distinct values
- count of distinct values that have occurred only once
*/
class Basic_stats_collector
{
ulonglong count; /* number of values retrieved */
ulonglong count_distinct; /* number of distinct values retrieved */
/* number of distinct values that occured only once */
ulonglong count_distinct_single_occurence;
public:
Basic_stats_collector()
{
count= 0;
count_distinct= 0;
count_distinct_single_occurence= 0;
}
ulonglong get_count_distinct() const { return count_distinct; }
ulonglong get_count_single_occurence() const
{
return count_distinct_single_occurence;
}
ulonglong get_count() const { return count; }
void next(void *elem, element_count elem_cnt)
{
count_distinct++;
if (elem_cnt == 1)
count_distinct_single_occurence++;
count+= elem_cnt;
}
};
/*
Histogram_builder is a helper class that is used to build histograms
for columns.
......@@ -1865,87 +1905,95 @@ class Histogram_builder
Field *column; /* table field for which the histogram is built */
uint col_length; /* size of this field */
ha_rows records; /* number of records the histogram is built for */
Histogram_builder(Field *col, uint col_len, ha_rows rows) :
column(col), col_length(col_len), records(rows)
{}
public:
// A histogram builder will also collect the counters
Basic_stats_collector counters;
virtual int next(void *elem, element_count elem_cnt)=0;
virtual void finalize()=0;
virtual ~Histogram_builder(){}
};
class Histogram_binary_builder : public Histogram_builder
{
Field *min_value; /* pointer to the minimal value for the field */
Field *max_value; /* pointer to the maximal value for the field */
Histogram_base *histogram; /* the histogram location */
Histogram_binary *histogram; /* the histogram location */
uint hist_width; /* the number of points in the histogram */
double bucket_capacity; /* number of rows in a bucket of the histogram */
uint curr_bucket; /* number of the current bucket to be built */
ulonglong count; /* number of values retrieved */
ulonglong count_distinct; /* number of distinct values retrieved */
/* number of distinct values that occured only once */
ulonglong count_distinct_single_occurence;
public:
Histogram_builder(Field *col, uint col_len, ha_rows rows)
: column(col), col_length(col_len), records(rows)
Histogram_binary_builder(Field *col, uint col_len, ha_rows rows)
: Histogram_builder(col, col_len, rows)
{
Column_statistics *col_stats= col->collected_stats;
min_value= col_stats->min_value;
max_value= col_stats->max_value;
histogram= col_stats->histogram;
histogram= (Histogram_binary*)col_stats->histogram;
hist_width= histogram->get_width();
bucket_capacity= (double) records / (hist_width + 1);
curr_bucket= 0;
count= 0;
count_distinct= 0;
count_distinct_single_occurence= 0;
}
Histogram_builder() = default;
virtual ~Histogram_builder() = default;
ulonglong get_count_distinct() const { return count_distinct; }
ulonglong get_count_single_occurence() const
{
return count_distinct_single_occurence;
}
virtual int next(void *elem, element_count elem_cnt)
int next(void *elem, element_count elem_cnt) override
{
count_distinct++;
if (elem_cnt == 1)
count_distinct_single_occurence++;
count+= elem_cnt;
counters.next(elem, elem_cnt);
ulonglong count= counters.get_count();
if (curr_bucket == hist_width)
return 0;
if (count > bucket_capacity * (curr_bucket + 1))
{
column->store_field_value((uchar *) elem, col_length);
((Histogram_binary *)histogram)->set_value(curr_bucket,
histogram->set_value(curr_bucket,
column->pos_in_interval(min_value, max_value));
curr_bucket++;
while (curr_bucket != hist_width &&
count > bucket_capacity * (curr_bucket + 1))
{
((Histogram_binary *)histogram)->set_prev_value(curr_bucket);
histogram->set_prev_value(curr_bucket);
curr_bucket++;
}
}
return 0;
}
virtual void finalize(){}
void finalize() override {}
};
Histogram_builder *Histogram_binary::create_builder(Field *col, uint col_len,
ha_rows rows)
{
return new Histogram_builder(col, col_len, rows);
return new Histogram_binary_builder(col, col_len, rows);
}
class Histogram_builder_json : public Histogram_builder
class Histogram_json_builder : public Histogram_builder
{
std::vector<std::string> bucket_bounds;
bool got_first_value = false;
Histogram_json_hb *histogram;
uint hist_width; /* the number of points in the histogram */
double bucket_capacity; /* number of rows in a bucket of the histogram */
uint curr_bucket; /* number of the current bucket to be built */
std::vector<std::string> bucket_bounds;
bool first_value= true;
public:
Histogram_builder_json(Field *col, uint col_len, ha_rows rows)
: Histogram_builder(col, col_len, rows) {}
Histogram_json_builder(Field *col, uint col_len, ha_rows rows)
: Histogram_builder(col, col_len, rows)
{
histogram= (Histogram_json_hb*)col->collected_stats->histogram;
bucket_capacity= (double)records / histogram->get_width();
hist_width= histogram->get_width();
curr_bucket= 0;
}
~Histogram_builder_json() override = default;
~Histogram_json_builder() override = default;
/*
Add data to the histogram. Adding Element elem which encountered elem_cnt
......@@ -1953,18 +2001,27 @@ class Histogram_builder_json : public Histogram_builder
*/
int next(void *elem, element_count elem_cnt) override
{
count_distinct++;
if (elem_cnt == 1)
count_distinct_single_occurence++;
count+= elem_cnt;
counters.next(elem, elem_cnt);
ulonglong count= counters.get_count();
if (curr_bucket == hist_width)
return 0;
if (count > bucket_capacity * (curr_bucket + 1))
if (first_value)
{
first_value= false;
column->store_field_value((uchar*) elem, col_length);
StringBuffer<MAX_FIELD_WIDTH> val;
column->val_str(&val);
bucket_bounds.push_back(std::string(val.ptr(), val.length()));
}
if (count > bucket_capacity * (curr_bucket + 1))
{
column->store_field_value((uchar*) elem, col_length);
StringBuffer<MAX_FIELD_WIDTH> val;
column->val_str(&val);
bucket_bounds.emplace_back(val.ptr(), val.length());
curr_bucket++;
while (curr_bucket != hist_width &&
count > bucket_capacity * (curr_bucket + 1))
......@@ -1973,6 +2030,14 @@ class Histogram_builder_json : public Histogram_builder
curr_bucket++;
}
}
if (records == count && bucket_bounds.size() == hist_width)
{
column->store_field_value((uchar*) elem, col_length);
StringBuffer<MAX_FIELD_WIDTH> val;
column->val_str(&val);
bucket_bounds.push_back(std::string(val.ptr(), val.length()));
}
return 0;
}
......@@ -1991,8 +2056,8 @@ class Histogram_builder_json : public Histogram_builder
writer.end_array();
writer.end_object();
Binary_string *json_string = (Binary_string *) writer.output.get_string();
Histogram_json_hb *hist= (Histogram_json_hb*)histogram;
hist->set_json_text(bucket_bounds.size(), (uchar *) json_string->c_ptr());
histogram->set_json_text(bucket_bounds.size()-1,
(uchar *) json_string->c_ptr());
}
};
......@@ -2000,12 +2065,10 @@ class Histogram_builder_json : public Histogram_builder
Histogram_builder *Histogram_json_hb::create_builder(Field *col, uint col_len,
ha_rows rows)
{
return new Histogram_builder_json(col, col_len, rows);
return new Histogram_json_builder(col, col_len, rows);
}
Histogram_base *create_histogram(MEM_ROOT *mem_root, Histogram_type hist_type,
THD *owner)
{
......@@ -2036,13 +2099,10 @@ static int histogram_build_walk(void *elem, element_count elem_cnt, void *arg)
return hist_builder->next(elem, elem_cnt);
}
static int count_distinct_single_occurence_walk(void *elem,
element_count count, void *arg)
int basic_stats_collector_walk(void *elem, element_count count,
void *arg)
{
((ulonglong*)arg)[0]+= 1;
if (count == 1)
((ulonglong*)arg)[1]+= 1;
((Basic_stats_collector*)arg)->next(elem, count);
return 0;
}
......@@ -2127,11 +2187,11 @@ class Count_distinct_field: public Sql_alloc
*/
void walk_tree()
{
ulonglong counts[2] = {0, 0};
tree->walk(table_field->table,
count_distinct_single_occurence_walk, counts);
distincts= counts[0];
distincts_single_occurence= counts[1];
Basic_stats_collector stats_collector;
tree->walk(table_field->table, basic_stats_collector_walk,
(void*)&stats_collector );
distincts= stats_collector.get_count_distinct();
distincts_single_occurence= stats_collector.get_count_single_occurence();
}
/*
......@@ -2147,8 +2207,9 @@ class Count_distinct_field: public Sql_alloc
tree->walk(table_field->table, histogram_build_walk,
(void *) hist_builder);
hist_builder->finalize();
distincts= hist_builder->get_count_distinct();
distincts_single_occurence= hist_builder->get_count_single_occurence();
distincts= hist_builder->counters.get_count_distinct();
distincts_single_occurence= hist_builder->counters.
get_count_single_occurence();
delete hist_builder;
}
......
......@@ -403,7 +403,8 @@ class Histogram_json_hb : public Histogram_base
return size;
}
void init_for_collection(MEM_ROOT *mem_root, Histogram_type htype_arg, ulonglong size) override;
void init_for_collection(MEM_ROOT *mem_root, Histogram_type htype_arg,
ulonglong size) override;
bool is_available() override {return true; }
......
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