Commit 4ff6fd34 authored by Igor Babaev's avatar Igor Babaev

Changed the type of all double columns in the system statistical tables

mysql.column_stat, mysql.table_stat for the type DECIMAL(12,4).
When cached the values from these columns are multiplied by factor 10^5
and stored as ulong numbers now. 
parent f549f495
...@@ -17,34 +17,34 @@ dbt3_s001 region 5 ...@@ -17,34 +17,34 @@ dbt3_s001 region 5
dbt3_s001 supplier 10 dbt3_s001 supplier 10
select * from mysql.index_stat; select * from mysql.index_stat;
db_name table_name index_name prefix_arity avg_frequency db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 customer PRIMARY 1 1 dbt3_s001 customer PRIMARY 1 1.0000
dbt3_s001 customer i_c_nationkey 1 6 dbt3_s001 customer i_c_nationkey 1 6.0000
dbt3_s001 lineitem PRIMARY 1 4.003333333333333 dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1 dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_shipdate 1 2.650044130626655 dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.025 dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.57857142857143 dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_partkey 1 30.025 dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey 1 600.5 dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_receiptdate 1 2.6477072310405645 dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_orderkey 1 4.003333333333333 dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.003333333333333 dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0403672903672905 dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_commitdate 1 2.7159656264133876 dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 nation PRIMARY 1 1 dbt3_s001 nation PRIMARY 1 1.0000
dbt3_s001 nation i_n_regionkey 1 5 dbt3_s001 nation i_n_regionkey 1 5.0000
dbt3_s001 orders PRIMARY 1 1 dbt3_s001 orders PRIMARY 1 1.0000
dbt3_s001 orders i_o_orderdate 1 1.3321492007104796 dbt3_s001 orders i_o_orderdate 1 1.3321
dbt3_s001 orders i_o_custkey 1 15 dbt3_s001 orders i_o_custkey 1 15.0000
dbt3_s001 part PRIMARY 1 1 dbt3_s001 part PRIMARY 1 1.0000
dbt3_s001 part i_p_retailprice 1 1 dbt3_s001 part i_p_retailprice 1 1.0000
dbt3_s001 partsupp PRIMARY 1 3.5 dbt3_s001 partsupp PRIMARY 1 3.5000
dbt3_s001 partsupp PRIMARY 2 1 dbt3_s001 partsupp PRIMARY 2 1.0000
dbt3_s001 partsupp i_ps_partkey 1 3.5 dbt3_s001 partsupp i_ps_partkey 1 3.5000
dbt3_s001 partsupp i_ps_suppkey 1 70 dbt3_s001 partsupp i_ps_suppkey 1 70.0000
dbt3_s001 region PRIMARY 1 1 dbt3_s001 region PRIMARY 1 1.0000
dbt3_s001 supplier PRIMARY 1 1 dbt3_s001 supplier PRIMARY 1 1.0000
dbt3_s001 supplier i_s_nationkey 1 1.1111111111111112 dbt3_s001 supplier i_s_nationkey 1 1.1111
set optimizer_switch=@save_optimizer_switch; set optimizer_switch=@save_optimizer_switch;
set @save_optimizer_switch=@@optimizer_switch; set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='index_condition_pushdown=off'; set optimizer_switch='index_condition_pushdown=off';
...@@ -90,47 +90,47 @@ dbt3_s001 region 5 ...@@ -90,47 +90,47 @@ dbt3_s001 region 5
dbt3_s001 supplier 10 dbt3_s001 supplier 10
select * from mysql.index_stat; select * from mysql.index_stat;
db_name table_name index_name prefix_arity avg_frequency db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 customer PRIMARY 1 1 dbt3_s001 customer PRIMARY 1 1.0000
dbt3_s001 customer i_c_nationkey 1 6 dbt3_s001 customer i_c_nationkey 1 6.0000
dbt3_s001 lineitem PRIMARY 1 4.003333333333333 dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1 dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_shipdate 1 2.650044130626655 dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.025 dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.57857142857143 dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_partkey 1 30.025 dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey 1 600.5 dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_receiptdate 1 2.6477072310405645 dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_orderkey 1 4.003333333333333 dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.003333333333333 dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0403672903672905 dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_commitdate 1 2.7159656264133876 dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 nation PRIMARY 1 1 dbt3_s001 nation PRIMARY 1 1.0000
dbt3_s001 nation i_n_regionkey 1 5 dbt3_s001 nation i_n_regionkey 1 5.0000
dbt3_s001 orders PRIMARY 1 1 dbt3_s001 orders PRIMARY 1 1.0000
dbt3_s001 orders i_o_orderdate 1 1.3321492007104796 dbt3_s001 orders i_o_orderdate 1 1.3321
dbt3_s001 orders i_o_custkey 1 15 dbt3_s001 orders i_o_custkey 1 15.0000
dbt3_s001 part PRIMARY 1 1 dbt3_s001 part PRIMARY 1 1.0000
dbt3_s001 part i_p_retailprice 1 1 dbt3_s001 part i_p_retailprice 1 1.0000
dbt3_s001 partsupp PRIMARY 1 3.5 dbt3_s001 partsupp PRIMARY 1 3.5000
dbt3_s001 partsupp PRIMARY 2 1 dbt3_s001 partsupp PRIMARY 2 1.0000
dbt3_s001 partsupp i_ps_partkey 1 3.5 dbt3_s001 partsupp i_ps_partkey 1 3.5000
dbt3_s001 partsupp i_ps_suppkey 1 70 dbt3_s001 partsupp i_ps_suppkey 1 70.0000
dbt3_s001 region PRIMARY 1 1 dbt3_s001 region PRIMARY 1 1.0000
dbt3_s001 supplier PRIMARY 1 1 dbt3_s001 supplier PRIMARY 1 1.0000
dbt3_s001 supplier i_s_nationkey 1 1.1111111111111112 dbt3_s001 supplier i_s_nationkey 1 1.1111
select * from mysql.table_stat where table_name='orders'; select * from mysql.table_stat where table_name='orders';
db_name table_name cardinality db_name table_name cardinality
dbt3_s001 orders 1500 dbt3_s001 orders 1500
select * from mysql.index_stat where table_name='orders'; select * from mysql.index_stat where table_name='orders';
db_name table_name index_name prefix_arity avg_frequency db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 orders PRIMARY 1 1 dbt3_s001 orders PRIMARY 1 1.0000
dbt3_s001 orders i_o_orderdate 1 1.3321492007104796 dbt3_s001 orders i_o_orderdate 1 1.3321
dbt3_s001 orders i_o_custkey 1 15 dbt3_s001 orders i_o_custkey 1 15.0000
select (select cardinality from mysql.table_stat where table_name='orders') / select (select cardinality from mysql.table_stat where table_name='orders') /
(select avg_frequency from mysql.index_stat (select avg_frequency from mysql.index_stat
where index_name='i_o_orderdate' and prefix_arity=1) as n_distinct; where index_name='i_o_orderdate' and prefix_arity=1) as n_distinct;
n_distinct n_distinct
1126 1126.0416
select count(distinct o_orderdate) from orders; select count(distinct o_orderdate) from orders;
count(distinct o_orderdate) count(distinct o_orderdate)
1126 1126
...@@ -138,20 +138,20 @@ select (select cardinality from mysql.table_stat where table_name='orders') / ...@@ -138,20 +138,20 @@ select (select cardinality from mysql.table_stat where table_name='orders') /
(select avg_frequency from mysql.index_stat (select avg_frequency from mysql.index_stat
where index_name='i_o_custkey' and prefix_arity=1) as n_distinct; where index_name='i_o_custkey' and prefix_arity=1) as n_distinct;
n_distinct n_distinct
100 100.0000
select count(distinct o_custkey) from orders; select count(distinct o_custkey) from orders;
count(distinct o_custkey) count(distinct o_custkey)
100 100
show index from orders; 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 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 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 orders 1 i_o_custkey 1 o_custkey A 100 NULL NULL YES BTREE
select index_name, column_name, cardinality from information_schema.statistics select index_name, column_name, cardinality from information_schema.statistics
where table_name='orders'; where table_name='orders';
index_name column_name cardinality index_name column_name cardinality
PRIMARY o_orderkey 1500 PRIMARY o_orderkey 1500
i_o_orderdate o_orderDATE 1127 i_o_orderdate o_orderDATE 1126
i_o_custkey o_custkey 100 i_o_custkey o_custkey 100
set @save_optimizer_switch=@@optimizer_switch; set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='index_condition_pushdown=off'; set optimizer_switch='index_condition_pushdown=off';
......
...@@ -20,34 +20,34 @@ dbt3_s001 region 5 ...@@ -20,34 +20,34 @@ dbt3_s001 region 5
dbt3_s001 supplier 10 dbt3_s001 supplier 10
select * from mysql.index_stat; select * from mysql.index_stat;
db_name table_name index_name prefix_arity avg_frequency db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 customer PRIMARY 1 1 dbt3_s001 customer PRIMARY 1 1.0000
dbt3_s001 customer i_c_nationkey 1 6 dbt3_s001 customer i_c_nationkey 1 6.0000
dbt3_s001 lineitem PRIMARY 1 4.003333333333333 dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1 dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_shipdate 1 2.650044130626655 dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.025 dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.57857142857143 dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_partkey 1 30.025 dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey 1 600.5 dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_receiptdate 1 2.6477072310405645 dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_orderkey 1 4.003333333333333 dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.003333333333333 dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0403672903672905 dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_commitdate 1 2.7159656264133876 dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 nation PRIMARY 1 1 dbt3_s001 nation PRIMARY 1 1.0000
dbt3_s001 nation i_n_regionkey 1 5 dbt3_s001 nation i_n_regionkey 1 5.0000
dbt3_s001 orders PRIMARY 1 1 dbt3_s001 orders PRIMARY 1 1.0000
dbt3_s001 orders i_o_orderdate 1 1.3321492007104796 dbt3_s001 orders i_o_orderdate 1 1.3321
dbt3_s001 orders i_o_custkey 1 15 dbt3_s001 orders i_o_custkey 1 15.0000
dbt3_s001 part PRIMARY 1 1 dbt3_s001 part PRIMARY 1 1.0000
dbt3_s001 part i_p_retailprice 1 1 dbt3_s001 part i_p_retailprice 1 1.0000
dbt3_s001 partsupp PRIMARY 1 3.5 dbt3_s001 partsupp PRIMARY 1 3.5000
dbt3_s001 partsupp PRIMARY 2 1 dbt3_s001 partsupp PRIMARY 2 1.0000
dbt3_s001 partsupp i_ps_partkey 1 3.5 dbt3_s001 partsupp i_ps_partkey 1 3.5000
dbt3_s001 partsupp i_ps_suppkey 1 70 dbt3_s001 partsupp i_ps_suppkey 1 70.0000
dbt3_s001 region PRIMARY 1 1 dbt3_s001 region PRIMARY 1 1.0000
dbt3_s001 supplier PRIMARY 1 1 dbt3_s001 supplier PRIMARY 1 1.0000
dbt3_s001 supplier i_s_nationkey 1 1.1111111111111112 dbt3_s001 supplier i_s_nationkey 1 1.1111
set optimizer_switch=@save_optimizer_switch; set optimizer_switch=@save_optimizer_switch;
set @save_optimizer_switch=@@optimizer_switch; set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='index_condition_pushdown=off'; set optimizer_switch='index_condition_pushdown=off';
...@@ -93,71 +93,71 @@ dbt3_s001 region 5 ...@@ -93,71 +93,71 @@ dbt3_s001 region 5
dbt3_s001 supplier 10 dbt3_s001 supplier 10
select * from mysql.index_stat; select * from mysql.index_stat;
db_name table_name index_name prefix_arity avg_frequency db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 customer PRIMARY 1 1 dbt3_s001 customer PRIMARY 1 1.0000
dbt3_s001 customer i_c_nationkey 1 6 dbt3_s001 customer i_c_nationkey 1 6.0000
dbt3_s001 customer i_c_nationkey 2 1 dbt3_s001 customer i_c_nationkey 2 1.0000
dbt3_s001 lineitem PRIMARY 1 4.003333333333333 dbt3_s001 lineitem PRIMARY 1 4.0033
dbt3_s001 lineitem PRIMARY 2 1 dbt3_s001 lineitem PRIMARY 2 1.0000
dbt3_s001 lineitem i_l_shipdate 1 2.650044130626655 dbt3_s001 lineitem i_l_shipdate 1 2.6500
dbt3_s001 lineitem i_l_shipdate 2 1.014872401554842 dbt3_s001 lineitem i_l_shipdate 2 1.0149
dbt3_s001 lineitem i_l_shipdate 3 1 dbt3_s001 lineitem i_l_shipdate 3 1.0000
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.025 dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.57857142857143 dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_suppkey_partkey 3 1.0030065141139135 dbt3_s001 lineitem i_l_suppkey_partkey 3 1.0030
dbt3_s001 lineitem i_l_suppkey_partkey 4 1 dbt3_s001 lineitem i_l_suppkey_partkey 4 1.0000
dbt3_s001 lineitem i_l_partkey 1 30.025 dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_partkey 2 1.008904569892473 dbt3_s001 lineitem i_l_partkey 2 1.0089
dbt3_s001 lineitem i_l_partkey 3 1 dbt3_s001 lineitem i_l_partkey 3 1.0000
dbt3_s001 lineitem i_l_suppkey 1 600.5 dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey 2 1.207277844792923 dbt3_s001 lineitem i_l_suppkey 2 1.2073
dbt3_s001 lineitem i_l_suppkey 3 1 dbt3_s001 lineitem i_l_suppkey 3 1.0000
dbt3_s001 lineitem i_l_receiptdate 1 2.6477072310405645 dbt3_s001 lineitem i_l_receiptdate 1 2.6477
dbt3_s001 lineitem i_l_receiptdate 2 1.0152155536770922 dbt3_s001 lineitem i_l_receiptdate 2 1.0152
dbt3_s001 lineitem i_l_receiptdate 3 1 dbt3_s001 lineitem i_l_receiptdate 3 1.0000
dbt3_s001 lineitem i_l_orderkey 1 4.003333333333333 dbt3_s001 lineitem i_l_orderkey 1 4.0033
dbt3_s001 lineitem i_l_orderkey 2 1 dbt3_s001 lineitem i_l_orderkey 2 1.0000
dbt3_s001 lineitem i_l_orderkey_quantity 1 4.003333333333333 dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033
dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0403672903672905 dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404
dbt3_s001 lineitem i_l_orderkey_quantity 3 1 dbt3_s001 lineitem i_l_orderkey_quantity 3 1.0000
dbt3_s001 lineitem i_l_commitdate 1 2.7159656264133876 dbt3_s001 lineitem i_l_commitdate 1 2.7160
dbt3_s001 lineitem i_l_commitdate 2 1.036416983085951 dbt3_s001 lineitem i_l_commitdate 2 1.0364
dbt3_s001 lineitem i_l_commitdate 3 1 dbt3_s001 lineitem i_l_commitdate 3 1.0000
dbt3_s001 nation PRIMARY 1 1 dbt3_s001 nation PRIMARY 1 1.0000
dbt3_s001 nation i_n_regionkey 1 5 dbt3_s001 nation i_n_regionkey 1 5.0000
dbt3_s001 nation i_n_regionkey 2 1 dbt3_s001 nation i_n_regionkey 2 1.0000
dbt3_s001 orders PRIMARY 1 1 dbt3_s001 orders PRIMARY 1 1.0000
dbt3_s001 orders i_o_orderdate 1 1.3321492007104796 dbt3_s001 orders i_o_orderdate 1 1.3321
dbt3_s001 orders i_o_orderdate 2 1 dbt3_s001 orders i_o_orderdate 2 1.0000
dbt3_s001 orders i_o_custkey 1 15 dbt3_s001 orders i_o_custkey 1 15.0000
dbt3_s001 orders i_o_custkey 2 1 dbt3_s001 orders i_o_custkey 2 1.0000
dbt3_s001 part PRIMARY 1 1 dbt3_s001 part PRIMARY 1 1.0000
dbt3_s001 part i_p_retailprice 1 1 dbt3_s001 part i_p_retailprice 1 1.0000
dbt3_s001 part i_p_retailprice 2 1 dbt3_s001 part i_p_retailprice 2 1.0000
dbt3_s001 partsupp PRIMARY 1 3.5 dbt3_s001 partsupp PRIMARY 1 3.5000
dbt3_s001 partsupp PRIMARY 2 1 dbt3_s001 partsupp PRIMARY 2 1.0000
dbt3_s001 partsupp i_ps_partkey 1 3.5 dbt3_s001 partsupp i_ps_partkey 1 3.5000
dbt3_s001 partsupp i_ps_partkey 2 1 dbt3_s001 partsupp i_ps_partkey 2 1.0000
dbt3_s001 partsupp i_ps_suppkey 1 70 dbt3_s001 partsupp i_ps_suppkey 1 70.0000
dbt3_s001 partsupp i_ps_suppkey 2 1 dbt3_s001 partsupp i_ps_suppkey 2 1.0000
dbt3_s001 region PRIMARY 1 1 dbt3_s001 region PRIMARY 1 1.0000
dbt3_s001 supplier PRIMARY 1 1 dbt3_s001 supplier PRIMARY 1 1.0000
dbt3_s001 supplier i_s_nationkey 1 1.1111111111111112 dbt3_s001 supplier i_s_nationkey 1 1.1111
dbt3_s001 supplier i_s_nationkey 2 1 dbt3_s001 supplier i_s_nationkey 2 1.0000
select * from mysql.table_stat where table_name='orders'; select * from mysql.table_stat where table_name='orders';
db_name table_name cardinality db_name table_name cardinality
dbt3_s001 orders 1500 dbt3_s001 orders 1500
select * from mysql.index_stat where table_name='orders'; select * from mysql.index_stat where table_name='orders';
db_name table_name index_name prefix_arity avg_frequency db_name table_name index_name prefix_arity avg_frequency
dbt3_s001 orders PRIMARY 1 1 dbt3_s001 orders PRIMARY 1 1.0000
dbt3_s001 orders i_o_orderdate 1 1.3321492007104796 dbt3_s001 orders i_o_orderdate 1 1.3321
dbt3_s001 orders i_o_orderdate 2 1 dbt3_s001 orders i_o_orderdate 2 1.0000
dbt3_s001 orders i_o_custkey 1 15 dbt3_s001 orders i_o_custkey 1 15.0000
dbt3_s001 orders i_o_custkey 2 1 dbt3_s001 orders i_o_custkey 2 1.0000
select (select cardinality from mysql.table_stat where table_name='orders') / select (select cardinality from mysql.table_stat where table_name='orders') /
(select avg_frequency from mysql.index_stat (select avg_frequency from mysql.index_stat
where index_name='i_o_orderdate' and prefix_arity=1) as n_distinct; where index_name='i_o_orderdate' and prefix_arity=1) as n_distinct;
n_distinct n_distinct
1126 1126.0416
select count(distinct o_orderdate) from orders; select count(distinct o_orderdate) from orders;
count(distinct o_orderdate) count(distinct o_orderdate)
1126 1126
...@@ -165,20 +165,20 @@ select (select cardinality from mysql.table_stat where table_name='orders') / ...@@ -165,20 +165,20 @@ select (select cardinality from mysql.table_stat where table_name='orders') /
(select avg_frequency from mysql.index_stat (select avg_frequency from mysql.index_stat
where index_name='i_o_custkey' and prefix_arity=1) as n_distinct; where index_name='i_o_custkey' and prefix_arity=1) as n_distinct;
n_distinct n_distinct
100 100.0000
select count(distinct o_custkey) from orders; select count(distinct o_custkey) from orders;
count(distinct o_custkey) count(distinct o_custkey)
100 100
show index from orders; 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 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 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 orders 1 i_o_custkey 1 o_custkey A 100 NULL NULL YES BTREE
select index_name, column_name, cardinality from information_schema.statistics select index_name, column_name, cardinality from information_schema.statistics
where table_name='orders'; where table_name='orders';
index_name column_name cardinality index_name column_name cardinality
PRIMARY o_orderkey 1500 PRIMARY o_orderkey 1500
i_o_orderdate o_orderDATE 1127 i_o_orderdate o_orderDATE 1126
i_o_custkey o_custkey 100 i_o_custkey o_custkey 100
set @save_optimizer_switch=@@optimizer_switch; set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='index_condition_pushdown=off'; set optimizer_switch='index_condition_pushdown=off';
......
This diff is collapsed.
...@@ -283,9 +283,9 @@ column_stat CREATE TABLE `column_stat` ( ...@@ -283,9 +283,9 @@ column_stat CREATE TABLE `column_stat` (
`column_name` varchar(64) COLLATE utf8_bin NOT NULL, `column_name` varchar(64) COLLATE utf8_bin NOT NULL,
`min_value` varchar(255) COLLATE utf8_bin DEFAULT NULL, `min_value` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`max_value` varchar(255) COLLATE utf8_bin DEFAULT NULL, `max_value` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`nulls_ratio` double DEFAULT NULL, `nulls_ratio` decimal(12,4) DEFAULT NULL,
`avg_length` double DEFAULT NULL, `avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` double DEFAULT NULL, `avg_frequency` decimal(12,4) DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`) PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Columns' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Columns'
show create table index_stat; show create table index_stat;
...@@ -295,7 +295,7 @@ index_stat CREATE TABLE `index_stat` ( ...@@ -295,7 +295,7 @@ index_stat CREATE TABLE `index_stat` (
`table_name` varchar(64) COLLATE utf8_bin NOT NULL, `table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`index_name` varchar(64) COLLATE utf8_bin NOT NULL, `index_name` varchar(64) COLLATE utf8_bin NOT NULL,
`prefix_arity` int(11) unsigned 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`) PRIMARY KEY (`db_name`,`table_name`,`index_name`,`prefix_arity`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Indexes' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Indexes'
show tables; show tables;
......
...@@ -9,13 +9,13 @@ def mysql columns_priv Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char( ...@@ -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 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 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 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_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 double NULL NULL 22 NULL NULL NULL NULL double 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 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 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 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 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 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_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 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 ...@@ -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 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 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 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 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 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 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; ...@@ -291,7 +291,7 @@ ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
NULL bigint NULL NULL NULL bigint NULL NULL
NULL datetime NULL NULL NULL datetime NULL NULL
NULL double NULL NULL NULL decimal NULL NULL
NULL int NULL NULL NULL int NULL NULL
NULL smallint NULL NULL NULL smallint NULL NULL
NULL time NULL NULL NULL time NULL NULL
...@@ -325,9 +325,9 @@ NULL mysql columns_priv Timestamp timestamp NULL NULL NULL NULL timestamp ...@@ -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 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 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) 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 nulls_ratio decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stat avg_length double NULL NULL NULL NULL double NULL mysql column_stat avg_length decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stat avg_frequency double NULL NULL NULL NULL double 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 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 Db char 64 192 utf8 utf8_bin char(64)
3.0000 mysql db User char 16 48 utf8 utf8_bin char(16) 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) ...@@ -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 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) 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 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 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) 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 NULL mysql ndb_binlog_index epoch bigint NULL NULL NULL NULL bigint(20) unsigned
......
...@@ -6,22 +6,6 @@ drop table if exists t1,t2; ...@@ -6,22 +6,6 @@ drop table if exists t1,t2;
set @save_use_stat_tables=@@use_stat_tables; 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.table_stat;
DELETE FROM mysql.column_stat; DELETE FROM mysql.column_stat;
DELETE FROM mysql.index_stat; DELETE FROM mysql.index_stat;
...@@ -85,13 +69,13 @@ INSERT INTO t1 VALUES ...@@ -85,13 +69,13 @@ INSERT INTO t1 VALUES
ANALYZE TABLE t1; ANALYZE TABLE t1;
SELECT * FROM table_stat; SELECT * FROM mysql.table_stat;
SELECT * FROM column_stat; SELECT * FROM mysql.column_stat;
SELECT * FROM index_stat; SELECT * FROM mysql.index_stat;
SELECT COUNT(*) FROM t1; 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'; WHERE db_name='test' AND table_name='t1' AND column_name='a';
SELECT MIN(t1.a), MAX(t1.a), SELECT MIN(t1.a), MAX(t1.a),
(SELECT COUNT(*) FROM t1 WHERE t1.b IS NULL) / (SELECT COUNT(*) FROM t1 WHERE t1.b IS NULL) /
...@@ -100,7 +84,7 @@ SELECT MIN(t1.a), MAX(t1.a), ...@@ -100,7 +84,7 @@ SELECT MIN(t1.a), MAX(t1.a),
(SELECT COUNT(DISTINCT t1.a) FROM t1) AS "AVG_FREQUENCY(t1.a)" (SELECT COUNT(DISTINCT t1.a) FROM t1) AS "AVG_FREQUENCY(t1.a)"
FROM t1; FROM t1;
SELECT * FROM column_stat SELECT * FROM mysql.column_stat
WHERE db_name='test' AND table_name='t1' AND column_name='b'; WHERE db_name='test' AND table_name='t1' AND column_name='b';
SELECT MIN(t1.b), MAX(t1.b), SELECT MIN(t1.b), MAX(t1.b),
(SELECT COUNT(*) FROM t1 WHERE t1.b IS NULL) / (SELECT COUNT(*) FROM t1 WHERE t1.b IS NULL) /
...@@ -109,7 +93,7 @@ SELECT MIN(t1.b), MAX(t1.b), ...@@ -109,7 +93,7 @@ SELECT MIN(t1.b), MAX(t1.b),
(SELECT COUNT(DISTINCT t1.b) FROM t1) AS "AVG_FREQUENCY(t1.b)" (SELECT COUNT(DISTINCT t1.b) FROM t1) AS "AVG_FREQUENCY(t1.b)"
FROM t1; FROM t1;
SELECT * FROM column_stat SELECT * FROM mysql.column_stat
WHERE db_name='test' AND table_name='t1' AND column_name='c'; WHERE db_name='test' AND table_name='t1' AND column_name='c';
SELECT MIN(t1.c), MAX(t1.c), SELECT MIN(t1.c), MAX(t1.c),
(SELECT COUNT(*) FROM t1 WHERE t1.c IS NULL) / (SELECT COUNT(*) FROM t1 WHERE t1.c IS NULL) /
...@@ -118,7 +102,7 @@ SELECT MIN(t1.c), MAX(t1.c), ...@@ -118,7 +102,7 @@ SELECT MIN(t1.c), MAX(t1.c),
(SELECT COUNT(DISTINCT t1.c) FROM t1) AS "AVG_FREQUENCY(t1.c)" (SELECT COUNT(DISTINCT t1.c) FROM t1) AS "AVG_FREQUENCY(t1.c)"
FROM t1; FROM t1;
SELECT * FROM column_stat SELECT * FROM mysql.column_stat
WHERE db_name='test' AND table_name='t1' AND column_name='d'; WHERE db_name='test' AND table_name='t1' AND column_name='d';
SELECT MIN(t1.d), MAX(t1.d), SELECT MIN(t1.d), MAX(t1.d),
(SELECT COUNT(*) FROM t1 WHERE t1.d IS NULL) / (SELECT COUNT(*) FROM t1 WHERE t1.d IS NULL) /
...@@ -127,7 +111,7 @@ SELECT MIN(t1.d), MAX(t1.d), ...@@ -127,7 +111,7 @@ SELECT MIN(t1.d), MAX(t1.d),
(SELECT COUNT(DISTINCT t1.d) FROM t1) AS "AVG_FREQUENCY(t1.d)" (SELECT COUNT(DISTINCT t1.d) FROM t1) AS "AVG_FREQUENCY(t1.d)"
FROM t1; FROM t1;
SELECT * FROM column_stat SELECT * FROM mysql.column_stat
WHERE db_name='test' AND table_name='t1' AND column_name='e'; WHERE db_name='test' AND table_name='t1' AND column_name='e';
SELECT MIN(t1.e), MAX(t1.e), SELECT MIN(t1.e), MAX(t1.e),
(SELECT COUNT(*) FROM t1 WHERE t1.e IS NULL) / (SELECT COUNT(*) FROM t1 WHERE t1.e IS NULL) /
...@@ -136,7 +120,7 @@ SELECT MIN(t1.e), MAX(t1.e), ...@@ -136,7 +120,7 @@ SELECT MIN(t1.e), MAX(t1.e),
(SELECT COUNT(DISTINCT t1.e) FROM t1) AS "AVG_FREQUENCY(t1.e)" (SELECT COUNT(DISTINCT t1.e) FROM t1) AS "AVG_FREQUENCY(t1.e)"
FROM t1; FROM t1;
SELECT * FROM index_stat SELECT * FROM mysql.index_stat
WHERE db_name='test' AND table_name='t1' AND index_name='idx1'; WHERE db_name='test' AND table_name='t1' AND index_name='idx1';
SELECT SELECT
(SELECT COUNT(*) FROM t1 WHERE t1.b IS NOT NULL) / (SELECT COUNT(*) FROM t1 WHERE t1.b IS NOT NULL) /
...@@ -147,7 +131,7 @@ SELECT ...@@ -147,7 +131,7 @@ SELECT
WHERE t1.b IS NOT NULL AND t1.e IS NOT NULL) WHERE t1.b IS NOT NULL AND t1.e IS NOT NULL)
AS 'ARITY 2'; AS 'ARITY 2';
SELECT * FROM index_stat SELECT * FROM mysql.index_stat
WHERE db_name='test' AND table_name='t1' AND index_name='idx2'; WHERE db_name='test' AND table_name='t1' AND index_name='idx2';
SELECT SELECT
(SELECT COUNT(*) FROM t1 WHERE t1.c IS NOT NULL) / (SELECT COUNT(*) FROM t1 WHERE t1.c IS NOT NULL) /
...@@ -158,14 +142,14 @@ SELECT ...@@ -158,14 +142,14 @@ SELECT
WHERE t1.c IS NOT NULL AND t1.d IS NOT NULL) WHERE t1.c IS NOT NULL AND t1.d IS NOT NULL)
AS 'ARITY 2'; AS 'ARITY 2';
SELECT * FROM index_stat SELECT * FROM mysql.index_stat
WHERE db_name='test' AND table_name='t1' AND index_name='idx3'; WHERE db_name='test' AND table_name='t1' AND index_name='idx3';
SELECT SELECT
(SELECT COUNT(*) FROM t1 WHERE t1.d IS NOT NULL) / (SELECT COUNT(*) FROM t1 WHERE t1.d IS NOT NULL) /
(SELECT COUNT(DISTINCT t1.d) FROM t1 WHERE t1.d IS NOT NULL) (SELECT COUNT(DISTINCT t1.d) FROM t1 WHERE t1.d IS NOT NULL)
AS 'ARITY 1'; AS 'ARITY 1';
SELECT * FROM index_stat SELECT * FROM mysql.index_stat
WHERE db_name='test' AND table_name='t1' AND index_name='idx4'; WHERE db_name='test' AND table_name='t1' AND index_name='idx4';
SELECT SELECT
(SELECT COUNT(*) FROM t1 WHERE t1.e IS NOT NULL) / (SELECT COUNT(*) FROM t1 WHERE t1.e IS NOT NULL) /
...@@ -186,14 +170,14 @@ DELETE FROM mysql.column_stat; ...@@ -186,14 +170,14 @@ DELETE FROM mysql.column_stat;
DELETE FROM mysql.index_stat; DELETE FROM mysql.index_stat;
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS() INDEXES(); ANALYZE TABLE t1 PERSISTENT FOR COLUMNS() INDEXES();
SELECT * FROM table_stat; SELECT * FROM mysql.table_stat;
SELECT * FROM column_stat; SELECT * FROM mysql.column_stat;
SELECT * FROM index_stat; SELECT * FROM mysql.index_stat;
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(c,e,b) INDEXES(idx2,idx4); ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(c,e,b) INDEXES(idx2,idx4);
SELECT * FROM table_stat; SELECT * FROM mysql.table_stat;
SELECT * FROM column_stat; SELECT * FROM mysql.column_stat;
SELECT * FROM index_stat; SELECT * FROM mysql.index_stat;
DELETE FROM mysql.table_stat; DELETE FROM mysql.table_stat;
DELETE FROM mysql.column_stat; DELETE FROM mysql.column_stat;
...@@ -201,9 +185,9 @@ DELETE FROM mysql.index_stat; ...@@ -201,9 +185,9 @@ DELETE FROM mysql.index_stat;
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS ALL INDEXES ALL; ANALYZE TABLE t1 PERSISTENT FOR COLUMNS ALL INDEXES ALL;
SELECT * FROM table_stat; SELECT * FROM mysql.table_stat;
SELECT * FROM column_stat; SELECT * FROM mysql.column_stat;
SELECT * FROM index_stat; SELECT * FROM mysql.index_stat;
CREATE TABLE t2 LIKE t1; CREATE TABLE t2 LIKE t1;
...@@ -212,9 +196,9 @@ INSERT INTO t2 SELECT * FROM t1; ...@@ -212,9 +196,9 @@ INSERT INTO t2 SELECT * FROM t1;
ANALYZE TABLE t2; ANALYZE TABLE t2;
SELECT * FROM table_stat; SELECT * FROM mysql.table_stat;
SELECT * FROM column_stat ORDER BY column_name; SELECT * FROM mysql.column_stat ORDER BY column_name;
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;
DELETE FROM mysql.table_stat; DELETE FROM mysql.table_stat;
...@@ -231,8 +215,8 @@ ALTER TABLE t1 ...@@ -231,8 +215,8 @@ ALTER TABLE t1
ANALYZE TABLE t1; ANALYZE TABLE t1;
SELECT * FROM column_stat; SELECT * FROM mysql.column_stat;
SELECT * FROM index_stat; SELECT * FROM mysql.index_stat;
DROP TABLE t1,t2; DROP TABLE t1,t2;
...@@ -265,13 +249,13 @@ ANALYZE TABLE Country, City, CountryLanguage; ...@@ -265,13 +249,13 @@ ANALYZE TABLE Country, City, CountryLanguage;
--enable_result_log --enable_result_log
SELECT UPPER(db_name), UPPER(table_name), cardinality SELECT UPPER(db_name), UPPER(table_name), cardinality
FROM test.table_stat; FROM mysql.table_stat;
SELECT UPPER(db_name), UPPER(table_name), SELECT UPPER(db_name), UPPER(table_name),
column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency 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), SELECT UPPER(db_name), UPPER(table_name),
index_name, prefix_arity, avg_frequency index_name, prefix_arity, avg_frequency
FROM test.index_stat; FROM mysql.index_stat;
use test; use test;
...@@ -302,13 +286,13 @@ ANALYZE TABLE Country, City, CountryLanguage; ...@@ -302,13 +286,13 @@ ANALYZE TABLE Country, City, CountryLanguage;
--enable_result_log --enable_result_log
SELECT UPPER(db_name), UPPER(table_name), cardinality SELECT UPPER(db_name), UPPER(table_name), cardinality
FROM test.table_stat; FROM mysql.table_stat;
SELECT UPPER(db_name), UPPER(table_name), SELECT UPPER(db_name), UPPER(table_name),
column_name, min_value, max_value, nulls_ratio, avg_length, avg_frequency 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), SELECT UPPER(db_name), UPPER(table_name),
index_name, prefix_arity, avg_frequency index_name, prefix_arity, avg_frequency
FROM test.index_stat; FROM mysql.index_stat;
use test; use test;
...@@ -319,10 +303,6 @@ DELETE FROM mysql.table_stat; ...@@ -319,10 +303,6 @@ DELETE FROM mysql.table_stat;
DELETE FROM mysql.column_stat; DELETE FROM mysql.column_stat;
DELETE FROM mysql.index_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; set use_stat_tables=@save_use_stat_tables;
\ No newline at end of file
...@@ -485,6 +485,6 @@ set @had_proxies_priv_table= @@warning_count != 0; ...@@ -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 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';
...@@ -219,6 +219,10 @@ public: ...@@ -219,6 +219,10 @@ public:
/* Statistical data on a column */ /* Statistical data on a column */
class Column_statistics 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: public:
/* /*
Bitmap indicating what statistical characteristics Bitmap indicating what statistical characteristics
...@@ -230,23 +234,54 @@ public: ...@@ -230,23 +234,54 @@ public:
Field *min_value; Field *min_value;
/* Maximum value for the column */ /* Maximum value for the column */
Field *max_value; 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 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 Average number of bytes occupied by the representation of a
value of the column in memory buffers such as join buffer. value of the column in memory buffers such as join buffer
CHAR values are stripped of trailing spaces. multiplied by the scale factor Scale_factor_avg_length
CHAR values are stripped of trailing spaces
Flexible values are stripped of their length prefixes. 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 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);
}
}; };
/* /*
......
...@@ -14595,8 +14595,8 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, ...@@ -14595,8 +14595,8 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
keyinfo->ext_key_parts= keyinfo->key_parts; keyinfo->ext_key_parts= keyinfo->key_parts;
keyinfo->key_length=0; keyinfo->key_length=0;
keyinfo->rec_per_key=NULL; keyinfo->rec_per_key=NULL;
keyinfo->read_stat.avg_frequency= NULL; keyinfo->read_stat.init_avg_frequency(NULL);
keyinfo->write_stat.avg_frequency= NULL; keyinfo->write_stat.init_avg_frequency(NULL);
keyinfo->algorithm= HA_KEY_ALG_UNDEF; keyinfo->algorithm= HA_KEY_ALG_UNDEF;
keyinfo->is_statistics_from_stat_tables= FALSE; keyinfo->is_statistics_from_stat_tables= FALSE;
keyinfo->name= (char*) "group_key"; keyinfo->name= (char*) "group_key";
...@@ -14713,7 +14713,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, ...@@ -14713,7 +14713,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
keyinfo->algorithm= HA_KEY_ALG_UNDEF; keyinfo->algorithm= HA_KEY_ALG_UNDEF;
keyinfo->is_statistics_from_stat_tables= FALSE; keyinfo->is_statistics_from_stat_tables= FALSE;
keyinfo->rec_per_key=0; 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 Create an extra field to hold NULL bits so that unique indexes on
......
...@@ -600,13 +600,13 @@ public: ...@@ -600,13 +600,13 @@ public:
} }
break; break;
case COLUMN_STAT_NULLS_RATIO: 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; break;
case COLUMN_STAT_AVG_LENGTH: 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; break;
case COLUMN_STAT_AVG_FREQUENCY: 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; break;
} }
} }
...@@ -665,13 +665,13 @@ public: ...@@ -665,13 +665,13 @@ public:
&my_charset_utf8_bin); &my_charset_utf8_bin);
break; break;
case COLUMN_STAT_NULLS_RATIO: 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; break;
case COLUMN_STAT_AVG_LENGTH: 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; break;
case COLUMN_STAT_AVG_FREQUENCY: 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; break;
} }
} }
...@@ -766,7 +766,7 @@ public: ...@@ -766,7 +766,7 @@ public:
{ {
Field *stat_field= stat_table->field[INDEX_STAT_AVG_FREQUENCY]; Field *stat_field= stat_table->field[INDEX_STAT_AVG_FREQUENCY];
double 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) if (avg_frequency == 0)
stat_field->set_null(); stat_field->set_null();
else else
...@@ -798,9 +798,9 @@ public: ...@@ -798,9 +798,9 @@ public:
{ {
Field *stat_field= stat_table->field[INDEX_STAT_AVG_FREQUENCY]; Field *stat_field= stat_table->field[INDEX_STAT_AVG_FREQUENCY];
if (!stat_field->is_null()) 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: ...@@ -1065,9 +1065,9 @@ public:
{ {
if (i < prefixes) if (i < prefixes)
{ {
index_info->write_stat.avg_frequency[i]= double val= state->prefix_count == 0 ?
state->prefix_count == 0 ? 0 : 0 : (double) state->entry_count / state->prefix_count;
(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) ...@@ -1354,17 +1354,19 @@ int collect_statistics_for_table(THD *thd, TABLE *table)
for (field_ptr= table->field; *field_ptr; field_ptr++) for (field_ptr= table->field; *field_ptr; field_ptr++)
{ {
double val;
table_field= *field_ptr; table_field= *field_ptr;
if (!bitmap_is_set(table->read_set, table_field->field_index)) if (!bitmap_is_set(table->read_set, table_field->field_index))
continue; continue;
table_field->write_stat.nulls_ratio= (double) table_field->nulls/rows; val= (double) table_field->nulls / rows;
table_field->write_stat.avg_length= table_field->write_stat.set_nulls_ratio(val);
(double) table_field->column_total_length / (rows-table_field->nulls); val= (double) table_field->column_total_length / (rows-table_field->nulls);
table_field->write_stat.set_avg_length(val);
if (table_field->count_distinct) if (table_field->count_distinct)
{ {
table_field->write_stat.avg_frequency= val= (double) (rows-table_field->nulls) /
(double) (rows-table_field->nulls) / table_field->count_distinct->get_value();
table_field->count_distinct->get_value(); table_field->write_stat.set_avg_frequency(val);
set_not_null_for_write_column_stat_value(table_field, set_not_null_for_write_column_stat_value(table_field,
COLUMN_STAT_AVG_FREQUENCY); COLUMN_STAT_AVG_FREQUENCY);
delete table_field->count_distinct; delete table_field->count_distinct;
...@@ -1585,38 +1587,37 @@ int read_statistics_for_table(THD *thd, TABLE *table) ...@@ -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; key_part_map ext_key_part_map= key_info->ext_key_part_map;
if (key_info->key_parts != key_info->ext_key_parts && 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; KEY *pk_key_info= table->key_info + table->s->primary_key;
uint k= key_info->key_parts; uint k= key_info->key_parts;
uint pk_parts= pk_key_info->key_parts; uint pk_parts= pk_key_info->key_parts;
ha_rows n_rows= table->read_stat.cardinality; ha_rows n_rows= table->read_stat.cardinality;
double k_dist= n_rows / key_info->read_stat.avg_frequency[k-1]; double k_dist= n_rows / key_info->read_stat.get_avg_frequency(k-1);
double *k_avg_freq_ptr= key_info->read_stat.avg_frequency + k;
uint m= 0; uint m= 0;
for (uint j= 0; j < pk_parts; j++) for (uint j= 0; j < pk_parts; j++)
{ {
if (!(ext_key_part_map & 1 << 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); 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 else
{ {
key_info->read_stat.avg_frequency[k + m]= double avg_frequency= pk_key_info->read_stat.get_avg_frequency(j);
pk_key_info->read_stat.avg_frequency[j]; key_info->read_stat.set_avg_frequency(k + m, avg_frequency);
m++; 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 || if (avg_frequency == 0 ||
table->read_stat.cardinality_is_null) table->read_stat.cardinality_is_null)
avg_frequency= 1; avg_frequency= 1;
...@@ -1625,7 +1626,7 @@ int read_statistics_for_table(THD *thd, TABLE *table) ...@@ -1625,7 +1626,7 @@ int read_statistics_for_table(THD *thd, TABLE *table)
avg_frequency/= k_dist; avg_frequency/= k_dist;
set_if_bigger(avg_frequency, 1); 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) ...@@ -1662,7 +1663,8 @@ void set_statistics_for_table(THD *thd, TABLE *table)
key_info < key_info_end; key_info++) key_info < key_info_end; key_info++)
{ {
key_info->is_statistics_from_stat_tables= key_info->is_statistics_from_stat_tables=
(use_stat_table_mode > 1 && key_info->read_stat.avg_frequency && (use_stat_table_mode > 1 &&
key_info->read_stat.avg_frequency[0] > 0.5); key_info->read_stat.avg_frequency_is_set() &&
key_info->read_stat.get_avg_frequency(0) > 0.5);
} }
} }
...@@ -124,14 +124,28 @@ typedef struct st_key { ...@@ -124,14 +124,28 @@ typedef struct st_key {
/* Statistical data on an index prefixes */ /* Statistical data on an index prefixes */
class Index_statistics 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 where N is the number of index entries without nulls
in the first k components, and D is the number of distinct in the first k components, and D is the number of distinct
k-component prefixes among them 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 { ...@@ -159,8 +173,7 @@ typedef struct st_key {
if (rec_per_key == 0) if (rec_per_key == 0)
return 0; return 0;
return (is_statistics_from_stat_tables ? return (is_statistics_from_stat_tables ?
(ulong) (100 * read_stat.avg_frequency[i]) / (double) 100 : read_stat.get_avg_frequency(i) : (double) rec_per_key[i]);
(double) rec_per_key[i]);
} }
} KEY; } KEY;
......
...@@ -762,8 +762,8 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, ...@@ -762,8 +762,8 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
ulong pos, record_offset; ulong pos, record_offset;
ulong *rec_per_key= NULL; ulong *rec_per_key= NULL;
ulong rec_buff_length; ulong rec_buff_length;
double *read_avg_frequency= NULL; ulong *read_avg_frequency= NULL;
double *write_avg_frequency= NULL; ulong *write_avg_frequency= NULL;
handler *handler_file= 0; handler *handler_file= 0;
KEY *keyinfo; KEY *keyinfo;
KEY_PART_INFO *key_part= NULL; KEY_PART_INFO *key_part= NULL;
...@@ -946,13 +946,13 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, ...@@ -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, if (!(rec_per_key= (ulong*) alloc_root(&share->mem_root,
sizeof(ulong) * ext_key_parts))) sizeof(ulong) * ext_key_parts)))
goto err; goto err;
if (!(read_avg_frequency= (double*) alloc_root(&share->mem_root, if (!(read_avg_frequency= (ulong*) alloc_root(&share->mem_root,
sizeof(double) * sizeof(double) *
ext_key_parts))) ext_key_parts)))
goto err; goto err;
if (!(write_avg_frequency= (double*) alloc_root(&share->mem_root, if (!(write_avg_frequency= (ulong*) alloc_root(&share->mem_root,
sizeof(double) * sizeof(double) *
ext_key_parts))) ext_key_parts)))
goto err; goto err;
first_key_part= key_part; first_key_part= key_part;
first_key_parts= first_keyinfo.key_parts; first_key_parts= first_keyinfo.key_parts;
...@@ -966,8 +966,8 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, ...@@ -966,8 +966,8 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
keyinfo->key_part= key_part; keyinfo->key_part= key_part;
keyinfo->rec_per_key= rec_per_key; keyinfo->rec_per_key= rec_per_key;
keyinfo->read_stat.avg_frequency= read_avg_frequency; keyinfo->read_stat.init_avg_frequency(read_avg_frequency);
keyinfo->write_stat.avg_frequency= write_avg_frequency; keyinfo->write_stat.init_avg_frequency(write_avg_frequency);
for (j=keyinfo->key_parts ; j-- ; key_part++) for (j=keyinfo->key_parts ; j-- ; key_part++)
{ {
*rec_per_key++=0; *rec_per_key++=0;
...@@ -5957,7 +5957,7 @@ bool TABLE::add_tmp_key(uint key, uint key_parts, ...@@ -5957,7 +5957,7 @@ bool TABLE::add_tmp_key(uint key, uint key_parts,
if (!keyinfo->rec_per_key) if (!keyinfo->rec_per_key)
return TRUE; return TRUE;
bzero(keyinfo->rec_per_key, sizeof(ulong)*key_parts); 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++) for (i= 0; i < key_parts; i++)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment