diff --git a/mysql-test/r/stat_tables.result b/mysql-test/r/stat_tables.result
index e52efc97c50..26f2b602c6b 100644
--- a/mysql-test/r/stat_tables.result
+++ b/mysql-test/r/stat_tables.result
@@ -17,34 +17,34 @@ dbt3_s001	region	5
 dbt3_s001	supplier	10
 select * from mysql.index_stat;
 db_name	table_name	index_name	prefix_arity	avg_frequency
-dbt3_s001	customer	PRIMARY	1	1
-dbt3_s001	customer	i_c_nationkey	1	6
-dbt3_s001	lineitem	PRIMARY	1	4.003333333333333
-dbt3_s001	lineitem	PRIMARY	2	1
-dbt3_s001	lineitem	i_l_shipdate	1	2.650044130626655
-dbt3_s001	lineitem	i_l_suppkey_partkey	1	30.025
-dbt3_s001	lineitem	i_l_suppkey_partkey	2	8.57857142857143
-dbt3_s001	lineitem	i_l_partkey	1	30.025
-dbt3_s001	lineitem	i_l_suppkey	1	600.5
-dbt3_s001	lineitem	i_l_receiptdate	1	2.6477072310405645
-dbt3_s001	lineitem	i_l_orderkey	1	4.003333333333333
-dbt3_s001	lineitem	i_l_orderkey_quantity	1	4.003333333333333
-dbt3_s001	lineitem	i_l_orderkey_quantity	2	1.0403672903672905
-dbt3_s001	lineitem	i_l_commitdate	1	2.7159656264133876
-dbt3_s001	nation	PRIMARY	1	1
-dbt3_s001	nation	i_n_regionkey	1	5
-dbt3_s001	orders	PRIMARY	1	1
-dbt3_s001	orders	i_o_orderdate	1	1.3321492007104796
-dbt3_s001	orders	i_o_custkey	1	15
-dbt3_s001	part	PRIMARY	1	1
-dbt3_s001	part	i_p_retailprice	1	1
-dbt3_s001	partsupp	PRIMARY	1	3.5
-dbt3_s001	partsupp	PRIMARY	2	1
-dbt3_s001	partsupp	i_ps_partkey	1	3.5
-dbt3_s001	partsupp	i_ps_suppkey	1	70
-dbt3_s001	region	PRIMARY	1	1
-dbt3_s001	supplier	PRIMARY	1	1
-dbt3_s001	supplier	i_s_nationkey	1	1.1111111111111112
+dbt3_s001	customer	PRIMARY	1	1.0000
+dbt3_s001	customer	i_c_nationkey	1	6.0000
+dbt3_s001	lineitem	PRIMARY	1	4.0033
+dbt3_s001	lineitem	PRIMARY	2	1.0000
+dbt3_s001	lineitem	i_l_shipdate	1	2.6500
+dbt3_s001	lineitem	i_l_suppkey_partkey	1	30.0250
+dbt3_s001	lineitem	i_l_suppkey_partkey	2	8.5786
+dbt3_s001	lineitem	i_l_partkey	1	30.0250
+dbt3_s001	lineitem	i_l_suppkey	1	600.5000
+dbt3_s001	lineitem	i_l_receiptdate	1	2.6477
+dbt3_s001	lineitem	i_l_orderkey	1	4.0033
+dbt3_s001	lineitem	i_l_orderkey_quantity	1	4.0033
+dbt3_s001	lineitem	i_l_orderkey_quantity	2	1.0404
+dbt3_s001	lineitem	i_l_commitdate	1	2.7160
+dbt3_s001	nation	PRIMARY	1	1.0000
+dbt3_s001	nation	i_n_regionkey	1	5.0000
+dbt3_s001	orders	PRIMARY	1	1.0000
+dbt3_s001	orders	i_o_orderdate	1	1.3321
+dbt3_s001	orders	i_o_custkey	1	15.0000
+dbt3_s001	part	PRIMARY	1	1.0000
+dbt3_s001	part	i_p_retailprice	1	1.0000
+dbt3_s001	partsupp	PRIMARY	1	3.5000
+dbt3_s001	partsupp	PRIMARY	2	1.0000
+dbt3_s001	partsupp	i_ps_partkey	1	3.5000
+dbt3_s001	partsupp	i_ps_suppkey	1	70.0000
+dbt3_s001	region	PRIMARY	1	1.0000
+dbt3_s001	supplier	PRIMARY	1	1.0000
+dbt3_s001	supplier	i_s_nationkey	1	1.1111
 set optimizer_switch=@save_optimizer_switch;
 set @save_optimizer_switch=@@optimizer_switch;
 set optimizer_switch='index_condition_pushdown=off';
@@ -90,47 +90,47 @@ dbt3_s001	region	5
 dbt3_s001	supplier	10
 select * from mysql.index_stat;
 db_name	table_name	index_name	prefix_arity	avg_frequency
-dbt3_s001	customer	PRIMARY	1	1
-dbt3_s001	customer	i_c_nationkey	1	6
-dbt3_s001	lineitem	PRIMARY	1	4.003333333333333
-dbt3_s001	lineitem	PRIMARY	2	1
-dbt3_s001	lineitem	i_l_shipdate	1	2.650044130626655
-dbt3_s001	lineitem	i_l_suppkey_partkey	1	30.025
-dbt3_s001	lineitem	i_l_suppkey_partkey	2	8.57857142857143
-dbt3_s001	lineitem	i_l_partkey	1	30.025
-dbt3_s001	lineitem	i_l_suppkey	1	600.5
-dbt3_s001	lineitem	i_l_receiptdate	1	2.6477072310405645
-dbt3_s001	lineitem	i_l_orderkey	1	4.003333333333333
-dbt3_s001	lineitem	i_l_orderkey_quantity	1	4.003333333333333
-dbt3_s001	lineitem	i_l_orderkey_quantity	2	1.0403672903672905
-dbt3_s001	lineitem	i_l_commitdate	1	2.7159656264133876
-dbt3_s001	nation	PRIMARY	1	1
-dbt3_s001	nation	i_n_regionkey	1	5
-dbt3_s001	orders	PRIMARY	1	1
-dbt3_s001	orders	i_o_orderdate	1	1.3321492007104796
-dbt3_s001	orders	i_o_custkey	1	15
-dbt3_s001	part	PRIMARY	1	1
-dbt3_s001	part	i_p_retailprice	1	1
-dbt3_s001	partsupp	PRIMARY	1	3.5
-dbt3_s001	partsupp	PRIMARY	2	1
-dbt3_s001	partsupp	i_ps_partkey	1	3.5
-dbt3_s001	partsupp	i_ps_suppkey	1	70
-dbt3_s001	region	PRIMARY	1	1
-dbt3_s001	supplier	PRIMARY	1	1
-dbt3_s001	supplier	i_s_nationkey	1	1.1111111111111112
+dbt3_s001	customer	PRIMARY	1	1.0000
+dbt3_s001	customer	i_c_nationkey	1	6.0000
+dbt3_s001	lineitem	PRIMARY	1	4.0033
+dbt3_s001	lineitem	PRIMARY	2	1.0000
+dbt3_s001	lineitem	i_l_shipdate	1	2.6500
+dbt3_s001	lineitem	i_l_suppkey_partkey	1	30.0250
+dbt3_s001	lineitem	i_l_suppkey_partkey	2	8.5786
+dbt3_s001	lineitem	i_l_partkey	1	30.0250
+dbt3_s001	lineitem	i_l_suppkey	1	600.5000
+dbt3_s001	lineitem	i_l_receiptdate	1	2.6477
+dbt3_s001	lineitem	i_l_orderkey	1	4.0033
+dbt3_s001	lineitem	i_l_orderkey_quantity	1	4.0033
+dbt3_s001	lineitem	i_l_orderkey_quantity	2	1.0404
+dbt3_s001	lineitem	i_l_commitdate	1	2.7160
+dbt3_s001	nation	PRIMARY	1	1.0000
+dbt3_s001	nation	i_n_regionkey	1	5.0000
+dbt3_s001	orders	PRIMARY	1	1.0000
+dbt3_s001	orders	i_o_orderdate	1	1.3321
+dbt3_s001	orders	i_o_custkey	1	15.0000
+dbt3_s001	part	PRIMARY	1	1.0000
+dbt3_s001	part	i_p_retailprice	1	1.0000
+dbt3_s001	partsupp	PRIMARY	1	3.5000
+dbt3_s001	partsupp	PRIMARY	2	1.0000
+dbt3_s001	partsupp	i_ps_partkey	1	3.5000
+dbt3_s001	partsupp	i_ps_suppkey	1	70.0000
+dbt3_s001	region	PRIMARY	1	1.0000
+dbt3_s001	supplier	PRIMARY	1	1.0000
+dbt3_s001	supplier	i_s_nationkey	1	1.1111
 select * from mysql.table_stat where table_name='orders';
 db_name	table_name	cardinality
 dbt3_s001	orders	1500
 select * from mysql.index_stat where table_name='orders';
 db_name	table_name	index_name	prefix_arity	avg_frequency
