1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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.
This commit is contained in:
Igor Babaev
2012-06-25 22:33:07 -07:00
parent f549f495f7
commit 4ff6fd34da
12 changed files with 339 additions and 325 deletions

View File

@ -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';