summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/mysqld--help.result18
-rw-r--r--mysql-test/r/selectivity.result111
-rw-r--r--mysql-test/r/selectivity_innodb.result113
-rw-r--r--mysql-test/r/statistics.result468
-rw-r--r--mysql-test/r/system_mysql_db.result2
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_mysql.result5
-rw-r--r--mysql-test/suite/sys_vars/r/histogram_size_basic.result136
-rw-r--r--mysql-test/suite/sys_vars/r/optimizer_use_condition_selectivity_basic.result8
-rw-r--r--mysql-test/suite/sys_vars/t/histogram_size_basic.test142
-rw-r--r--mysql-test/suite/sys_vars/t/optimizer_use_condition_selectivity_basic.test4
-rw-r--r--mysql-test/t/selectivity.test22
-rw-r--r--mysql-test/t/statistics.test17
12 files changed, 815 insertions, 231 deletions
diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result
index afa3a2ac3af..1804bd1c6fb 100644
--- a/mysql-test/r/mysqld--help.result
+++ b/mysql-test/r/mysqld--help.result
@@ -202,6 +202,8 @@ The following options may be given as the first argument:
The maximum length of the result of function
GROUP_CONCAT()
-?, --help Display this help and exit.
+ --histogram-size=# Number of bytes used for a histogram. If set to 0, no
+ histograms are created by ANALYZE.
--ignore-builtin-innodb
Disable initialization of builtin InnoDB plugin
--ignore-db-dirs=name
@@ -505,13 +507,16 @@ The following options may be given as the first argument:
takes into account to calculate cardinality of a partial
join when it searches for the best execution plan
Meaning: 1 - use selectivity of index backed range
- conditions to calculate cardinality of the partial join
+ conditions to calculate the cardinality of a partial join
if the last joined table is accessed by full table scan
- or an index scan 2 - use selectivity of index backed
- range conditions to calculate cardinality of the partial
- join in any case 3 - additionally always use selectivity
- of range conditions that are not backed by any index to
- calculate cardinality of the partial join
+ or an index scan, 2 - use selectivity of index backed
+ range conditions to calculate the cardinality of a
+ partial join in any case, 3 - additionally always use
+ selectivity of range conditions that are not backed by
+ any index to calculate the cardinality of a partial join,
+ 4 - use histograms to calculate selectivity of range
+ conditions that are not backed by any index to calculate
+ the cardinality of a partial join.
--performance-schema
Enable the performance schema.
--performance-schema-events-waits-history-long-size=#
@@ -926,6 +931,7 @@ gdb FALSE
general-log FALSE
group-concat-max-len 1024
help TRUE
+histogram-size 0
ignore-builtin-innodb FALSE
ignore-db-dirs
init-connect
diff --git a/mysql-test/r/selectivity.result b/mysql-test/r/selectivity.result
index 3db8da46ea2..af3f6fdda2d 100644
--- a/mysql-test/r/selectivity.result
+++ b/mysql-test/r/selectivity.result
@@ -10,6 +10,7 @@ DROP DATABASE IF EXISTS dbt3_s001;
CREATE DATABASE dbt3_s001;
use dbt3_s001;
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
+set @save_histogram_size=@@histogram_size;
EXPLAIN EXTENDED select sql_calc_found_rows
s_name, s_address
from supplier, nation
@@ -84,7 +85,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
2 MATERIALIZED part ALL PRIMARY NULL NULL NULL 200 4.17 Using where
2 MATERIALIZED partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where
-4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 100.00 Using where
+4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 15.14 Using where
Warnings:
Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2
Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2
@@ -109,6 +110,114 @@ order by s_name
limit 10;
s_name s_address
Supplier#000000010 Saygah3gYWMp72i PY
+set histogram_size=15;
+flush table part;
+ANALYZE TABLE part PERSISTENT FOR COLUMNS(p_name) INDEXES();
+Table Op Msg_type Msg_text
+dbt3_s001.part analyze status Table is already up to date
+set optimizer_use_condition_selectivity=4;
+EXPLAIN EXTENDED select sql_calc_found_rows
+s_name, s_address
+from supplier, nation
+where s_suppkey in (select ps_suppkey from partsupp
+where ps_partkey in (select p_partkey from part
+where p_name like 'g%')
+and ps_availqty >
+(select 0.5 * sum(l_quantity)
+from lineitem
+where l_partkey = ps_partkey
+and l_suppkey = ps_suppkey
+and l_shipdate >= date('1993-01-01')
+and l_shipdate < date('1993-01-01') +
+interval '1' year ))
+and s_nationkey = n_nationkey
+and n_name = 'UNITED STATES'
+order by s_name
+limit 10;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY nation ALL PRIMARY NULL NULL NULL 25 4.00 Using where; Using temporary; Using filesort
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00
+1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 6.25 Using where
+1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00 Using where; FirstMatch(supplier)
+4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 15.14 Using where
+Warnings:
+Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2
+Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2
+Note 1003 select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where ((`dbt3_s001`.`partsupp`.`ps_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey`) and (`dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey`) and (`dbt3_s001`.`nation`.`n_name` = 'UNITED STATES') and (`dbt3_s001`.`supplier`.`s_nationkey` = `dbt3_s001`.`nation`.`n_nationkey`) and (`dbt3_s001`.`partsupp`.`ps_availqty` > <expr_cache><`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((select (0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`)) from `dbt3_s001`.`lineitem` where ((`dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`) and (`dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey`) and (`dbt3_s001`.`lineitem`.`l_shipDATE` >= <cache>(cast('1993-01-01' as date))) and (`dbt3_s001`.`lineitem`.`l_shipDATE` < <cache>((cast('1993-01-01' as date) + interval '1' year))))))) and (`dbt3_s001`.`part`.`p_name` like 'g%')) order by `dbt3_s001`.`supplier`.`s_name` limit 10
+select sql_calc_found_rows
+s_name, s_address
+from supplier, nation
+where s_suppkey in (select ps_suppkey from partsupp
+where ps_partkey in (select p_partkey from part
+where p_name like 'g%')
+and ps_availqty >
+(select 0.5 * sum(l_quantity)
+from lineitem
+where l_partkey = ps_partkey
+and l_suppkey = ps_suppkey
+and l_shipdate >= date('1993-01-01')
+and l_shipdate < date('1993-01-01') +
+interval '1' year ))
+and s_nationkey = n_nationkey
+and n_name = 'UNITED STATES'
+order by s_name
+limit 10;
+s_name s_address
+Supplier#000000010 Saygah3gYWMp72i PY
+set histogram_size=24;
+flush table nation;
+ANALYZE TABLE nation PERSISTENT FOR COLUMNS(n_name) INDEXES();
+Table Op Msg_type Msg_text
+dbt3_s001.nation analyze status Table is already up to date
+EXPLAIN EXTENDED select sql_calc_found_rows
+s_name, s_address
+from supplier, nation
+where s_suppkey in (select ps_suppkey from partsupp
+where ps_partkey in (select p_partkey from part
+where p_name like 'g%')
+and ps_availqty >
+(select 0.5 * sum(l_quantity)
+from lineitem
+where l_partkey = ps_partkey
+and l_suppkey = ps_suppkey
+and l_shipdate >= date('1993-01-01')
+and l_shipdate < date('1993-01-01') +
+interval '1' year ))
+and s_nationkey = n_nationkey
+and n_name = 'UNITED STATES'
+order by s_name
+limit 10;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY nation ALL PRIMARY NULL NULL NULL 25 4.00 Using where; Using temporary; Using filesort
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00
+1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 6.25 Using where
+1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00 Using where; FirstMatch(supplier)
+4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 15.14 Using where
+Warnings:
+Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2
+Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2
+Note 1003 select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where ((`dbt3_s001`.`partsupp`.`ps_suppkey` = `dbt3_s001`.`supplier`.`s_suppkey`) and (`dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey`) and (`dbt3_s001`.`nation`.`n_name` = 'UNITED STATES') and (`dbt3_s001`.`supplier`.`s_nationkey` = `dbt3_s001`.`nation`.`n_nationkey`) and (`dbt3_s001`.`partsupp`.`ps_availqty` > <expr_cache><`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((select (0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`)) from `dbt3_s001`.`lineitem` where ((`dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`) and (`dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey`) and (`dbt3_s001`.`lineitem`.`l_shipDATE` >= <cache>(cast('1993-01-01' as date))) and (`dbt3_s001`.`lineitem`.`l_shipDATE` < <cache>((cast('1993-01-01' as date) + interval '1' year))))))) and (`dbt3_s001`.`part`.`p_name` like 'g%')) order by `dbt3_s001`.`supplier`.`s_name` limit 10
+select sql_calc_found_rows
+s_name, s_address
+from supplier, nation
+where s_suppkey in (select ps_suppkey from partsupp
+where ps_partkey in (select p_partkey from part
+where p_name like 'g%')
+and ps_availqty >
+(select 0.5 * sum(l_quantity)
+from lineitem
+where l_partkey = ps_partkey
+and l_suppkey = ps_suppkey
+and l_shipdate >= date('1993-01-01')
+and l_shipdate < date('1993-01-01') +
+interval '1' year ))
+and s_nationkey = n_nationkey
+and n_name = 'UNITED STATES'
+order by s_name
+limit 10;
+s_name s_address
+Supplier#000000010 Saygah3gYWMp72i PY
DROP DATABASE dbt3_s001;
+set histogram_size=@save_histogram_size;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set use_stat_tables=@save_use_stat_tables;
diff --git a/mysql-test/r/selectivity_innodb.result b/mysql-test/r/selectivity_innodb.result
index 0a6abfd66d3..9ececad3492 100644
--- a/mysql-test/r/selectivity_innodb.result
+++ b/mysql-test/r/selectivity_innodb.result
@@ -13,6 +13,7 @@ DROP DATABASE IF EXISTS dbt3_s001;
CREATE DATABASE dbt3_s001;
use dbt3_s001;
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
+set @save_histogram_size=@@histogram_size;
EXPLAIN EXTENDED select sql_calc_found_rows
s_name, s_address
from supplier, nation
@@ -87,7 +88,116 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
2 MATERIALIZED part ALL PRIMARY NULL NULL NULL 200 4.17 Using where
2 MATERIALIZED partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where
-4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 100.00 Using where
+4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 14.37 Using where
+Warnings:
+Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2
+Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2
+Note 1003 select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where ((`dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey`) and (`dbt3_s001`.`nation`.`n_name` = 'UNITED STATES') and (`dbt3_s001`.`supplier`.`s_nationkey` = `dbt3_s001`.`nation`.`n_nationkey`) and (`dbt3_s001`.`partsupp`.`ps_availqty` > <expr_cache><`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((select (0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`)) from `dbt3_s001`.`lineitem` where ((`dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`) and (`dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey`) and (`dbt3_s001`.`lineitem`.`l_shipDATE` >= <cache>(cast('1993-01-01' as date))) and (`dbt3_s001`.`lineitem`.`l_shipDATE` < <cache>((cast('1993-01-01' as date) + interval '1' year))))))) and (`dbt3_s001`.`part`.`p_name` like 'g%')) order by `dbt3_s001`.`supplier`.`s_name` limit 10
+select sql_calc_found_rows
+s_name, s_address
+from supplier, nation
+where s_suppkey in (select ps_suppkey from partsupp
+where ps_partkey in (select p_partkey from part
+where p_name like 'g%')
+and ps_availqty >
+(select 0.5 * sum(l_quantity)
+from lineitem
+where l_partkey = ps_partkey
+and l_suppkey = ps_suppkey
+and l_shipdate >= date('1993-01-01')
+and l_shipdate < date('1993-01-01') +
+interval '1' year ))
+and s_nationkey = n_nationkey
+and n_name = 'UNITED STATES'
+order by s_name
+limit 10;
+s_name s_address
+Supplier#000000010 Saygah3gYWMp72i PY
+set histogram_size=15;
+flush table part;
+ANALYZE TABLE part PERSISTENT FOR COLUMNS(p_name) INDEXES();
+Table Op Msg_type Msg_text
+dbt3_s001.part analyze status OK
+set optimizer_use_condition_selectivity=4;
+EXPLAIN EXTENDED select sql_calc_found_rows
+s_name, s_address
+from supplier, nation
+where s_suppkey in (select ps_suppkey from partsupp
+where ps_partkey in (select p_partkey from part
+where p_name like 'g%')
+and ps_availqty >
+(select 0.5 * sum(l_quantity)
+from lineitem
+where l_partkey = ps_partkey
+and l_suppkey = ps_suppkey
+and l_shipdate >= date('1993-01-01')
+and l_shipdate < date('1993-01-01') +
+interval '1' year ))
+and s_nationkey = n_nationkey
+and n_name = 'UNITED STATES'
+order by s_name
+limit 10;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY nation ALL PRIMARY NULL NULL NULL 25 4.00 Using where; Using temporary; Using filesort
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
+2 MATERIALIZED part ALL PRIMARY NULL NULL NULL 200 6.25 Using where
+2 MATERIALIZED partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where
+4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 14.37 Using where
+Warnings:
+Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2
+Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2
+Note 1003 select sql_calc_found_rows `dbt3_s001`.`supplier`.`s_name` AS `s_name`,`dbt3_s001`.`supplier`.`s_address` AS `s_address` from `dbt3_s001`.`supplier` semi join (`dbt3_s001`.`part` join `dbt3_s001`.`partsupp`) join `dbt3_s001`.`nation` where ((`dbt3_s001`.`partsupp`.`ps_partkey` = `dbt3_s001`.`part`.`p_partkey`) and (`dbt3_s001`.`nation`.`n_name` = 'UNITED STATES') and (`dbt3_s001`.`supplier`.`s_nationkey` = `dbt3_s001`.`nation`.`n_nationkey`) and (`dbt3_s001`.`partsupp`.`ps_availqty` > <expr_cache><`dbt3_s001`.`partsupp`.`ps_partkey`,`dbt3_s001`.`partsupp`.`ps_suppkey`>((select (0.5 * sum(`dbt3_s001`.`lineitem`.`l_quantity`)) from `dbt3_s001`.`lineitem` where ((`dbt3_s001`.`lineitem`.`l_partkey` = `dbt3_s001`.`partsupp`.`ps_partkey`) and (`dbt3_s001`.`lineitem`.`l_suppkey` = `dbt3_s001`.`partsupp`.`ps_suppkey`) and (`dbt3_s001`.`lineitem`.`l_shipDATE` >= <cache>(cast('1993-01-01' as date))) and (`dbt3_s001`.`lineitem`.`l_shipDATE` < <cache>((cast('1993-01-01' as date) + interval '1' year))))))) and (`dbt3_s001`.`part`.`p_name` like 'g%')) order by `dbt3_s001`.`supplier`.`s_name` limit 10
+select sql_calc_found_rows
+s_name, s_address
+from supplier, nation
+where s_suppkey in (select ps_suppkey from partsupp
+where ps_partkey in (select p_partkey from part
+where p_name like 'g%')
+and ps_availqty >
+(select 0.5 * sum(l_quantity)
+from lineitem
+where l_partkey = ps_partkey
+and l_suppkey = ps_suppkey
+and l_shipdate >= date('1993-01-01')
+and l_shipdate < date('1993-01-01') +
+interval '1' year ))
+and s_nationkey = n_nationkey
+and n_name = 'UNITED STATES'
+order by s_name
+limit 10;
+s_name s_address
+Supplier#000000010 Saygah3gYWMp72i PY
+set histogram_size=24;
+flush table nation;
+ANALYZE TABLE nation PERSISTENT FOR COLUMNS(n_name) INDEXES();
+Table Op Msg_type Msg_text
+dbt3_s001.nation analyze status OK
+EXPLAIN EXTENDED select sql_calc_found_rows
+s_name, s_address
+from supplier, nation
+where s_suppkey in (select ps_suppkey from partsupp
+where ps_partkey in (select p_partkey from part
+where p_name like 'g%')
+and ps_availqty >
+(select 0.5 * sum(l_quantity)
+from lineitem
+where l_partkey = ps_partkey
+and l_suppkey = ps_suppkey
+and l_shipdate >= date('1993-01-01')
+and l_shipdate < date('1993-01-01') +
+interval '1' year ))
+and s_nationkey = n_nationkey
+and n_name = 'UNITED STATES'
+order by s_name
+limit 10;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY nation ALL PRIMARY NULL NULL NULL 25 4.00 Using where; Using temporary; Using filesort
+1 PRIMARY supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1 100.00
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
+2 MATERIALIZED part ALL PRIMARY NULL NULL NULL 200 6.25 Using where
+2 MATERIALIZED partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where
+4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 14.37 Using where
Warnings:
Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2
Note 1276 Field or reference 'dbt3_s001.partsupp.ps_suppkey' of SELECT #4 was resolved in SELECT #2
@@ -113,6 +223,7 @@ limit 10;
s_name s_address
Supplier#000000010 Saygah3gYWMp72i PY
DROP DATABASE dbt3_s001;
+set histogram_size=@save_histogram_size;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set use_stat_tables=@save_use_stat_tables;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
diff --git a/mysql-test/r/statistics.result b/mysql-test/r/statistics.result
index ba0390f98db..2abff4416c9 100644
--- a/mysql-test/r/statistics.result
+++ b/mysql-test/r/statistics.result
@@ -64,13 +64,13 @@ SELECT * FROM mysql.table_stats;
db_name table_name cardinality
test t1 40
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -87,8 +87,8 @@ COUNT(*)
40
SELECT * FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='a';
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
SELECT MIN(t1.a), MAX(t1.a),
(SELECT COUNT(*) FROM t1 WHERE t1.b IS NULL) /
(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.a)",
@@ -99,8 +99,8 @@ MIN(t1.a) MAX(t1.a) NULLS_RATIO(t1.a) AVG_FREQUENCY(t1.a)
0 49 0.2000 1.0000
SELECT * FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='b';
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
SELECT MIN(t1.b), MAX(t1.b),
(SELECT COUNT(*) FROM t1 WHERE t1.b IS NULL) /
(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.b)",
@@ -111,8 +111,8 @@ MIN(t1.b) MAX(t1.b) NULLS_RATIO(t1.b) AVG_FREQUENCY(t1.b)
vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000
SELECT * FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='c';
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
SELECT MIN(t1.c), MAX(t1.c),
(SELECT COUNT(*) FROM t1 WHERE t1.c IS NULL) /
(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.c)",
@@ -123,8 +123,8 @@ MIN(t1.c) MAX(t1.c) NULLS_RATIO(t1.c) AVG_FREQUENCY(t1.c)
aaaa dddddddd 0.1250 7.0000
SELECT * FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='d';
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
SELECT MIN(t1.d), MAX(t1.d),
(SELECT COUNT(*) FROM t1 WHERE t1.d IS NULL) /
(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.d)",
@@ -135,8 +135,8 @@ MIN(t1.d) MAX(t1.d) NULLS_RATIO(t1.d) AVG_FREQUENCY(t1.d)
1989-03-12 1999-07-23 0.1500 8.5000
SELECT * FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='e';
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
SELECT MIN(t1.e), MAX(t1.e),
(SELECT COUNT(*) FROM t1 WHERE t1.e IS NULL) /
(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.e)",
@@ -206,6 +206,28 @@ WHERE t1.e IS NOT NULL AND t1.b IS NOT NULL AND t1.d IS NOT NULL)
AS 'ARITY 3';
ARITY 1 ARITY 2 ARITY 3
6.2000 1.6875 1.1304
+DELETE FROM mysql.column_stats;
+set histogram_size=4;
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Table is already up to date
+SELECT db_name, table_name, column_name,
+min_value, max_value,
+nulls_ratio, avg_frequency,
+hist_size, HEX(histogram)
+FROM mysql.column_stats;
+db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size HEX(histogram)
+test t1 a 0 49 0.0000 1.0000 4 2E62A1D0
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 003FBFFF
+test t1 c aaaa dddddddd 0.1250 7.0000 4 0055AAFF
+test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 009393FF
+test t1 e 0.01 0.112 0.2250 6.2000 4 000564E1
+test t1 f 1 5 0.2000 6.4000 4 3F7FBFBF
+DELETE FROM mysql.column_stats;
+set histogram_size= 0;
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Table is already up to date
CREATE TABLE t3 (
a int NOT NULL PRIMARY KEY,
b varchar(32),
@@ -238,16 +260,16 @@ db_name table_name cardinality
test t1 40
test t3 17
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
-test t3 a 0 38 0.0000 4.0000 1.0000
-test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000
-test t3 c aaaa dddddddd 0.1176 6.4000 3.7500
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
+test t3 a 0 38 0.0000 4.0000 1.0000 0 NULL
+test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000 0 NULL
+test t3 c aaaa dddddddd 0.1176 6.4000 3.7500 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -267,16 +289,16 @@ db_name table_name cardinality
test s1 40
test t3 17
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test s1 a 0 49 0.0000 4.0000 1.0000
-test s1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test s1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test s1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test s1 e 0.01 0.112 0.2250 8.0000 6.2000
-test s1 f 1 5 0.2000 1.0000 6.4000
-test t3 a 0 38 0.0000 4.0000 1.0000
-test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000
-test t3 c aaaa dddddddd 0.1176 6.4000 3.7500
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test s1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test s1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test s1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test s1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test s1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test s1 f 1 5 0.2000 1.0000 6.4000 0 NULL
+test t3 a 0 38 0.0000 4.0000 1.0000 0 NULL
+test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000 0 NULL
+test t3 c aaaa dddddddd 0.1176 6.4000 3.7500 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test s1 PRIMARY 1 1.0000
@@ -296,16 +318,16 @@ db_name table_name cardinality
test t1 40
test t3 17
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
-test t3 a 0 38 0.0000 4.0000 1.0000
-test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000
-test t3 c aaaa dddddddd 0.1176 6.4000 3.7500
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
+test t3 a 0 38 0.0000 4.0000 1.0000 0 NULL
+test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000 0 NULL
+test t3 c aaaa dddddddd 0.1176 6.4000 3.7500 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -324,13 +346,13 @@ SELECT * FROM mysql.table_stats;
db_name table_name cardinality
test t1 40
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -365,13 +387,13 @@ t1 CREATE TABLE `t1` (
KEY `idx4` (`y`,`x`,`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 x vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 y 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 x vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 y 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
ALTER TABLE t1 CHANGE COLUMN x b varchar(32),
CHANGE COLUMN y e double;
SHOW CREATE TABLE t1;
@@ -390,13 +412,13 @@ t1 CREATE TABLE `t1` (
KEY `idx4` (`e`,`b`,`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
ALTER TABLE t1 RENAME TO s1, CHANGE COLUMN b x varchar(32);
SHOW CREATE TABLE s1;
Table Create Table
@@ -417,13 +439,13 @@ SELECT * FROM mysql.table_stats;
db_name table_name cardinality
test s1 40
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test s1 a 0 49 0.0000 4.0000 1.0000
-test s1 x vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test s1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test s1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test s1 e 0.01 0.112 0.2250 8.0000 6.2000
-test s1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test s1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test s1 x vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test s1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test s1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test s1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test s1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test s1 PRIMARY 1 1.0000
@@ -455,13 +477,13 @@ SELECT * FROM mysql.table_stats;
db_name table_name cardinality
test t1 40
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -490,12 +512,12 @@ t1 CREATE TABLE `t1` (
KEY `idx4` (`e`,`x`,`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -519,12 +541,12 @@ t1 CREATE TABLE `t1` (
KEY `idx4` (`e`,`b`,`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -535,13 +557,13 @@ ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx4);
Table Op Msg_type Msg_text
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -576,12 +598,12 @@ t1 CREATE TABLE `t1` (
KEY `idx4` (`e`,`x`,`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -605,12 +627,12 @@ t1 CREATE TABLE `t1` (
KEY `idx4` (`e`,`b`,`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -624,13 +646,13 @@ LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/save_index_stats'
INTO TABLE mysql.index_stats
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -658,12 +680,12 @@ t1 CREATE TABLE `t1` (
KEY `idx4` (`e`,`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -721,12 +743,12 @@ t1 CREATE TABLE `t1` (
KEY `idx4` (`e`,`b`,`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -735,13 +757,13 @@ ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4);
Table Op Msg_type Msg_text
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 b NULL NULL 1.0000 NULL NULL
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 b NULL NULL 1.0000 NULL NULL 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -758,13 +780,13 @@ ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4);
Table Op Msg_type Msg_text
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -790,12 +812,12 @@ t1 CREATE TABLE `t1` (
KEY `idx3` (`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -820,12 +842,12 @@ t1 CREATE TABLE `t1` (
KEY `idx4` (`e`,`b`,`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -834,13 +856,13 @@ ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4);
Table Op Msg_type Msg_text
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -862,7 +884,7 @@ SELECT * FROM mysql.table_stats;
db_name table_name cardinality
test t1 40
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(c,e,b) INDEXES(idx2,idx4);
@@ -872,10 +894,10 @@ SELECT * FROM mysql.table_stats;
db_name table_name cardinality
test t1 40
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 idx2 1 7.0000
@@ -912,13 +934,13 @@ SELECT * FROM mysql.table_stats;
db_name table_name cardinality
test t1 40
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -942,19 +964,19 @@ db_name table_name cardinality
test t1 40
test t2 40
SELECT * FROM mysql.column_stats ORDER BY column_name;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t2 a 0 49 0.0000 4.0000 1.0000
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test t2 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t2 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t2 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t2 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
-test t2 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t2 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test t2 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t2 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t2 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t2 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
+test t2 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
@@ -986,13 +1008,13 @@ SELECT * FROM mysql.table_stats;
db_name table_name cardinality
test t2 40
SELECT * FROM mysql.column_stats ORDER BY column_name;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t2 a 0 49 0.0000 4.0000 1.0000
-test t2 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
-test t2 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t2 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t2 e 0.01 0.112 0.2250 8.0000 6.2000
-test t2 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t2 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t2 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL
+test t2 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t2 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t2 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t2 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
db_name table_name index_name prefix_arity avg_frequency
test t2 PRIMARY 1 1.0000
@@ -1122,12 +1144,12 @@ MODIFY COLUMN b text,
ADD INDEX idx1 (b(4), e),
ADD INDEX idx4 (e, b(4), d);
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t2 a 0 49 0.0000 4.0000 1.0000
-test t2 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t2 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t2 e 0.01 0.112 0.2250 8.0000 6.2000
-test t2 f 1 5 0.2000 1.0000 6.4000
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t2 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t2 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t2 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t2 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t2 f 1 5 0.2000 1.0000 6.4000 0 NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t2 idx3 1 8.5000
@@ -1143,18 +1165,18 @@ ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t2 a 0 49 0.0000 4.0000 1.0000
-test t2 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t2 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t2 e 0.01 0.112 0.2250 8.0000 6.2000
-test t2 f 1 5 0.2000 1.0000 6.4000
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
-test t1 b NULL NULL 0.2000 17.1250 NULL
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t2 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t2 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t2 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t2 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t2 f 1 5 0.2000 1.0000 6.4000 0 NULL
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
+test t1 b NULL NULL 0.2000 17.1250 NULL NULL NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t2 idx3 1 8.5000
@@ -1187,7 +1209,7 @@ mysql.column_stats analyze status OK
SELECT * FROM mysql.table_stats;
db_name table_name cardinality
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
set use_stat_tables='never';
@@ -1198,13 +1220,13 @@ SELECT * FROM mysql.table_stats;
db_name table_name cardinality
test t1 40
SELECT * FROM mysql.column_stats;
-db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
-test t1 a 0 49 0.0000 4.0000 1.0000
-test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
-test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
-test t1 e 0.01 0.112 0.2250 8.0000 6.2000
-test t1 f 1 5 0.2000 1.0000 6.4000
-test t1 b NULL NULL 0.2000 17.1250 NULL
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size histogram
+test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL
+test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL
+test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL
+test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL
+test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL
+test t1 b NULL NULL 0.2000 17.1250 NULL NULL NULL
SELECT * FROM mysql.index_stats;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
diff --git a/mysql-test/r/system_mysql_db.result b/mysql-test/r/system_mysql_db.result
index 4bd5c45d944..4ceedffa5cb 100644
--- a/mysql-test/r/system_mysql_db.result
+++ b/mysql-test/r/system_mysql_db.result
@@ -286,6 +286,8 @@ column_stats CREATE TABLE `column_stats` (
`nulls_ratio` decimal(12,4) DEFAULT NULL,
`avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
+ `hist_size` tinyint(3) unsigned DEFAULT NULL,
+ `histogram` varbinary(255) DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Columns'
show create table index_stats;
diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql.result b/mysql-test/suite/funcs_1/r/is_columns_mysql.result
index df3ca6b366d..bcd9c14f307 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result
@@ -13,6 +13,8 @@ def mysql column_stats avg_frequency 8 NULL YES decimal NULL NULL 12 4 NULL NULL
def mysql column_stats avg_length 7 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) select,insert,update,references
def mysql column_stats column_name 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
def mysql column_stats db_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
+def mysql column_stats histogram 10 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255) select,insert,update,references
+def mysql column_stats hist_size 9 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned select,insert,update,references
def mysql column_stats max_value 5 NULL YES varchar 255 765 NULL NULL NULL utf8 utf8_bin varchar(255) select,insert,update,references
def mysql column_stats min_value 4 NULL YES varchar 255 765 NULL NULL NULL utf8 utf8_bin varchar(255) select,insert,update,references
def mysql column_stats nulls_ratio 6 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) select,insert,update,references
@@ -256,6 +258,7 @@ ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
1.0000 blob NULL NULL
1.0000 longblob NULL NULL
+1.0000 varbinary NULL NULL
1.0000 char latin1 latin1_bin
1.0000 char latin1 latin1_swedish_ci
1.0000 varchar latin1 latin1_swedish_ci
@@ -328,6 +331,8 @@ NULL mysql columns_priv Timestamp timestamp NULL NULL NULL NULL timestamp
NULL mysql column_stats nulls_ratio decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats avg_length decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats avg_frequency decimal NULL NULL NULL NULL decimal(12,4)
+NULL mysql column_stats hist_size tinyint NULL NULL NULL NULL tinyint(3) unsigned
+1.0000 mysql column_stats histogram varbinary 255 255 NULL NULL varbinary(255)
3.0000 mysql db Host char 60 180 utf8 utf8_bin char(60)
3.0000 mysql db Db char 64 192 utf8 utf8_bin char(64)
3.0000 mysql db User char 16 48 utf8 utf8_bin char(16)
diff --git a/mysql-test/suite/sys_vars/r/histogram_size_basic.result b/mysql-test/suite/sys_vars/r/histogram_size_basic.result
new file mode 100644
index 00000000000..1f310600d00
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/histogram_size_basic.result
@@ -0,0 +1,136 @@
+SET @start_global_value = @@global.histogram_size;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.histogram_size;
+SELECT @start_session_value;
+@start_session_value
+0
+'#--------------------FN_DYNVARS_053_01-------------------------#'
+SET @@global.histogram_size = DEFAULT;
+SELECT @@global.histogram_size;
+@@global.histogram_size
+0
+SET @@session.histogram_size = DEFAULT;
+SELECT @@session.histogram_size;
+@@session.histogram_size
+0
+'#--------------------FN_DYNVARS_053_03-------------------------#'
+SET @@global.histogram_size = 1;
+SELECT @@global.histogram_size;
+@@global.histogram_size
+1
+SET @@global.histogram_size = 31;
+SELECT @@global.histogram_size;
+@@global.histogram_size
+31
+SET @@global.histogram_size = 255;
+SELECT @@global.histogram_size;
+@@global.histogram_size
+255
+'#--------------------FN_DYNVARS_053_04-------------------------#'
+SET @@session.histogram_size = 1;
+SELECT @@session.histogram_size;
+@@session.histogram_size
+1
+SET @@session.histogram_size = 31;
+SELECT @@session.histogram_size;
+@@session.histogram_size
+31
+SET @@session.histogram_size = 255;
+SELECT @@session.histogram_size;
+@@session.histogram_size
+255
+'#------------------FN_DYNVARS_053_05-----------------------#'
+SET @@global.histogram_size = -1;
+Warnings:
+Warning 1292 Truncated incorrect histogram_size value: '-1'
+SELECT @@global.histogram_size;
+@@global.histogram_size
+0
+SET @@global.histogram_size = 256;
+Warnings:
+Warning 1292 Truncated incorrect histogram_size value: '256'
+SELECT @@global.histogram_size;
+@@global.histogram_size
+255
+SET @@global.histogram_size = 1024;
+Warnings:
+Warning 1292 Truncated incorrect histogram_size value: '1024'
+SELECT @@global.histogram_size;
+@@global.histogram_size
+255
+SET @@global.histogram_size = 4.5;
+ERROR 42000: Incorrect argument type to variable 'histogram_size'
+SELECT @@global.histogram_size;
+@@global.histogram_size
+255
+SET @@global.histogram_size = test;
+ERROR 42000: Incorrect argument type to variable 'histogram_size'
+SELECT @@global.histogram_size;
+@@global.histogram_size
+255
+SET @@session.histogram_size = -1;
+Warnings:
+Warning 1292 Truncated incorrect histogram_size value: '-1'
+SELECT @@session.histogram_size;
+@@session.histogram_size
+0
+SET @@session.histogram_size = 256;
+Warnings:
+Warning 1292 Truncated incorrect histogram_size value: '256'
+SELECT @@session.histogram_size;
+@@session.histogram_size
+255
+SET @@session.histogram_size = 1024;
+Warnings:
+Warning 1292 Truncated incorrect histogram_size value: '1024'
+SELECT @@session.histogram_size;
+@@session.histogram_size
+255
+SET @@session.histogram_size = 4.5;
+ERROR 42000: Incorrect argument type to variable 'histogram_size'
+SELECT @@session.histogram_size;
+@@session.histogram_size
+255
+SET @@session.histogram_size = test;
+ERROR 42000: Incorrect argument type to variable 'histogram_size'
+SELECT @@session.histogram_size;
+@@session.histogram_size
+255
+'#------------------FN_DYNVARS_053_06-----------------------#'
+SELECT @@global.histogram_size = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='histogram_size';
+@@global.histogram_size = VARIABLE_VALUE
+1
+'#------------------FN_DYNVARS_053_07-----------------------#'
+SELECT @@session.histogram_size = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='histogram_size';
+@@session.histogram_size = VARIABLE_VALUE
+1
+'#------------------FN_DYNVARS_053_08-----------------------#'
+SET @@global.histogram_size = TRUE;
+SET @@global.histogram_size = FALSE;
+'#---------------------FN_DYNVARS_001_09----------------------#'
+SET @@global.histogram_size = 10;
+SELECT @@histogram_size = @@global.histogram_size;
+@@histogram_size = @@global.histogram_size
+0
+'#---------------------FN_DYNVARS_001_10----------------------#'
+SET @@histogram_size = 100;
+SELECT @@histogram_size = @@local.histogram_size;
+@@histogram_size = @@local.histogram_size
+1
+SELECT @@local.histogram_size = @@session.histogram_size;
+@@local.histogram_size = @@session.histogram_size
+1
+SET @@global.histogram_size = @start_global_value;
+SELECT @@global.histogram_size;
+@@global.histogram_size
+0
+SET @@session.histogram_size = @start_session_value;
+SELECT @@session.histogram_size;
+@@session.histogram_size
+0
diff --git a/mysql-test/suite/sys_vars/r/optimizer_use_condition_selectivity_basic.result b/mysql-test/suite/sys_vars/r/optimizer_use_condition_selectivity_basic.result
index 332194e369e..418c221b5aa 100644
--- a/mysql-test/suite/sys_vars/r/optimizer_use_condition_selectivity_basic.result
+++ b/mysql-test/suite/sys_vars/r/optimizer_use_condition_selectivity_basic.result
@@ -40,6 +40,10 @@ SET @@global.optimizer_use_condition_selectivity = 3;
SELECT @@global.optimizer_use_condition_selectivity;
@@global.optimizer_use_condition_selectivity
3
+SET @@global.optimizer_use_condition_selectivity = 4;
+SELECT @@global.optimizer_use_condition_selectivity;
+@@global.optimizer_use_condition_selectivity
+4
'#--------------------FN_DYNVARS_115_04-------------------------#'
SELECT @@session.optimizer_use_condition_selectivity;
@@session.optimizer_use_condition_selectivity
@@ -56,6 +60,10 @@ SET @@session.optimizer_use_condition_selectivity = 3;
SELECT @@session.optimizer_use_condition_selectivity;
@@session.optimizer_use_condition_selectivity
3
+SET @@session.optimizer_use_condition_selectivity = 4;
+SELECT @@session.optimizer_use_condition_selectivity;
+@@session.optimizer_use_condition_selectivity
+4
'#------------------FN_DYNVARS_115_05-----------------------#'
SET @@global.optimizer_use_condition_selectivity = ON;
ERROR 42000: Incorrect argument type to variable 'optimizer_use_condition_selectivity'
diff --git a/mysql-test/suite/sys_vars/t/histogram_size_basic.test b/mysql-test/suite/sys_vars/t/histogram_size_basic.test
new file mode 100644
index 00000000000..d65936e3616
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/histogram_size_basic.test
@@ -0,0 +1,142 @@
+--source include/load_sysvars.inc
+
+##############################################################
+# START OF histogram_size TESTS #
+##############################################################
+
+
+#############################################################
+# Save initial value #
+#############################################################
+
+SET @start_global_value = @@global.histogram_size;
+SELECT @start_global_value;
+SET @start_session_value = @@session.histogram_size;
+SELECT @start_session_value;
+
+--echo '#--------------------FN_DYNVARS_053_01-------------------------#'
+################################################################
+# Display the DEFAULT value of histogram_size #
+################################################################
+
+SET @@global.histogram_size = DEFAULT;
+SELECT @@global.histogram_size;
+
+SET @@session.histogram_size = DEFAULT;
+SELECT @@session.histogram_size;
+
+--echo '#--------------------FN_DYNVARS_053_03-------------------------#'
+########################################################################
+# Change the value of histogram_size to a valid value for GLOBAL Scope #
+########################################################################
+
+SET @@global.histogram_size = 1;
+SELECT @@global.histogram_size;
+SET @@global.histogram_size = 31;
+SELECT @@global.histogram_size;
+SET @@global.histogram_size = 255;
+SELECT @@global.histogram_size;
+
+--echo '#--------------------FN_DYNVARS_053_04-------------------------#'
+#########################################################################
+# Change the value of histogram_size to a valid value for SESSION Scope #
+#########################################################################
+
+SET @@session.histogram_size = 1;
+SELECT @@session.histogram_size;
+SET @@session.histogram_size = 31;
+SELECT @@session.histogram_size;
+SET @@session.histogram_size = 255;
+SELECT @@session.histogram_size;
+
+--echo '#------------------FN_DYNVARS_053_05-----------------------#'
+##########################################################
+# Change the value of histogram_size to an invalid value #
+###########################################################
+
+SET @@global.histogram_size = -1;
+SELECT @@global.histogram_size;
+SET @@global.histogram_size = 256;
+SELECT @@global.histogram_size;
+SET @@global.histogram_size = 1024;
+SELECT @@global.histogram_size;
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.histogram_size = 4.5;
+SELECT @@global.histogram_size;
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.histogram_size = test;
+SELECT @@global.histogram_size;
+
+SET @@session.histogram_size = -1;
+SELECT @@session.histogram_size;
+SET @@session.histogram_size = 256;
+SELECT @@session.histogram_size;
+SET @@session.histogram_size = 1024;
+SELECT @@session.histogram_size;
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@session.histogram_size = 4.5;
+SELECT @@session.histogram_size;
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@session.histogram_size = test;
+SELECT @@session.histogram_size;
+
+--echo '#------------------FN_DYNVARS_053_06-----------------------#'
+####################################################################
+# Check if the value in GLOBAL Table matches value in variable #
+####################################################################
+
+SELECT @@global.histogram_size = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='histogram_size';
+
+--echo '#------------------FN_DYNVARS_053_07-----------------------#'
+####################################################################
+# Check if the value in SESSION Table matches value in variable #
+####################################################################
+
+SELECT @@session.histogram_size = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='histogram_size';
+
+
+--echo '#------------------FN_DYNVARS_053_08-----------------------#'
+####################################################################
+# Check if TRUE and FALSE values can be used on variable #
+####################################################################
+
+SET @@global.histogram_size = TRUE;
+SET @@global.histogram_size = FALSE;
+
+--echo '#---------------------FN_DYNVARS_001_09----------------------#'
+#################################################################################
+# Check if accessing variable with and without GLOBAL point to same variable #
+#################################################################################
+
+SET @@global.histogram_size = 10;
+SELECT @@histogram_size = @@global.histogram_size;
+
+--echo '#---------------------FN_DYNVARS_001_10----------------------#'
+########################################################################################################
+# Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable #
+########################################################################################################
+
+SET @@histogram_size = 100;
+SELECT @@histogram_size = @@local.histogram_size;
+SELECT @@local.histogram_size = @@session.histogram_size;
+
+####################################
+# Restore initial value #
+####################################
+
+SET @@global.histogram_size = @start_global_value;
+SELECT @@global.histogram_size;
+SET @@session.histogram_size = @start_session_value;
+SELECT @@session.histogram_size;
+
+
+###################################################
+# END OF histogram_size TESTS #
+###################################################
+
diff --git a/mysql-test/suite/sys_vars/t/optimizer_use_condition_selectivity_basic.test b/mysql-test/suite/sys_vars/t/optimizer_use_condition_selectivity_basic.test
index d898cf448dc..58a1af4b975 100644
--- a/mysql-test/suite/sys_vars/t/optimizer_use_condition_selectivity_basic.test
+++ b/mysql-test/suite/sys_vars/t/optimizer_use_condition_selectivity_basic.test
@@ -52,6 +52,8 @@ SET @@global.optimizer_use_condition_selectivity = 2;
SELECT @@global.optimizer_use_condition_selectivity;
SET @@global.optimizer_use_condition_selectivity = 3;
SELECT @@global.optimizer_use_condition_selectivity;
+SET @@global.optimizer_use_condition_selectivity = 4;
+SELECT @@global.optimizer_use_condition_selectivity;
--echo '#--------------------FN_DYNVARS_115_04-------------------------#'
@@ -66,6 +68,8 @@ SET @@session.optimizer_use_condition_selectivity = 2;
SELECT @@session.optimizer_use_condition_selectivity;
SET @@session.optimizer_use_condition_selectivity = 3;
SELECT @@session.optimizer_use_condition_selectivity;
+SET @@session.optimizer_use_condition_selectivity = 4;
+SELECT @@session.optimizer_use_condition_selectivity;
--echo '#------------------FN_DYNVARS_115_05-----------------------#'
diff --git a/mysql-test/t/selectivity.test b/mysql-test/t/selectivity.test
index 4756c6d4816..77089271cdd 100644
--- a/mysql-test/t/selectivity.test
+++ b/mysql-test/t/selectivity.test
@@ -16,6 +16,7 @@ CREATE DATABASE dbt3_s001;
use dbt3_s001;
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
+set @save_histogram_size=@@histogram_size;
--disable_query_log
--disable_result_log
@@ -58,8 +59,29 @@ set optimizer_use_condition_selectivity=3;
eval EXPLAIN EXTENDED $Q20;
eval $Q20;
+set histogram_size=15;
+
+flush table part;
+
+ANALYZE TABLE part PERSISTENT FOR COLUMNS(p_name) INDEXES();
+
+set optimizer_use_condition_selectivity=4;
+
+eval EXPLAIN EXTENDED $Q20;
+eval $Q20;
+
+set histogram_size=24;
+
+flush table nation;
+
+ANALYZE TABLE nation PERSISTENT FOR COLUMNS(n_name) INDEXES();
+
+eval EXPLAIN EXTENDED $Q20;
+eval $Q20;
+
DROP DATABASE dbt3_s001;
+set histogram_size=@save_histogram_size;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set use_stat_tables=@save_use_stat_tables;
diff --git a/mysql-test/t/statistics.test b/mysql-test/t/statistics.test
index 4f2d0510c11..65412d849ed 100644
--- a/mysql-test/t/statistics.test
+++ b/mysql-test/t/statistics.test
@@ -165,6 +165,23 @@ SELECT
WHERE t1.e IS NOT NULL AND t1.b IS NOT NULL AND t1.d IS NOT NULL)
AS 'ARITY 3';
+
+DELETE FROM mysql.column_stats;
+
+set histogram_size=4;
+ANALYZE TABLE t1;
+
+SELECT db_name, table_name, column_name,
+ min_value, max_value,
+ nulls_ratio, avg_frequency,
+ hist_size, HEX(histogram)
+ FROM mysql.column_stats;
+
+DELETE FROM mysql.column_stats;
+set histogram_size= 0;
+ANALYZE TABLE t1;
+
+
CREATE TABLE t3 (
a int NOT NULL PRIMARY KEY,
b varchar(32),