-dbt3_s001	orders	PRIMARY	1	1
-dbt3_s001	orders	i_o_orderdate	1	1.3321492007104796
-dbt3_s001	orders	i_o_custkey	1	15
+dbt3_s001	orders	PRIMARY	1	1.0000
+dbt3_s001	orders	i_o_orderdate	1	1.3321
+dbt3_s001	orders	i_o_custkey	1	15.0000
 select (select cardinality from mysql.table_stat where table_name='orders') /
 (select avg_frequency from mysql.index_stat 
 where index_name='i_o_orderdate' and prefix_arity=1) as n_distinct;
 n_distinct
-1126
+1126.0416
 select count(distinct o_orderdate) from orders;
 count(distinct o_orderdate)
 1126
@@ -138,20 +138,20 @@ select (select cardinality from mysql.table_stat where table_name='orders') /
 (select avg_frequency from mysql.index_stat 
 where index_name='i_o_custkey' and prefix_arity=1) as n_distinct;
 n_distinct
-100
+100.0000
 select count(distinct o_custkey) from orders;
 count(distinct o_custkey)
 100
 show index from orders;
 Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment	Index_comment
 orders	0	PRIMARY	1	o_orderkey	A	1500	NULL	NULL		BTREE		
-orders	1	i_o_orderdate	1	o_orderDATE	A	1127	NULL	NULL	YES	BTREE		
+orders	1	i_o_orderdate	1	o_orderDATE	A	1126	NULL	NULL	YES	BTREE		
 orders	1	i_o_custkey	1	o_custkey	A	100	NULL	NULL	YES	BTREE		
 select index_name, column_name, cardinality from information_schema.statistics
 where table_name='orders';
 index_name	column_name	cardinality
 PRIMARY	o_orderkey	1500
-i_o_orderdate	o_orderDATE	1127
+i_o_orderdate	o_orderDATE	1126
 i_o_custkey	o_custkey	100
 set @save_optimizer_switch=@@optimizer_switch;
 set optimizer_switch='index_condition_pushdown=off';
diff --git a/mysql-test/r/stat_tables_innodb.result b/mysql-test/r/stat_tables_innodb.result
index 90361099ca2..3d534dcab29 100644
--- a/mysql-test/r/stat_tables_innodb.result
+++ b/mysql-test/r/stat_tables_innodb.result
@@ -20,34 +20,34 @@ dbt3_s001	region	5
 dbt3_s001	supplier	10
 select * from mysql.index_stat;
 db_name	table_name	index_name	prefix_arity	avg_frequency
-dbt3_s001	customer	PRIMARY	1	1
-dbt3_s001	customer	i_c_nationkey	1	6
-dbt3_s001	lineitem	PRIMARY	1	4.003333333333333
-dbt3_s001	lineitem	PRIMARY	2	1
-dbt3_s001	lineitem	i_l_shipdate	1	2.650044130626655
-dbt3_s001	lineitem	i_l_suppkey_partkey	1	30.025
-dbt3_s001	lineitem	i_l_suppkey_partkey	2	8.57857142857143
-dbt3_s001	lineitem	i_l_partkey	1	30.025
-dbt3_s001	lineitem	i_l_suppkey	1	600.5
-dbt3_s001	lineitem	i_l_receiptdate	1	2.6477072310405645
-dbt3_s001	lineitem	i_l_orderkey	1	4.003333333333333
-dbt3_s001	lineitem	i_l_orderkey_quantity	1	4.003333333333333
-dbt3_s001	lineitem	i_l_orderkey_quantity	2	1.0403672903672905
-dbt3_s001	lineitem	i_l_commitdate	1	2.7159656264133876
-dbt3_s001	nation	PRIMARY	1	1
-dbt3_s001	nation	i_n_regionkey	1	5
-dbt3_s001	orders	PRIMARY	1	1
-dbt3_s001	orders	i_o_orderdate	1	1.3321492007104796
-dbt3_s001	orders	i_o_custkey	1	15
-dbt3_s001	part	PRIMARY	1	1
-dbt3_s001	part	i_p_retailprice	1	1
-dbt3_s001	partsupp	PRIMARY	1	3.5
-dbt3_s001	partsupp	PRIMARY	2	1
-dbt3_s001	partsupp	i_ps_partkey	1	3.5
-dbt3_s001	partsupp	i_ps_suppkey	1	70
-dbt3_s001	region	PRIMARY	1	1
-dbt3_s001	supplier	PRIMARY	1	1
-dbt3_s001	supplier	i_s_nationkey	1	1.1111111111111112
+dbt3_s001	customer	PRIMARY	1	1.0000
+dbt3_s001	customer	i_c_nationkey	1	6.0000
+dbt3_s001	lineitem	PRIMARY	1	4.0033
+dbt3_s001	lineitem	PRIMARY	2	1.0000
+dbt3_s001	lineitem	i_l_shipdate	1	2.6500
+dbt3_s001	lineitem	i_l_suppkey_partkey	1	30.0250
+dbt3_s001	lineitem	i_l_suppkey_partkey	2	8.5786
+dbt3_s001	lineitem	i_l_partkey	1	30.0250
+dbt3_s001	lineitem	i_l_suppkey	1	600.5000
+dbt3_s001	lineitem	i_l_receiptdate	1	2.6477
+dbt3_s001	lineitem	i_l_orderkey	1	4.0033
+dbt3_s001	lineitem	i_l_orderkey_quantity	1	4.0033
+dbt3_s001	lineitem	i_l_orderkey_quantity	2	1.0404
+dbt3_s001	lineitem	i_l_commitdate	1	2.7160
+dbt3_s001	nation	PRIMARY	1	1.0000
+dbt3_s001	nation	i_n_regionkey	1	5.0000
+dbt3_s001	orders	PRIMARY	1	1.0000
+dbt3_s001	orders	i_o_orderdate	1	1.3321
+dbt3_s001	orders	i_o_custkey	1	15.0000
+dbt3_s001	part	PRIMARY	1	1.0000
+dbt3_s001	part	i_p_retailprice	1	1.0000
+dbt3_s001	partsupp	PRIMARY	1	3.5000
+dbt3_s001	partsupp	PRIMARY	2	1.0000
+dbt3_s001	partsupp	i_ps_partkey	1	3.5000
+dbt3_s001	partsupp	i_ps_suppkey	1	70.0000
+dbt3_s001	region	PRIMARY	1	1.0000
+dbt3_s001	supplier	PRIMARY	1	1.0000
+dbt3_s001	supplier	i_s_nationkey	1	1.1111
 set optimizer_switch=@save_optimizer_switch;
 set @save_optimizer_switch=@@optimizer_switch;
 set optimizer_switch='index_condition_pushdown=off';
@@ -93,71 +93,71 @@ dbt3_s001	region	5
 dbt3_s001	supplier	10
 select * from mysql.index_stat;
 db_name	table_name	index_name	prefix_arity	avg_frequency
-dbt3_s001	customer	PRIMARY	1	1
-dbt3_s001	customer	i_c_nationkey	1	6
-dbt3_s001	customer	i_c_nationkey	2	1
-dbt3_s001	lineitem	PRIMARY	1	4.003333333333333
-dbt3_s001	lineitem	PRIMARY	2	1
-dbt3_s001	lineitem	i_l_shipdate	1	2.650044130626655
-dbt3_s001	lineitem	i_l_shipdate	2	1.014872401554842
-dbt3_s001	lineitem	i_l_shipdate	3	1
-dbt3_s001	lineitem	i_l_suppkey_partkey	1	30.025
-dbt3_s001	lineitem	i_l_suppkey_partkey	2	8.57857142857143
-dbt3_s001	lineitem	i_l_suppkey_partkey	3	1.0030065141139135
-dbt3_s001	lineitem	i_l_suppkey_partkey	4	1
-dbt3_s001	lineitem	i_l_partkey	1	30.025
-dbt3_s001	lineitem	i_l_partkey	2	1.008904569892473
-dbt3_s001	lineitem	i_l_partkey	3	1
-dbt3_s001	lineitem	i_l_suppkey	1	600.5
-dbt3_s001	lineitem	i_l_suppkey	2	1.207277844792923
-dbt3_s001	lineitem	i_l_suppkey	3	1
-dbt3_s001	lineitem	i_l_receiptdate	1	2.6477072310405645
-dbt3_s001	lineitem	i_l_receiptdate	2	1.0152155536770922
-dbt3_s001	lineitem	i_l_receiptdate	3	1
-dbt3_s001	lineitem	i_l_orderkey	1	4.003333333333333
-dbt3_s001	lineitem	i_l_orderkey	2	1
-dbt3_s001	lineitem	i_l_orderkey_quantity	1	4.003333333333333
-dbt3_s001	lineitem	i_l_orderkey_quantity	2	1.0403672903672905
-dbt3_s001	lineitem	i_l_orderkey_quantity	3	1
-dbt3_s001	lineitem	i_l_commitdate	1	2.7159656264133876
-dbt3_s001	lineitem	i_l_commitdate	2	1.036416983085951
-dbt3_s001	lineitem	i_l_commitdate	3	1
-dbt3_s001	nation	PRIMARY	1	1
-dbt3_s001	nation	i_n_regionkey	1	5
-dbt3_s001	nation	i_n_regionkey	2	1
-dbt3_s001	orders	PRIMARY	1	1
-dbt3_s001	orders	i_o_orderdate	1	1.3321492007104796
-dbt3_s001	orders	i_o_orderdate	2	1
-dbt3_s001	orders	i_o_custkey	1	15
-dbt3_s001	orders	i_o_custkey	2	1
-dbt3_s001	part	PRIMARY	1	1
-dbt3_s001	part	i_p_retailprice	1	1
-dbt3_s001	part	i_p_retailprice	2	1
-dbt3_s001	partsupp	PRIMARY	1	3.5
-dbt3_s001	partsupp	PRIMARY	2	1
-dbt3_s001	partsupp	i_ps_partkey	1	3.5
-dbt3_s001	partsupp	i_ps_partkey	2	1
-dbt3_s001	partsupp	i_ps_suppkey	1	70
-dbt3_s001	partsupp	i_ps_suppkey	2	1
-dbt3_s001	region	PRIMARY	1	1
-dbt3_s001	supplier	PRIMARY	1	1
-dbt3_s001	supplier	i_s_nationkey	1	1.1111111111111112
-dbt3_s001	supplier	i_s_nationkey	2	1
+dbt3_s001	customer	PRIMARY	1	1.0000
+dbt3_s001	customer	i_c_nationkey	1	6.0000
+dbt3_s001	customer	i_c_nationkey	2	1.0000
+dbt3_s001	lineitem	PRIMARY	1	4.0033
+dbt3_s001	lineitem	PRIMARY	2	1.0000
+dbt3_s001	lineitem	i_l_shipdate	1	2.6500
+dbt3_s001	lineitem	i_l_shipdate	2	1.0149
+dbt3_s001	lineitem	i_l_shipdate	3	1.0000
+dbt3_s001	lineitem	i_l_suppkey_partkey	1	30.0250
+dbt3_s001	lineitem	i_l_suppkey_partkey	2	8.5786
+dbt3_s001	lineitem	i_l_suppkey_partkey	3	1.0030
+dbt3_s001	lineitem	i_l_suppkey_partkey	4	1.0000
+dbt3_s001	lineitem	i_l_partkey	1	30.0250
+dbt3_s001	lineitem	i_l_partkey	2	1.0089
+dbt3_s001	lineitem	i_l_partkey	3	1.0000
+dbt3_s001	lineitem	i_l_suppkey	1	600.5000
+dbt3_s001	lineitem	i_l_suppkey	2	1.2073
+dbt3_s001	lineitem	i_l_suppkey	3	1.0000
+dbt3_s001	lineitem	i_l_receiptdate	1	2.6477
+dbt3_s001	lineitem	i_l_receiptdate	2	1.0152
+dbt3_s001	lineitem	i_l_receiptdate	3	1.0000
+dbt3_s001	lineitem	i_l_orderkey	1	4.0033
+dbt3_s001	lineitem	i_l_orderkey	2	1.0000
+dbt3_s001	lineitem	i_l_orderkey_quantity	1	4.0033
+dbt3_s001	lineitem	i_l_orderkey_quantity	2	1.0404
+dbt3_s001	lineitem	i_l_orderkey_quantity	3	1.0000
+dbt3_s001	lineitem	i_l_commitdate	1	2.7160
+dbt3_s001	lineitem	i_l_commitdate	2	1.0364
+dbt3_s001	lineitem	i_l_commitdate	3	1.0000
+dbt3_s001	nation	PRIMARY	1	1.0000
+dbt3_s001	nation	i_n_regionkey	1	5.0000
+dbt3_s001	nation	i_n_regionkey	2	1.0000
+dbt3_s001	orders	PRIMARY	1	1.0000
+dbt3_s001	orders	i_o_orderdate	1	1.3321
+dbt3_s001	orders	i_o_orderdate	2	1.0000
+dbt3_s001	orders	i_o_custkey	1	15.0000
+dbt3_s001	orders	i_o_custkey	2	1.0000
+dbt3_s001	part	PRIMARY	1	1.0000
+dbt3_s001	part	i_p_retailprice	1	1.0000
+dbt3_s001	part	i_p_retailprice	2	1.0000
+dbt3_s001	partsupp	PRIMARY	1	3.5000
+dbt3_s001	partsupp	PRIMARY	2	1.0000
+dbt3_s001	partsupp	i_ps_partkey	1	3.5000
+dbt3_s001	partsupp	i_ps_partkey	2	1.0000
+dbt3_s001	partsupp	i_ps_suppkey	1	70.0000
+dbt3_s001	partsupp	i_ps_suppkey	2	1.0000
+dbt3_s001	region	PRIMARY	1	1.0000
+dbt3_s001	supplier	PRIMARY	1	1.0000
+dbt3_s001	supplier	i_s_nationkey	1	1.1111
+dbt3_s001	supplier	i_s_nationkey	2	1.0000
 select * from mysql.table_stat where table_name='orders';
 db_name	table_name	cardinality
 dbt3_s001	orders	1500
 select * from mysql.index_stat where table_name='orders';
 db_name	table_name	index_name	prefix_arity	avg_frequency
-dbt3_s001	orders	PRIMARY	1	1
-dbt3_s001	orders	i_o_orderdate	1	1.3321492007104796
-dbt3_s001	orders	i_o_orderdate	2	1
-dbt3_s001	orders	i_o_custkey	1	15
-dbt3_s001	orders	i_o_custkey	2	1
+dbt3_s001	orders	PRIMARY	1	1.0000
+dbt3_s001	orders	i_o_orderdate	1	1.3321
+dbt3_s001	orders	i_o_orderdate	2	1.0000
+dbt3_s001	orders	i_o_custkey	1	15.0000
+dbt3_s001	orders	i_o_custkey	2	1.0000
 select (select cardinality from mysql.table_stat where table_name='orders') /
 (select avg_frequency from mysql.index_stat 
 where index_name='i_o_orderdate' and prefix_arity=1) as n_distinct;
 n_distinct
-1126
+1126.0416
 select count(distinct o_orderdate) from orders;
 count(distinct o_orderdate)
 1126
@@ -165,20 +165,20 @@ select (select cardinality from mysql.table_stat where table_name='orders') /
 (select avg_frequency from mysql.index_stat 
 where index_name='i_o_custkey' and prefix_arity=1) as n_distinct;
 n_distinct
-100
+100.0000
 select count(distinct o_custkey) from orders;
 count(distinct o_custkey)
 100
 show index from orders;
 Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment	Index_comment
 orders	0	PRIMARY	1	o_orderkey	A	1500	NULL	NULL		BTREE		
-orders	1	i_o_orderdate	1	o_orderDATE	A	1127	NULL	NULL	YES	BTREE		
+orders	1	i_o_orderdate	1	o_orderDATE	A	1126	NULL	NULL	YES	BTREE		
 orders	1	i_o_custkey	1	o_custkey	A	100	NULL	NULL	YES	BTREE		
 select index_name, column_name, cardinality from information_schema.statistics
 where table_name='orders';
 index_name	column_name	cardinality
 PRIMARY	o_orderkey	1500
-i_o_orderdate	o_orderDATE	1127
+i_o_orderdate	o_orderDATE	1126
 i_o_custkey	o_custkey	100
 set @save_optimizer_switch=@@optimizer_switch;
 set optimizer_switch='index_condition_pushdown=off';
diff --git a/mysql-test/r/statistics.result b/mysql-test/r/statistics.result
index 4e1a5a6733c..99d3c04312b 100644
--- a/mysql-test/r/statistics.result
+++ b/mysql-test/r/statistics.result
@@ -1,18 +1,5 @@
 drop table if exists t1,t2;
 set @save_use_stat_tables=@@use_stat_tables;
-CREATE VIEW table_stat AS
-SELECT * FROM mysql.table_stat;
-CREATE VIEW column_stat AS
-SELECT db_name, table_name, column_name,
-min_value, max_value,
-CAST(nulls_ratio AS decimal(12,4)) AS 'nulls_ratio',
-CAST(avg_length AS decimal(12,4)) AS 'avg_length',
-CAST(avg_frequency AS decimal(12,4)) AS 'avg_frequency'
-    FROM mysql.column_stat;
-CREATE VIEW index_stat AS
-SELECT db_name, table_name, index_name, prefix_arity,
-CAST(avg_frequency AS decimal(12,4)) AS 'avg_frequency'
-    FROM mysql.index_stat;
 DELETE FROM mysql.table_stat;
 DELETE FROM mysql.column_stat;
 DELETE FROM mysql.index_stat;
@@ -73,10 +60,10 @@ INSERT INTO t1 VALUES
 ANALYZE TABLE t1;
 Table	Op	Msg_type	Msg_text
 test.t1	analyze	status	OK
-SELECT * FROM table_stat;
+SELECT * FROM mysql.table_stat;
 db_name	table_name	cardinality
 test	t1	40
-SELECT * FROM column_stat;
+SELECT * FROM mysql.column_stat;
 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
@@ -84,7 +71,7 @@ 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
-SELECT * FROM index_stat;
+SELECT * FROM mysql.index_stat;
 db_name	table_name	index_name	prefix_arity	avg_frequency
 test	t1	PRIMARY	1	1.0000
 test	t1	idx1	1	6.4000
@@ -98,7 +85,7 @@ test	t1	idx4	3	1.1304
 SELECT COUNT(*) FROM t1;
 COUNT(*)
 40
-SELECT * FROM column_stat
+SELECT * FROM mysql.column_stat
 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
@@ -110,7 +97,7 @@ SELECT MIN(t1.a), MAX(t1.a),
 FROM t1;
 MIN(t1.a)	MAX(t1.a)	NULLS_RATIO(t1.a)	AVG_FREQUENCY(t1.a)
 0	49	0.2000	1.0000
