diff options
author | Igor Babaev <igor@askmonty.org> | 2012-06-25 22:33:07 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2012-06-25 22:33:07 -0700 |
commit | 4ff6fd34dae6315384d8c38ea69092cde09b78ba (patch) | |
tree | e5ec8fd533705ded464d84d40e1595d35b0ad5fc /mysql-test | |
parent | f549f495f7f621d2c7e35303ab84392ec519ecb0 (diff) | |
download | mariadb-git-4ff6fd34dae6315384d8c38ea69092cde09b78ba.tar.gz |
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.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/stat_tables.result | 126 | ||||
-rw-r--r-- | mysql-test/r/stat_tables_innodb.result | 174 | ||||
-rw-r--r-- | mysql-test/r/statistics.result | 80 | ||||
-rw-r--r-- | mysql-test/r/system_mysql_db.result | 8 | ||||
-rw-r--r-- | mysql-test/suite/funcs_1/r/is_columns_mysql.result | 18 | ||||
-rw-r--r-- | mysql-test/t/statistics.test | 84 |
6 files changed, 227 insertions, 263 deletions
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 |