-SELECT * FROM column_stat
+SELECT * FROM mysql.column_stat
 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
@@ -122,7 +109,7 @@ SELECT MIN(t1.b), MAX(t1.b),
 FROM t1;
 MIN(t1.b)	MAX(t1.b)	NULLS_RATIO(t1.b)	AVG_FREQUENCY(t1.b)
 vvvvvvvvvvvvv	zzzzzzzzzzzzzzzzzz	0.2000	6.4000
-SELECT * FROM column_stat 
+SELECT * FROM mysql.column_stat 
 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
@@ -134,7 +121,7 @@ SELECT MIN(t1.c), MAX(t1.c),
 FROM t1;
 MIN(t1.c)	MAX(t1.c)	NULLS_RATIO(t1.c)	AVG_FREQUENCY(t1.c)
 aaaa	dddddddd	0.1250	7.0000
-SELECT * FROM column_stat
+SELECT * FROM mysql.column_stat
 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
@@ -146,7 +133,7 @@ SELECT MIN(t1.d), MAX(t1.d),
 FROM t1;
 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 column_stat
+SELECT * FROM mysql.column_stat
 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
@@ -158,7 +145,7 @@ SELECT MIN(t1.e), MAX(t1.e),
 FROM t1;
 MIN(t1.e)	MAX(t1.e)	NULLS_RATIO(t1.e)	AVG_FREQUENCY(t1.e)
 0.01	0.112	0.2250	6.2000
-SELECT * FROM index_stat
+SELECT * FROM mysql.index_stat
 WHERE db_name='test' AND table_name='t1' AND index_name='idx1';
 db_name	table_name	index_name	prefix_arity	avg_frequency
 test	t1	idx1	1	6.4000
@@ -173,7 +160,7 @@ WHERE t1.b IS NOT NULL AND t1.e IS NOT NULL)
 AS 'ARITY 2';
 ARITY 1	ARITY 2
 6.4000	1.6875
-SELECT * FROM index_stat
+SELECT * FROM mysql.index_stat
 WHERE db_name='test' AND table_name='t1' AND index_name='idx2';
 db_name	table_name	index_name	prefix_arity	avg_frequency
 test	t1	idx2	1	7.0000
@@ -188,7 +175,7 @@ WHERE t1.c IS NOT NULL AND t1.d IS NOT NULL)
 AS 'ARITY 2';
 ARITY 1	ARITY 2
 7.0000	2.3846
-SELECT * FROM index_stat
+SELECT * FROM mysql.index_stat
 WHERE db_name='test' AND table_name='t1' AND index_name='idx3';
 db_name	table_name	index_name	prefix_arity	avg_frequency
 test	t1	idx3	1	8.5000
@@ -198,7 +185,7 @@ SELECT
 AS 'ARITY 1';
 ARITY 1
 8.5000
-SELECT * FROM index_stat
+SELECT * FROM mysql.index_stat
 WHERE db_name='test' AND table_name='t1' AND index_name='idx4';
 db_name	table_name	index_name	prefix_arity	avg_frequency
 test	t1	idx4	1	6.2000
@@ -225,25 +212,25 @@ DELETE FROM mysql.index_stat;
 ANALYZE TABLE t1 PERSISTENT FOR COLUMNS() INDEXES();
 Table	Op	Msg_type	Msg_text
 test.t1	analyze	status	Table is already up to date
-SELECT * FROM table_stat;
+SELECT * FROM mysql.table_stat;
 db_name	table_name	cardinality
 test	t1	40
-SELECT * FROM column_stat;
+SELECT * FROM mysql.column_stat;
 db_name	table_name	column_name	min_value	max_value	nulls_ratio	avg_length	avg_frequency
-SELECT * FROM index_stat;
+SELECT * FROM mysql.index_stat;
 db_name	table_name	index_name	prefix_arity	avg_frequency
 ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(c,e,b) INDEXES(idx2,idx4);
 Table	Op	Msg_type	Msg_text
 test.t1	analyze	status	Table is already up to date
-SELECT * FROM table_stat;
+SELECT * FROM mysql.table_stat;
 db_name	table_name	cardinality
 test	t1	40
-SELECT * FROM column_stat;
+SELECT * FROM mysql.column_stat;
 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
 test	t1	c	aaaa	dddddddd	0.1250	6.6571	7.0000
 test	t1	e	0.01	0.112	0.2250	8.0000	6.2000
-SELECT * FROM index_stat;
+SELECT * FROM mysql.index_stat;
 db_name	table_name	index_name	prefix_arity	avg_frequency
 test	t1	idx2	1	7.0000
 test	t1	idx2	2	2.3846
@@ -256,10 +243,10 @@ DELETE FROM mysql.index_stat;
 ANALYZE TABLE t1 PERSISTENT FOR COLUMNS ALL INDEXES ALL;
 Table	Op	Msg_type	Msg_text
 test.t1	analyze	status	Table is already up to date
-SELECT * FROM table_stat;
+SELECT * FROM mysql.table_stat;
 db_name	table_name	cardinality
 test	t1	40
-SELECT * FROM column_stat;
+SELECT * FROM mysql.column_stat;
 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
@@ -267,7 +254,7 @@ 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
-SELECT * FROM index_stat;
+SELECT * FROM mysql.index_stat;
 db_name	table_name	index_name	prefix_arity	avg_frequency
 test	t1	PRIMARY	1	1.0000
 test	t1	idx1	1	6.4000
@@ -284,11 +271,11 @@ INSERT INTO t2 SELECT * FROM t1;
 ANALYZE TABLE t2;
 Table	Op	Msg_type	Msg_text
 test.t2	analyze	status	OK
-SELECT * FROM table_stat;
+SELECT * FROM mysql.table_stat;
 db_name	table_name	cardinality
 test	t1	40
 test	t2	40
-SELECT * FROM column_stat ORDER BY column_name;
+SELECT * FROM mysql.column_stat 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
@@ -302,7 +289,7 @@ 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
-SELECT * FROM index_stat ORDER BY index_name, prefix_arity, table_name;
+SELECT * FROM mysql.index_stat ORDER BY index_name, prefix_arity, table_name;
 db_name	table_name	index_name	prefix_arity	avg_frequency
 test	t1	PRIMARY	1	1.0000
 test	t2	PRIMARY	1	1.0000
@@ -335,7 +322,7 @@ ADD INDEX idx4 (e, b(4), d);
 ANALYZE TABLE t1;
 Table	Op	Msg_type	Msg_text
 test.t1	analyze	status	OK
-SELECT * FROM column_stat;
+SELECT * FROM mysql.column_stat;
 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	0.2000	17.1250	NULL
@@ -343,7 +330,7 @@ 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
-SELECT * FROM index_stat;
+SELECT * FROM mysql.index_stat;
 db_name	table_name	index_name	prefix_arity	avg_frequency
 test	t1	PRIMARY	1	1.0000
 test	t1	idx2	1	7.0000
@@ -390,14 +377,14 @@ INDEX (Percentage)
 set use_stat_tables='preferably';
 ANALYZE TABLE Country, City, CountryLanguage;
 SELECT UPPER(db_name), UPPER(table_name), cardinality
-FROM test.table_stat;
+FROM mysql.table_stat;
 UPPER(db_name)	UPPER(table_name)	cardinality
 WORLD	COUNTRY	239
 WORLD	CITY	4079
 WORLD	COUNTRYLANGUAGE	984
 SELECT UPPER(db_name), UPPER(table_name), 
 column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency
-FROM test.column_stat;
+FROM mysql.column_stat;
 UPPER(db_name)	UPPER(table_name)	column_name	min_value	max_value	nulls_ratio	avg_length	avg_frequency
 WORLD	COUNTRY	Code	ABW	ZWE	0.0000	3.0000	1.0000
 WORLD	COUNTRY	Name	Afghanistan	Zimbabwe	0.0000	10.1088	1.0000
@@ -413,7 +400,7 @@ WORLD	COUNTRYLANGUAGE	Language	Abhyasi	[South]Mande	0.0000	7.1778	2.1532
 WORLD	COUNTRYLANGUAGE	Percentage	0.0	99.9	0.0000	4.0000	2.7640
 SELECT UPPER(db_name), UPPER(table_name),
 index_name, prefix_arity, avg_frequency
-FROM test.index_stat;
+FROM mysql.index_stat;
 UPPER(db_name)	UPPER(table_name)	index_name	prefix_arity	avg_frequency
 WORLD	COUNTRY	PRIMARY	1	1.0000
 WORLD	COUNTRY	Name	1	1.0000
@@ -458,7 +445,7 @@ ALTER TABLE CountryLanguage ENGINE=InnoDB;
 set use_stat_tables='preferably';
 ANALYZE TABLE Country, City, CountryLanguage;
 SELECT UPPER(db_name), UPPER(table_name), cardinality
-FROM test.table_stat;
+FROM mysql.table_stat;
 UPPER(db_name)	UPPER(table_name)	cardinality
 WORLD	COUNTRY	239
 WORLD	CITY	4079
@@ -468,7 +455,7 @@ WORLD_INNODB	CITY	4079
 WORLD_INNODB	COUNTRYLANGUAGE	984
 SELECT UPPER(db_name), UPPER(table_name), 
 column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency
-FROM test.column_stat;
+FROM mysql.column_stat;
 UPPER(db_name)	UPPER(table_name)	column_name	min_value	max_value	nulls_ratio	avg_length	avg_frequency
 WORLD	COUNTRY	Code	ABW	ZWE	0.0000	3.0000	1.0000
 WORLD	COUNTRY	Name	Afghanistan	Zimbabwe	0.0000	10.1088	1.0000
@@ -496,7 +483,7 @@ WORLD_INNODB	COUNTRYLANGUAGE	Language	Abhyasi	[South]Mande	0.0000	7.1778	2.1532
 WORLD_INNODB	COUNTRYLANGUAGE	Percentage	0.0	99.9	0.0000	4.0000	2.7640
 SELECT UPPER(db_name), UPPER(table_name),
 index_name, prefix_arity, avg_frequency
-FROM test.index_stat;
+FROM mysql.index_stat;
 UPPER(db_name)	UPPER(table_name)	index_name	prefix_arity	avg_frequency
 WORLD	COUNTRY	PRIMARY	1	1.0000
 WORLD	COUNTRY	Name	1	1.0000
@@ -520,7 +507,4 @@ DROP DATABASE world_innodb;
 DELETE FROM mysql.table_stat;
 DELETE FROM mysql.column_stat;
 DELETE FROM mysql.index_stat;
-DROP VIEW test.table_stat;
-DROP VIEW test.column_stat;
-DROP VIEW test.index_stat;
 set use_stat_tables=@save_use_stat_tables;
diff --git a/mysql-test/r/system_mysql_db.result b/mysql-test/r/system_mysql_db.result
index 985fbd0539d..cf7db8f64ff 100644
--- a/mysql-test/r/system_mysql_db.result
+++ b/mysql-test/r/system_mysql_db.result
@@ -283,9 +283,9 @@ column_stat	CREATE TABLE `column_stat` (
   `column_name` varchar(64) COLLATE utf8_bin NOT NULL,
   `min_value` varchar(255) COLLATE utf8_bin DEFAULT NULL,
   `max_value` varchar(255) COLLATE utf8_bin DEFAULT NULL,
-  `nulls_ratio` double DEFAULT NULL,
-  `avg_length` double DEFAULT NULL,
-  `avg_frequency` double DEFAULT NULL,
+  `nulls_ratio` decimal(12,4) DEFAULT NULL,
+  `avg_length` decimal(12,4) DEFAULT NULL,
+  `avg_frequency` decimal(12,4) 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_stat;
@@ -295,7 +295,7 @@ index_stat	CREATE TABLE `index_stat` (
   `table_name` varchar(64) COLLATE utf8_bin NOT NULL,
   `index_name` varchar(64) COLLATE utf8_bin NOT NULL,
   `prefix_arity` int(11) unsigned NOT NULL,
-  `avg_frequency` double DEFAULT NULL,
+  `avg_frequency` decimal(12,4) DEFAULT NULL,
   PRIMARY KEY (`db_name`,`table_name`,`index_name`,`prefix_arity`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Indexes'
 show tables;
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 c83f80cd28f..bc8be53d524 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result
@@ -9,13 +9,13 @@ def	mysql	columns_priv	Host	1		NO	char	60	180	NULL	NULL	NULL	utf8	utf8_bin	char(
 def	mysql	columns_priv	Table_name	4		NO	char	64	192	NULL	NULL	NULL	utf8	utf8_bin	char(64)	PRI		select,insert,update,references	
 def	mysql	columns_priv	Timestamp	6	CURRENT_TIMESTAMP	NO	timestamp	NULL	NULL	NULL	NULL	0	NULL	NULL	timestamp		on update CURRENT_TIMESTAMP	select,insert,update,references	
 def	mysql	columns_priv	User	3		NO	char	16	48	NULL	NULL	NULL	utf8	utf8_bin	char(16)	PRI		select,insert,update,references	
-def	mysql	column_stat	avg_frequency	8	NULL	YES	double	NULL	NULL	22	NULL	NULL	NULL	NULL	double			select,insert,update,references	
-def	mysql	column_stat	avg_length	7	NULL	YES	double	NULL	NULL	22	NULL	NULL	NULL	NULL	double			select,insert,update,references	
+def	mysql	column_stat	avg_frequency	8	NULL	YES	decimal	NULL	NULL	12	4	NULL	NULL	NULL	decimal(12,4)			select,insert,update,references	
+def	mysql	column_stat	avg_length	7	NULL	YES	decimal	NULL	NULL	12	4	NULL	NULL	NULL	decimal(12,4)			select,insert,update,references	
 def	mysql	column_stat	column_name	3	NULL	NO	varchar	64	192	NULL	NULL	NULL	utf8	utf8_bin	varchar(64)	PRI		select,insert,update,references	
 def	mysql	column_stat	db_name	1	NULL	NO	varchar	64	192	NULL	NULL	NULL	utf8	utf8_bin	varchar(64)	PRI		select,insert,update,references	
 def	mysql	column_stat	max_value	5	NULL	YES	varchar	255	765	NULL	NULL	NULL	utf8	utf8_bin	varchar(255)			select,insert,update,references	
 def	mysql	column_stat	min_value	4	NULL	YES	varchar	255	765	NULL	NULL	NULL	utf8	utf8_bin	varchar(255)			select,insert,update,references	
-def	mysql	column_stat	nulls_ratio	6	NULL	YES	double	NULL	NULL	22	NULL	NULL	NULL	NULL	double			select,insert,update,references	
+def	mysql	column_stat	nulls_ratio	6	NULL	YES	decimal	NULL	NULL	12	4	NULL	NULL	NULL	decimal(12,4)			select,insert,update,references	
 def	mysql	column_stat	table_name	2	NULL	NO	varchar	64	192	NULL	NULL	NULL	utf8	utf8_bin	varchar(64)	PRI		select,insert,update,references	
 def	mysql	db	Alter_priv	13	N	NO	enum	1	3	NULL	NULL	NULL	utf8	utf8_general_ci	enum('N','Y')			select,insert,update,references	
 def	mysql	db	Alter_routine_priv	19	N	NO	enum	1	3	NULL	NULL	NULL	utf8	utf8_general_ci	enum('N','Y')			select,insert,update,references	
@@ -105,7 +105,7 @@ def	mysql	host	Select_priv	3	N	NO	enum	1	3	NULL	NULL	NULL	utf8	utf8_general_ci	e
 def	mysql	host	Show_view_priv	16	N	NO	enum	1	3	NULL	NULL	NULL	utf8	utf8_general_ci	enum('N','Y')			select,insert,update,references	
 def	mysql	host	Trigger_priv	20	N	NO	enum	1	3	NULL	NULL	NULL	utf8	utf8_general_ci	enum('N','Y')			select,insert,update,references	
 def	mysql	host	Update_priv	5	N	NO	enum	1	3	NULL	NULL	NULL	utf8	utf8_general_ci	enum('N','Y')			select,insert,update,references	
-def	mysql	index_stat	avg_frequency	5	NULL	YES	double	NULL	NULL	22	NULL	NULL	NULL	NULL	double			select,insert,update,references	
+def	mysql	index_stat	avg_frequency	5	NULL	YES	decimal	NULL	NULL	12	4	NULL	NULL	NULL	decimal(12,4)			select,insert,update,references	
 def	mysql	index_stat	db_name	1	NULL	NO	varchar	64	192	NULL	NULL	NULL	utf8	utf8_bin	varchar(64)	PRI		select,insert,update,references	
 def	mysql	index_stat	index_name	3	NULL	NO	varchar	64	192	NULL	NULL	NULL	utf8	utf8_bin	varchar(64)	PRI		select,insert,update,references	
 def	mysql	index_stat	prefix_arity	4	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	NULL	int(11) unsigned	PRI		select,insert,update,references	
@@ -291,7 +291,7 @@ ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
 COL_CML	DATA_TYPE	CHARACTER_SET_NAME	COLLATION_NAME
 NULL	bigint	NULL	NULL
 NULL	datetime	NULL	NULL
-NULL	double	NULL	NULL
+NULL	decimal	NULL	NULL
 NULL	int	NULL	NULL
 NULL	smallint	NULL	NULL
 NULL	time	NULL	NULL
@@ -325,9 +325,9 @@ NULL	mysql	columns_priv	Timestamp	timestamp	NULL	NULL	NULL	NULL	timestamp
 3.0000	mysql	column_stat	column_name	varchar	64	192	utf8	utf8_bin	varchar(64)
 3.0000	mysql	column_stat	min_value	varchar	255	765	utf8	utf8_bin	varchar(255)
 3.0000	mysql	column_stat	max_value	varchar	255	765	utf8	utf8_bin	varchar(255)
-NULL	mysql	column_stat	nulls_ratio	double	NULL	NULL	NULL	NULL	double
-NULL	mysql	column_stat	avg_length	double	NULL	NULL	NULL	NULL	double
-NULL	mysql	column_stat	avg_frequency	double	NULL	NULL	NULL	NULL	double
+NULL	mysql	column_stat	nulls_ratio	decimal	NULL	NULL	NULL	NULL	decimal(12,4)
+NULL	mysql	column_stat	avg_length	decimal	NULL	NULL	NULL	NULL	decimal(12,4)
+NULL	mysql	column_stat	avg_frequency	decimal	NULL	NULL	NULL	NULL	decimal(12,4)
 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)
@@ -420,7 +420,7 @@ NULL	mysql	help_topic	help_category_id	smallint	NULL	NULL	NULL	NULL	smallint(5)
 3.0000	mysql	index_stat	table_name	varchar	64	192	utf8	utf8_bin	varchar(64)
 3.0000	mysql	index_stat	index_name	varchar	64	192	utf8	utf8_bin	varchar(64)
 NULL	mysql	index_stat	prefix_arity	int	NULL	NULL	NULL	NULL	int(11) unsigned
-NULL	mysql	index_stat	avg_frequency	double	NULL	NULL	NULL	NULL	double
+NULL	mysql	index_stat	avg_frequency	decimal	NULL	NULL	NULL	NULL	decimal(12,4)
 NULL	mysql	ndb_binlog_index	Position	bigint	NULL	NULL	NULL	NULL	bigint(20) unsigned
 1.0000	mysql	ndb_binlog_index	File	varchar	255	255	latin1	latin1_swedish_ci	varchar(255)
 NULL	mysql	ndb_binlog_index	epoch	bigint	NULL	NULL	NULL	NULL	bigint(20) unsigned
diff --git a/mysql-test/t/statistics.test b/mysql-test/t/statistics.test
index e4676c7b340..600c7eff105 100644
--- a/mysql-test/t/statistics.test
+++ b/mysql-test/t/statistics.test
@@ -6,22 +6,6 @@ drop table if exists t1,t2;
 
 set @save_use_stat_tables=@@use_stat_tables;
 
-CREATE VIEW table_stat AS
-SELECT * FROM mysql.table_stat;
- 
-CREATE VIEW column_stat AS
-  SELECT db_name, table_name, column_name,
-         min_value, max_value,
-         CAST(nulls_ratio AS decimal(12,4)) AS 'nulls_ratio',
-         CAST(avg_length AS decimal(12,4)) AS 'avg_length',
-         CAST(avg_frequency AS decimal(12,4)) AS 'avg_frequency'
-    FROM mysql.column_stat;
-
-CREATE VIEW index_stat AS
-  SELECT db_name, table_name, index_name, prefix_arity,
-         CAST(avg_frequency AS decimal(12,4)) AS 'avg_frequency'
-    FROM mysql.index_stat;
-
 DELETE FROM mysql.table_stat;
 DELETE FROM mysql.column_stat;
 DELETE FROM mysql.index_stat;  
@@ -85,13 +69,13 @@ INSERT INTO t1 VALUES
 
 ANALYZE TABLE t1;
 
-SELECT * FROM table_stat;
-SELECT * FROM column_stat;
-SELECT * FROM index_stat;
+SELECT * FROM mysql.table_stat;
+SELECT * FROM mysql.column_stat;
+SELECT * FROM mysql.index_stat;
 
 SELECT COUNT(*) FROM t1;
 
-SELECT * FROM column_stat
+SELECT * FROM mysql.column_stat
   WHERE db_name='test' AND table_name='t1' AND column_name='a';
 SELECT MIN(t1.a), MAX(t1.a), 
        (SELECT COUNT(*) FROM t1 WHERE t1.b IS NULL) /
@@ -100,7 +84,7 @@ SELECT MIN(t1.a), MAX(t1.a),
        (SELECT COUNT(DISTINCT t1.a) FROM t1) AS "AVG_FREQUENCY(t1.a)"
 FROM t1;
 
-SELECT * FROM column_stat
+SELECT * FROM mysql.column_stat
   WHERE db_name='test' AND table_name='t1' AND column_name='b';
 SELECT MIN(t1.b), MAX(t1.b), 
        (SELECT COUNT(*) FROM t1 WHERE t1.b IS NULL) /
@@ -109,7 +93,7 @@ SELECT MIN(t1.b), MAX(t1.b),
        (SELECT COUNT(DISTINCT t1.b) FROM t1) AS "AVG_FREQUENCY(t1.b)"
 FROM t1;
 
-SELECT * FROM column_stat 
+SELECT * FROM mysql.column_stat 
   WHERE db_name='test' AND table_name='t1' AND column_name='c';
 SELECT MIN(t1.c), MAX(t1.c), 
        (SELECT COUNT(*) FROM t1 WHERE t1.c IS NULL) /
@@ -118,7 +102,7 @@ SELECT MIN(t1.c), MAX(t1.c),
        (SELECT COUNT(DISTINCT t1.c) FROM t1) AS "AVG_FREQUENCY(t1.c)"
 FROM t1;
 
-SELECT * FROM column_stat
+SELECT * FROM mysql.column_stat
   WHERE db_name='test' AND table_name='t1' AND column_name='d';
 SELECT MIN(t1.d), MAX(t1.d), 
        (SELECT COUNT(*) FROM t1 WHERE t1.d IS NULL) /
@@ -127,7 +111,7 @@ SELECT MIN(t1.d), MAX(t1.d),
        (SELECT COUNT(DISTINCT t1.d) FROM t1) AS "AVG_FREQUENCY(t1.d)"
 FROM t1;
 
-SELECT * FROM column_stat
+SELECT * FROM mysql.column_stat
   WHERE db_name='test' AND table_name='t1' AND column_name='e';
 SELECT MIN(t1.e), MAX(t1.e), 
        (SELECT COUNT(*) FROM t1 WHERE t1.e IS NULL) /
@@ -136,7 +120,7 @@ SELECT MIN(t1.e), MAX(t1.e),
        (SELECT COUNT(DISTINCT t1.e) FROM t1) AS "AVG_FREQUENCY(t1.e)"
 FROM t1;
 
-SELECT * FROM index_stat
+SELECT * FROM mysql.index_stat
   WHERE db_name='test' AND table_name='t1' AND index_name='idx1';
 SELECT 
   (SELECT COUNT(*) FROM t1 WHERE t1.b IS NOT NULL) /
@@ -147,7 +131,7 @@ SELECT
      WHERE t1.b IS NOT NULL AND t1.e IS NOT NULL) 
   AS 'ARITY 2';
 
-SELECT * FROM index_stat
+SELECT * FROM mysql.index_stat
   WHERE db_name='test' AND table_name='t1' AND index_name='idx2';
 SELECT 
   (SELECT COUNT(*) FROM t1 WHERE t1.c IS NOT NULL) /
@@ -158,14 +142,14 @@ SELECT
      WHERE t1.c IS NOT NULL AND t1.d IS NOT NULL)
   AS 'ARITY 2';
 
-SELECT * FROM index_stat
+SELECT * FROM mysql.index_stat
   WHERE db_name='test' AND table_name='t1' AND index_name='idx3';
 SELECT 
   (SELECT COUNT(*) FROM t1 WHERE t1.d IS NOT NULL) /
   (SELECT COUNT(DISTINCT t1.d) FROM t1 WHERE t1.d IS NOT NULL)
   AS 'ARITY 1';
 
-SELECT * FROM index_stat
+SELECT * FROM mysql.index_stat
   WHERE db_name='test' AND table_name='t1' AND index_name='idx4';
 SELECT 
   (SELECT COUNT(*) FROM t1 WHERE t1.e IS NOT NULL) /
@@ -186,14 +170,14 @@ DELETE FROM mysql.column_stat;
 DELETE FROM mysql.index_stat;
 
 ANALYZE TABLE t1 PERSISTENT FOR COLUMNS() INDEXES();
-SELECT * FROM table_stat;
-SELECT * FROM column_stat;
-SELECT * FROM index_stat;
+SELECT * FROM mysql.table_stat;
+SELECT * FROM mysql.column_stat;
+SELECT * FROM mysql.index_stat;
 
 ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(c,e,b) INDEXES(idx2,idx4);
-SELECT * FROM table_stat;
-SELECT * FROM column_stat;
-SELECT * FROM index_stat;
+SELECT * FROM mysql.table_stat;
+SELECT * FROM mysql.column_stat;
+SELECT * FROM mysql.index_stat;
 
 DELETE FROM mysql.table_stat;
 DELETE FROM mysql.column_stat;
@@ -201,9 +185,9 @@ DELETE FROM mysql.index_stat;
 
 ANALYZE TABLE t1 PERSISTENT FOR COLUMNS ALL INDEXES ALL;
 
-SELECT * FROM table_stat;
-SELECT * FROM column_stat;
-SELECT * FROM index_stat;
+SELECT * FROM mysql.table_stat;
+SELECT * FROM mysql.column_stat;
+SELECT * FROM mysql.index_stat;
 
 
 CREATE TABLE t2 LIKE t1;
@@ -212,9 +196,9 @@ INSERT INTO t2 SELECT * FROM t1;
 
 ANALYZE TABLE t2;
 
-SELECT * FROM table_stat;
-SELECT * FROM column_stat ORDER BY column_name;
-SELECT * FROM index_stat ORDER BY index_name, prefix_arity, table_name;
+SELECT * FROM mysql.table_stat;
+SELECT * FROM mysql.column_stat ORDER BY column_name;
+SELECT * FROM mysql.index_stat ORDER BY index_name, prefix_arity, table_name;
 
 
 DELETE FROM mysql.table_stat;
@@ -231,8 +215,8 @@ ALTER TABLE t1
   
 ANALYZE TABLE t1;
 
-SELECT * FROM column_stat;
-SELECT * FROM index_stat;
+SELECT * FROM mysql.column_stat;
+SELECT * FROM mysql.index_stat;
 
 DROP TABLE t1,t2;
 
@@ -265,13 +249,13 @@ ANALYZE TABLE Country, City, CountryLanguage;
 --enable_result_log
 
 SELECT UPPER(db_name), UPPER(table_name), cardinality
-  FROM test.table_stat;
+  FROM mysql.table_stat;
 SELECT UPPER(db_name), UPPER(table_name), 
        column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency
-  FROM test.column_stat;
+  FROM mysql.column_stat;
 SELECT UPPER(db_name), UPPER(table_name),
        index_name, prefix_arity, avg_frequency
-  FROM test.index_stat;
+  FROM mysql.index_stat;
 
 use test;
 
@@ -302,13 +286,13 @@ ANALYZE TABLE Country, City, CountryLanguage;
 --enable_result_log
 
 SELECT UPPER(db_name), UPPER(table_name), cardinality
-  FROM test.table_stat;
+  FROM mysql.table_stat;
 SELECT UPPER(db_name), UPPER(table_name), 
        column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency
-  FROM test.column_stat;
+  FROM mysql.column_stat;
 SELECT UPPER(db_name), UPPER(table_name),
        index_name, prefix_arity, avg_frequency
-  FROM test.index_stat;
+  FROM mysql.index_stat;
 
 use test;
 
@@ -319,10 +303,6 @@ DELETE FROM mysql.table_stat;
 DELETE FROM mysql.column_stat;
 DELETE FROM mysql.index_stat;
   
-DROP VIEW test.table_stat;
-DROP VIEW test.column_stat;
-DROP VIEW test.index_stat;
-
 set use_stat_tables=@save_use_stat_tables;
 
     
\ No newline at end of file
diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql
index eaf4fda4026..e7d16c5b798 100644
--- a/scripts/mysql_system_tables.sql
+++ b/scripts/mysql_system_tables.sql
@@ -485,6 +485,6 @@ set @had_proxies_priv_table= @@warning_count != 0;
 
 CREATE TABLE IF NOT EXISTS table_stat (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, cardinality bigint(21) unsigned DEFAULT NULL, PRIMARY KEY (db_name,table_name) ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Tables';
 
-CREATE TABLE IF NOT EXISTS column_stat (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, column_name varchar(64) NOT NULL, min_value varchar(255) DEFAULT NULL, max_value varchar(255) DEFAULT NULL, nulls_ratio double DEFAULT NULL, avg_length double DEFAULT NULL, avg_frequency double DEFAULT NULL, PRIMARY KEY (db_name,table_name,column_name) ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns';
+CREATE TABLE IF NOT EXISTS column_stat (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, column_name varchar(64) NOT NULL, min_value varchar(255) DEFAULT NULL, max_value varchar(255) DEFAULT NULL, nulls_ratio decimal(12,4) DEFAULT NULL, avg_length decimal(12,4) DEFAULT NULL, avg_frequency decimal(12,4) DEFAULT NULL, PRIMARY KEY (db_name,table_name,column_name) ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns';
 
-CREATE TABLE IF NOT EXISTS index_stat (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, index_name varchar(64) NOT NULL, prefix_arity int(11) unsigned NOT NULL, avg_frequency double DEFAULT NULL, PRIMARY KEY (db_name,table_name,index_name,prefix_arity) ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Indexes';
+CREATE TABLE IF NOT EXISTS index_stat (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, index_name varchar(64) NOT NULL, prefix_arity int(11) unsigned NOT NULL, avg_frequency decimal(12,4) DEFAULT NULL, PRIMARY KEY (db_name,table_name,index_name,prefix_arity) ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Indexes';
diff --git a/sql/field.h b/sql/field.h
index 16ff02c6789..5df2f57fee4 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -219,6 +219,10 @@ public:
   /* Statistical data on a column */
   class Column_statistics
   {
+  private:
+    static const uint Scale_factor_nulls_ratio= 100000;
+    static const uint Scale_factor_avg_length= 100000;
+    static const uint Scale_factor_avg_frequency= 100000;
   public:
     /* 
       Bitmap indicating  what statistical characteristics
@@ -230,23 +234,54 @@ public:
     Field *min_value; 
     /* Maximum value for the column */   
     Field *max_value;
+  private:
     /* 
-      The ratio Z/N, where N is the total number of rows,
+      The ratio Z/N multiplied by the scale factor Scale_factor_nulls_ratio,
+      where N is the total number of rows,
       Z is the number of nulls in the column
     */
-    double nulls_ratio; 
+    ulong nulls_ratio; 
     /*
       Average number of bytes occupied by the representation of a
-      value of the column in memory buffers such as join buffer.
-      CHAR values are stripped of trailing spaces.
+      value of the column in memory buffers such as join buffer
+      multiplied by the scale factor Scale_factor_avg_length
+      CHAR values are stripped of trailing spaces
       Flexible values are stripped of their length prefixes.
     */
-    double avg_length;
+    ulong avg_length;
     /*
-      The ratio N/D, where N is the number of rows with null value 
+      The ratio N/D multiplied by the scale factor Scale_factor_avg_frequency,
+      where N is the number of rows with null value 
       in the column, D the number of distinct values among them
     */
-    double avg_frequency;
+    ulong avg_frequency;
+
+  public:
+    double get_nulls_ratio()
+    {
+      return (double) nulls_ratio /  Scale_factor_nulls_ratio;
+    }
+    double get_avg_length()
+    {
+      return (double) avg_length / Scale_factor_avg_length;
+    }
+    double get_avg_frequency()
+    {
+      return (double) avg_frequency / Scale_factor_avg_frequency;
+    }
+
+    void set_nulls_ratio (double val)
+    {
+      nulls_ratio= (ulong) (val * Scale_factor_nulls_ratio);
+    }
+    void set_avg_length (double val)
+    {
+      avg_length= (ulong) (val * Scale_factor_avg_length);
+    }
+    void set_avg_frequency (double val)
+    {
+      avg_frequency= (ulong) (val * Scale_factor_avg_frequency);
+    }
   };
   
   /*
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index cf0063b80d4..49a35ccf18b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -14595,8 +14595,8 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
     keyinfo->ext_key_parts= keyinfo->key_parts;
     keyinfo->key_length=0;
     keyinfo->rec_per_key=NULL;
-    keyinfo->read_stat.avg_frequency= NULL;
-    keyinfo->write_stat.avg_frequency= NULL;
+    keyinfo->read_stat.init_avg_frequency(NULL);
+    keyinfo->write_stat.init_avg_frequency(NULL);
     keyinfo->algorithm= HA_KEY_ALG_UNDEF;
     keyinfo->is_statistics_from_stat_tables= FALSE;
     keyinfo->name= (char*) "group_key";
@@ -14713,7 +14713,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
     keyinfo->algorithm= HA_KEY_ALG_UNDEF;
     keyinfo->is_statistics_from_stat_tables= FALSE;
     keyinfo->rec_per_key=0;
-    keyinfo->read_stat.avg_frequency= NULL;
+    keyinfo->read_stat.init_avg_frequency(NULL);
 
     /*
       Create an extra field to hold NULL bits so that unique indexes on
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index c2505cdc6ef..de5f2976053 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -600,13 +600,13 @@ public:
           }
           break;
         case COLUMN_STAT_NULLS_RATIO:
-          stat_field->store(table_field->write_stat.nulls_ratio);
+          stat_field->store(table_field->write_stat.get_nulls_ratio());
           break;
         case COLUMN_STAT_AVG_LENGTH:
-          stat_field->store(table_field->write_stat.avg_length);
+          stat_field->store(table_field->write_stat.get_avg_length());
           break;
         case COLUMN_STAT_AVG_FREQUENCY:
-          stat_field->store(table_field->write_stat.avg_frequency);
+          stat_field->store(table_field->write_stat.get_avg_frequency());
           break;            
         }
       }
@@ -665,13 +665,13 @@ public:
                                                     &my_charset_utf8_bin);
             break;
           case COLUMN_STAT_NULLS_RATIO:
-            table_field->read_stat.nulls_ratio= stat_field->val_real();
+            table_field->read_stat.set_nulls_ratio(stat_field->val_real());
             break;
           case COLUMN_STAT_AVG_LENGTH:
-            table_field->read_stat.avg_length= stat_field->val_real();
+            table_field->read_stat.set_avg_length(stat_field->val_real());
             break;
           case COLUMN_STAT_AVG_FREQUENCY:
-            table_field->read_stat.avg_frequency= stat_field->val_real();
+            table_field->read_stat.set_avg_frequency(stat_field->val_real());
             break;            
           }
         }
@@ -766,7 +766,7 @@ public:
   {
     Field *stat_field= stat_table->field[INDEX_STAT_AVG_FREQUENCY];
     double avg_frequency=
-             table_key_info->write_stat.avg_frequency[prefix_arity-1];
+      table_key_info->write_stat.get_avg_frequency(prefix_arity-1);
     if (avg_frequency == 0)
       stat_field->set_null();
     else
@@ -798,9 +798,9 @@ public:
     {
       Field *stat_field= stat_table->field[INDEX_STAT_AVG_FREQUENCY];
       if (!stat_field->is_null())
-          avg_frequency= stat_field->val_real();
+        avg_frequency= stat_field->val_real();
     }
-    table_key_info->read_stat.avg_frequency[prefix_arity-1]= avg_frequency;
+    table_key_info->read_stat.set_avg_frequency(prefix_arity-1, avg_frequency);
   }  
 
 };
@@ -1065,9 +1065,9 @@ public:
     {
       if (i < prefixes)
       {
-        index_info->write_stat.avg_frequency[i]=
-          state->prefix_count == 0 ? 0 :
-          (double) state->entry_count / state->prefix_count;
+        double val= state->prefix_count == 0 ?
+	            0 : (double) state->entry_count / state->prefix_count;                     
+        index_info->write_stat.set_avg_frequency(i, val);
       }
     }
   }       
@@ -1354,17 +1354,19 @@ int collect_statistics_for_table(THD *thd, TABLE *table)
 
     for (field_ptr= table->field; *field_ptr; field_ptr++)
     {
+      double val;
       table_field= *field_ptr;
       if (!bitmap_is_set(table->read_set, table_field->field_index))
         continue;
-      table_field->write_stat.nulls_ratio= (double) table_field->nulls/rows;
-      table_field->write_stat.avg_length=
-        (double) table_field->column_total_length / (rows-table_field->nulls);
+      val= (double) table_field->nulls / rows;
+      table_field->write_stat.set_nulls_ratio(val);
+      val= (double) table_field->column_total_length / (rows-table_field->nulls);
+      table_field->write_stat.set_avg_length(val);
       if (table_field->count_distinct)
       {
-        table_field->write_stat.avg_frequency= 
-          (double) (rows-table_field->nulls) /
-          table_field->count_distinct->get_value(); 
+        val= (double) (rows-table_field->nulls) /
+	     table_field->count_distinct->get_value(); 
+        table_field->write_stat.set_avg_frequency(val); 
         set_not_null_for_write_column_stat_value(table_field,
                                                  COLUMN_STAT_AVG_FREQUENCY);
         delete table_field->count_distinct;
@@ -1585,38 +1587,37 @@ int read_statistics_for_table(THD *thd, TABLE *table)
    
     key_part_map ext_key_part_map= key_info->ext_key_part_map;
     if (key_info->key_parts != key_info->ext_key_parts &&
-        key_info->read_stat.avg_frequency[key_info->key_parts] == 0)
+        key_info->read_stat.get_avg_frequency(key_info->key_parts) == 0)
     {
-      double *ptr;
-      double *ptr_end;
       KEY *pk_key_info= table->key_info + table->s->primary_key;
       uint k= key_info->key_parts;
       uint pk_parts= pk_key_info->key_parts;
       ha_rows n_rows= table->read_stat.cardinality;
-      double k_dist= n_rows / key_info->read_stat.avg_frequency[k-1]; 
-      double *k_avg_freq_ptr= key_info->read_stat.avg_frequency + k;
+      double k_dist= n_rows / key_info->read_stat.get_avg_frequency(k-1);
       uint m= 0;
       for (uint j= 0; j < pk_parts; j++)
       {
         if (!(ext_key_part_map & 1 << j))
 	{
-          for (ptr= k_avg_freq_ptr, ptr_end= ptr + m; ptr < ptr_end; ptr++)
+          for (uint l= k; l < k + m; l++)
 	  {
-            double avg_frequency= pk_key_info->read_stat.avg_frequency[j-1];
+            double avg_frequency= pk_key_info->read_stat.get_avg_frequency(j-1);
             set_if_smaller(avg_frequency, 1);
-	    (*ptr)*= pk_key_info->read_stat.avg_frequency[j]/avg_frequency;
+            double val= pk_key_info->read_stat.get_avg_frequency(j) /
+	                avg_frequency; 
+	    key_info->read_stat.set_avg_frequency (l, val);
           }
         }
         else
 	{
-           key_info->read_stat.avg_frequency[k + m]=
-             pk_key_info->read_stat.avg_frequency[j]; 
-	   m++;
+	  double avg_frequency= pk_key_info->read_stat.get_avg_frequency(j);
+	  key_info->read_stat.set_avg_frequency(k + m, avg_frequency);
+	  m++;
         }    
       }      
-      for (ptr= k_avg_freq_ptr, ptr_end= ptr + m; ptr < ptr_end; ptr++)
+      for (uint l= k; l < k + m; l++)
       {
-        double avg_frequency= *ptr;
+        double avg_frequency= key_info->read_stat.get_avg_frequency(l);
         if (avg_frequency == 0 ||
             table->read_stat.cardinality_is_null)
           avg_frequency= 1;
@@ -1625,7 +1626,7 @@ int read_statistics_for_table(THD *thd, TABLE *table)
           avg_frequency/= k_dist;
           set_if_bigger(avg_frequency, 1);
 	}
-        *ptr= avg_frequency;
+        key_info->read_stat.set_avg_frequency(l, avg_frequency);
       }
     }
   }
@@ -1662,7 +1663,8 @@ void set_statistics_for_table(THD *thd, TABLE *table)
        key_info < key_info_end; key_info++)
   {
     key_info->is_statistics_from_stat_tables=
-      (use_stat_table_mode > 1 &&  key_info->read_stat.avg_frequency &&
-       key_info->read_stat.avg_frequency[0] > 0.5);
+      (use_stat_table_mode > 1  &&
+       key_info->read_stat.avg_frequency_is_set() &&
+       key_info->read_stat.get_avg_frequency(0) > 0.5);
   }
 }
diff --git a/sql/structs.h b/sql/structs.h
index 9949a72964b..4a70820586d 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -124,14 +124,28 @@ typedef struct st_key {
    /* Statistical data on an index prefixes */
   class Index_statistics
   {
-  public:
+  private:
+    static const uint Scale_factor_avg_frequency= 100000;
     /*
-      The k-th element of this array contains the ratio N/D, 
+      The k-th element of this array contains the ratio N/D
+      multiplied by the scale factor Scale_factor_avg_frequency, 
       where N is the number of index entries without nulls 
       in the first k components, and D is the number of distinct
       k-component prefixes among them 
     */
-    double *avg_frequency;
+    ulong *avg_frequency;
+
+  public:
+    void init_avg_frequency(ulong *ptr) { avg_frequency= ptr; }
+    bool avg_frequency_is_set() { return avg_frequency != NULL; }
+    double get_avg_frequency(uint i)
+    {
+      return (double) avg_frequency[i] / Scale_factor_avg_frequency;
+    }
+    void set_avg_frequency(uint i, double val)
+    {
+      avg_frequency[i]= (ulong) (val * Scale_factor_avg_frequency);
+    }
   };
 
   /*
@@ -159,8 +173,7 @@ typedef struct st_key {
     if (rec_per_key == 0)
       return 0;
     return (is_statistics_from_stat_tables ?
-            (ulong) (100 * read_stat.avg_frequency[i]) / (double) 100 :
-            (double) rec_per_key[i]);
+            read_stat.get_avg_frequency(i) : (double) rec_per_key[i]);
   }
 } KEY;
 
diff --git a/sql/table.cc b/sql/table.cc
index de5c11ed92d..48f40a05c33 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -762,8 +762,8 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
   ulong pos, record_offset; 
   ulong *rec_per_key= NULL;
   ulong rec_buff_length;
-  double *read_avg_frequency= NULL;
-  double *write_avg_frequency= NULL;
+  ulong *read_avg_frequency= NULL;
+  ulong *write_avg_frequency= NULL;
   handler *handler_file= 0;
   KEY	*keyinfo;
   KEY_PART_INFO *key_part= NULL;
@@ -946,13 +946,13 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
       if (!(rec_per_key= (ulong*) alloc_root(&share->mem_root,
                                              sizeof(ulong) * ext_key_parts)))
         goto err;
-      if (!(read_avg_frequency= (double*) alloc_root(&share->mem_root,
-                                                     sizeof(double) *
-                                                     ext_key_parts)))
+      if (!(read_avg_frequency= (ulong*) alloc_root(&share->mem_root,
+                                                    sizeof(double) *
+                                                    ext_key_parts)))
         goto err;
-      if (!(write_avg_frequency= (double*) alloc_root(&share->mem_root,
-                                                      sizeof(double) * 
-                                                      ext_key_parts)))
+      if (!(write_avg_frequency= (ulong*) alloc_root(&share->mem_root,
+                                                     sizeof(double) * 
+                                                     ext_key_parts)))
         goto err;
       first_key_part= key_part;
       first_key_parts= first_keyinfo.key_parts;
@@ -966,8 +966,8 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
 
     keyinfo->key_part=	 key_part;
     keyinfo->rec_per_key= rec_per_key;
-    keyinfo->read_stat.avg_frequency= read_avg_frequency;
-    keyinfo->write_stat.avg_frequency= write_avg_frequency; 
+    keyinfo->read_stat.init_avg_frequency(read_avg_frequency);
+    keyinfo->write_stat.init_avg_frequency(write_avg_frequency); 
     for (j=keyinfo->key_parts ; j-- ; key_part++)
     {
       *rec_per_key++=0;
@@ -5957,7 +5957,7 @@ bool TABLE::add_tmp_key(uint key, uint key_parts,
   if (!keyinfo->rec_per_key)
     return TRUE;
   bzero(keyinfo->rec_per_key, sizeof(ulong)*key_parts);
-  keyinfo->read_stat.avg_frequency= NULL;
+  keyinfo->read_stat.init_avg_frequency(NULL);
 
   for (i= 0; i < key_parts; i++)
   {