diff options
author | Igor Babaev <igor@askmonty.org> | 2012-07-26 17:50:08 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2012-07-26 17:50:08 -0700 |
commit | 8c499274da21af6226785d51dd24968bf2b1befe (patch) | |
tree | bfd5380bc3c0967fde27ec8966054767ef9cbc67 /mysql-test | |
parent | cb0a5c84b63a24d143160e38995cb35268f8eef4 (diff) | |
download | mariadb-git-8c499274da21af6226785d51dd24968bf2b1befe.tar.gz |
Performed re-factoring and re-structuring of the code for mwl#248:
- Moved the definitions of the classes to store data from persistent
statistical tables into statistics.h, leaving in other internal
data structures only references to the corresponding objects.
- Defined class Column_statistics_collected derived from the class
Column_statistics. This is a helper class to collect statistics
on columns.
- Moved references to read statistics to TABLE SHARE, leaving the
the reference to the collected statistics in TABLE.
- Added a new clone method for the class Field allowing to clone
fields attached to table shares. It was was used to create
fields for min/max values in the memory of the table share.
A lso:
- Added procedures to allocate memory for statistical data in
the table share memory and in table memory.
Also:
- Added a test case demonstrating how ANALYZE could work in parallel
to collect statistics on different indexes of the same table.
- Added a test two demonstrate how two connections working
simultaneously could allocate memory for statistical data in the
table share memory.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/stat_tables.result | 116 | ||||
-rw-r--r-- | mysql-test/r/stat_tables_innodb.result | 172 | ||||
-rw-r--r-- | mysql-test/t/stat_tables.test | 109 |
3 files changed, 397 insertions, 0 deletions
diff --git a/mysql-test/r/stat_tables.result b/mysql-test/r/stat_tables.result index 26f2b602c6b..09486d4ce0b 100644 --- a/mysql-test/r/stat_tables.result +++ b/mysql-test/r/stat_tables.result @@ -334,6 +334,122 @@ and o_orderkey=l_orderkey and p_partkey=l_partkey; o_orderkey p_partkey 5895 200 set optimizer_switch=@save_optimizer_switch; +flush table lineitem; +set use_stat_tables='never'; +select sum(l_extendedprice*l_discount) as revenue +from lineitem +where l_shipdate >= date '1994-01-01' +and l_shipdate < date '1994-01-01' + interval '1' year +and l_discount between 0.06 - 0.01 and 0.06 + 0.01 +and l_quantity < 24; +revenue +77949.91860000002 +set debug_sync='statistics_mem_alloc_start1 WAIT_FOR second_thread_started_too'; +set debug_sync='statistics_mem_alloc_start2 SIGNAL first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +select sum(l_extendedprice*l_discount) as revenue +from lineitem +where l_shipdate >= date '1994-01-01' +and l_shipdate < date '1994-01-01' + interval '1' year +and l_discount between 0.06 - 0.01 and 0.06 + 0.01 +and l_quantity < 24 ; +set debug_sync='statistics_mem_alloc_start1 SIGNAL second_thread_started_too'; +set debug_sync='statistics_mem_alloc_start2 WAIT_FOR first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +select sum(l_extendedprice*l_discount) as revenue +from lineitem +where l_shipdate >= date '1994-01-01' +and l_shipdate < date '1994-01-01' + interval '1' year +and l_discount between 0.06 - 0.01 and 0.06 + 0.01 +and l_quantity < 24; +revenue +77949.91860000002 +revenue +77949.91860000002 +set use_stat_tables='preferably'; +select * from mysql.index_stat where table_name='lineitem' order by index_name; +db_name table_name index_name prefix_arity avg_frequency +dbt3_s001 lineitem PRIMARY 1 4.0033 +dbt3_s001 lineitem PRIMARY 2 1.0000 +dbt3_s001 lineitem i_l_commitdate 1 2.7160 +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_partkey 1 30.0250 +dbt3_s001 lineitem i_l_receiptdate 1 2.6477 +dbt3_s001 lineitem i_l_shipdate 1 2.6500 +dbt3_s001 lineitem i_l_suppkey 1 600.5000 +dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250 +dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786 +delete from mysql.index_stat +where table_name='lineitem' and +index_name in ('i_l_shipdate', 'i_l_receiptdate'); +select * from mysql.index_stat where table_name='lineitem' order by index_name; +db_name table_name index_name prefix_arity avg_frequency +dbt3_s001 lineitem PRIMARY 1 4.0033 +dbt3_s001 lineitem PRIMARY 2 1.0000 +dbt3_s001 lineitem i_l_commitdate 1 2.7160 +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_partkey 1 30.0250 +dbt3_s001 lineitem i_l_suppkey 1 600.5000 +dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786 +dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250 +analyze table lineitem persistent for columns() indexes (i_l_shipdate); +select * from mysql.index_stat where table_name='lineitem' order by index_name; +db_name table_name index_name prefix_arity avg_frequency +dbt3_s001 lineitem PRIMARY 1 4.0033 +dbt3_s001 lineitem PRIMARY 2 1.0000 +dbt3_s001 lineitem i_l_commitdate 1 2.7160 +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_partkey 1 30.0250 +dbt3_s001 lineitem i_l_shipdate 1 2.6500 +dbt3_s001 lineitem i_l_suppkey 1 600.5000 +dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786 +dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250 +delete from mysql.index_stat +where table_name='lineitem' and index_name= 'i_l_shipdate'; +select * from mysql.index_stat where table_name='lineitem' order by index_name; +db_name table_name index_name prefix_arity avg_frequency +dbt3_s001 lineitem PRIMARY 1 4.0033 +dbt3_s001 lineitem PRIMARY 2 1.0000 +dbt3_s001 lineitem i_l_commitdate 1 2.7160 +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_partkey 1 30.0250 +dbt3_s001 lineitem i_l_suppkey 1 600.5000 +dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786 +dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250 +set debug_sync='statistics_collection_start1 WAIT_FOR second_thread_started_too'; +set debug_sync='statistics_collection_start2 SIGNAL first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +analyze table lineitem persistent for columns() indexes (i_l_shipdate); +set debug_sync='statistics_collection_start1 SIGNAL second_thread_started_too'; +set debug_sync='statistics_collection_start2 WAIT_FOR first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +analyze table lineitem persistent for columns() indexes (i_l_receiptdate); +select * from mysql.index_stat where table_name='lineitem' order by index_name; +db_name table_name index_name prefix_arity avg_frequency +dbt3_s001 lineitem PRIMARY 1 4.0033 +dbt3_s001 lineitem PRIMARY 2 1.0000 +dbt3_s001 lineitem i_l_commitdate 1 2.7160 +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_partkey 1 30.0250 +dbt3_s001 lineitem i_l_receiptdate 1 2.6477 +dbt3_s001 lineitem i_l_shipdate 1 2.6500 +dbt3_s001 lineitem i_l_suppkey 1 600.5000 +dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250 +dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786 DROP DATABASE dbt3_s001; use test; set use_stat_tables=@save_use_stat_tables; diff --git a/mysql-test/r/stat_tables_innodb.result b/mysql-test/r/stat_tables_innodb.result index 3d534dcab29..4cb1261b689 100644 --- a/mysql-test/r/stat_tables_innodb.result +++ b/mysql-test/r/stat_tables_innodb.result @@ -361,6 +361,178 @@ and o_orderkey=l_orderkey and p_partkey=l_partkey; o_orderkey p_partkey 5895 200 set optimizer_switch=@save_optimizer_switch; +flush table lineitem; +set use_stat_tables='never'; +select sum(l_extendedprice*l_discount) as revenue +from lineitem +where l_shipdate >= date '1994-01-01' +and l_shipdate < date '1994-01-01' + interval '1' year +and l_discount between 0.06 - 0.01 and 0.06 + 0.01 +and l_quantity < 24; +revenue +77949.91860000002 +set debug_sync='statistics_mem_alloc_start1 WAIT_FOR second_thread_started_too'; +set debug_sync='statistics_mem_alloc_start2 SIGNAL first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +select sum(l_extendedprice*l_discount) as revenue +from lineitem +where l_shipdate >= date '1994-01-01' +and l_shipdate < date '1994-01-01' + interval '1' year +and l_discount between 0.06 - 0.01 and 0.06 + 0.01 +and l_quantity < 24 ; +set debug_sync='statistics_mem_alloc_start1 SIGNAL second_thread_started_too'; +set debug_sync='statistics_mem_alloc_start2 WAIT_FOR first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +select sum(l_extendedprice*l_discount) as revenue +from lineitem +where l_shipdate >= date '1994-01-01' +and l_shipdate < date '1994-01-01' + interval '1' year +and l_discount between 0.06 - 0.01 and 0.06 + 0.01 +and l_quantity < 24; +revenue +77949.91860000002 +revenue +77949.91860000002 +set use_stat_tables='preferably'; +select * from mysql.index_stat where table_name='lineitem' order by index_name; +db_name table_name index_name prefix_arity avg_frequency +dbt3_s001 lineitem PRIMARY 1 4.0033 +dbt3_s001 lineitem PRIMARY 2 1.0000 +dbt3_s001 lineitem i_l_commitdate 2 1.0364 +dbt3_s001 lineitem i_l_commitdate 1 2.7160 +dbt3_s001 lineitem i_l_commitdate 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_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_receiptdate 3 1.0000 +dbt3_s001 lineitem i_l_receiptdate 2 1.0152 +dbt3_s001 lineitem i_l_receiptdate 1 2.6477 +dbt3_s001 lineitem i_l_shipdate 1 2.6500 +dbt3_s001 lineitem i_l_shipdate 3 1.0000 +dbt3_s001 lineitem i_l_shipdate 2 1.0149 +dbt3_s001 lineitem i_l_suppkey 2 1.2073 +dbt3_s001 lineitem i_l_suppkey 3 1.0000 +dbt3_s001 lineitem i_l_suppkey 1 600.5000 +dbt3_s001 lineitem i_l_suppkey_partkey 4 1.0000 +dbt3_s001 lineitem i_l_suppkey_partkey 3 1.0030 +dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786 +dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250 +delete from mysql.index_stat +where table_name='lineitem' and +index_name in ('i_l_shipdate', 'i_l_receiptdate'); +select * from mysql.index_stat where table_name='lineitem' order by index_name; +db_name table_name index_name prefix_arity avg_frequency +dbt3_s001 lineitem PRIMARY 1 4.0033 +dbt3_s001 lineitem PRIMARY 2 1.0000 +dbt3_s001 lineitem i_l_commitdate 2 1.0364 +dbt3_s001 lineitem i_l_commitdate 1 2.7160 +dbt3_s001 lineitem i_l_commitdate 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 3 1.0000 +dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404 +dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033 +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 2 1.2073 +dbt3_s001 lineitem i_l_suppkey 3 1.0000 +dbt3_s001 lineitem i_l_suppkey 1 600.5000 +dbt3_s001 lineitem i_l_suppkey_partkey 3 1.0030 +dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786 +dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250 +dbt3_s001 lineitem i_l_suppkey_partkey 4 1.0000 +analyze table lineitem persistent for columns() indexes (i_l_shipdate); +select * from mysql.index_stat where table_name='lineitem' order by index_name; +db_name table_name index_name prefix_arity avg_frequency +dbt3_s001 lineitem PRIMARY 1 4.0033 +dbt3_s001 lineitem PRIMARY 2 1.0000 +dbt3_s001 lineitem i_l_commitdate 2 1.0364 +dbt3_s001 lineitem i_l_commitdate 1 2.7160 +dbt3_s001 lineitem i_l_commitdate 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_partkey 3 1.0000 +dbt3_s001 lineitem i_l_partkey 2 1.0089 +dbt3_s001 lineitem i_l_partkey 1 30.0250 +dbt3_s001 lineitem i_l_shipdate 3 1.0000 +dbt3_s001 lineitem i_l_shipdate 2 1.0149 +dbt3_s001 lineitem i_l_shipdate 1 2.6500 +dbt3_s001 lineitem i_l_suppkey 3 1.0000 +dbt3_s001 lineitem i_l_suppkey 2 1.2073 +dbt3_s001 lineitem i_l_suppkey 1 600.5000 +dbt3_s001 lineitem i_l_suppkey_partkey 3 1.0030 +dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786 +dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250 +dbt3_s001 lineitem i_l_suppkey_partkey 4 1.0000 +delete from mysql.index_stat +where table_name='lineitem' and index_name= 'i_l_shipdate'; +select * from mysql.index_stat where table_name='lineitem' order by index_name; +db_name table_name index_name prefix_arity avg_frequency +dbt3_s001 lineitem PRIMARY 1 4.0033 +dbt3_s001 lineitem PRIMARY 2 1.0000 +dbt3_s001 lineitem i_l_commitdate 2 1.0364 +dbt3_s001 lineitem i_l_commitdate 1 2.7160 +dbt3_s001 lineitem i_l_commitdate 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 3 1.0000 +dbt3_s001 lineitem i_l_orderkey_quantity 2 1.0404 +dbt3_s001 lineitem i_l_orderkey_quantity 1 4.0033 +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 2 1.2073 +dbt3_s001 lineitem i_l_suppkey 3 1.0000 +dbt3_s001 lineitem i_l_suppkey 1 600.5000 +dbt3_s001 lineitem i_l_suppkey_partkey 3 1.0030 +dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786 +dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250 +dbt3_s001 lineitem i_l_suppkey_partkey 4 1.0000 +set debug_sync='statistics_collection_start1 WAIT_FOR second_thread_started_too'; +set debug_sync='statistics_collection_start2 SIGNAL first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +analyze table lineitem persistent for columns() indexes (i_l_shipdate); +set debug_sync='statistics_collection_start1 SIGNAL second_thread_started_too'; +set debug_sync='statistics_collection_start2 WAIT_FOR first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +analyze table lineitem persistent for columns() indexes (i_l_receiptdate); +select * from mysql.index_stat where table_name='lineitem' order by index_name; +db_name table_name index_name prefix_arity avg_frequency +dbt3_s001 lineitem PRIMARY 1 4.0033 +dbt3_s001 lineitem PRIMARY 2 1.0000 +dbt3_s001 lineitem i_l_commitdate 2 1.0364 +dbt3_s001 lineitem i_l_commitdate 1 2.7160 +dbt3_s001 lineitem i_l_commitdate 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_partkey 3 1.0000 +dbt3_s001 lineitem i_l_partkey 2 1.0089 +dbt3_s001 lineitem i_l_partkey 1 30.0250 +dbt3_s001 lineitem i_l_receiptdate 1 2.6477 +dbt3_s001 lineitem i_l_shipdate 1 2.6500 +dbt3_s001 lineitem i_l_suppkey 3 1.0000 +dbt3_s001 lineitem i_l_suppkey 2 1.2073 +dbt3_s001 lineitem i_l_suppkey 1 600.5000 +dbt3_s001 lineitem i_l_suppkey_partkey 3 1.0030 +dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786 +dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250 +dbt3_s001 lineitem i_l_suppkey_partkey 4 1.0000 DROP DATABASE dbt3_s001; use test; set use_stat_tables=@save_use_stat_tables; diff --git a/mysql-test/t/stat_tables.test b/mysql-test/t/stat_tables.test index 640f9febc75..bdb689228b2 100644 --- a/mysql-test/t/stat_tables.test +++ b/mysql-test/t/stat_tables.test @@ -144,6 +144,115 @@ eval $QQ1; set optimizer_switch=@save_optimizer_switch; +# +# Test for parallel memory allocation for statistical data +# +# assumes that start the code of memory allocation for stats data has this line: +# +# DEBUG_SYNC(thd, "statistics_mem_alloc_start1"); +# DEBUG_SYNC(thd, "statistics_mem_alloc-start2"); +# + +let $Q6= +select sum(l_extendedprice*l_discount) as revenue +from lineitem +where l_shipdate >= date '1994-01-01' + and l_shipdate < date '1994-01-01' + interval '1' year + and l_discount between 0.06 - 0.01 and 0.06 + 0.01 + and l_quantity < 24; + +flush table lineitem; +set use_stat_tables='never'; +eval $Q6; + +connect (con1, localhost, root,,); +connect (con2, localhost, root,,); + +connection con1; +set debug_sync='statistics_mem_alloc_start1 WAIT_FOR second_thread_started_too'; +set debug_sync='statistics_mem_alloc_start2 SIGNAL first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +--send_eval $Q6 + +connection con2; +set debug_sync='statistics_mem_alloc_start1 SIGNAL second_thread_started_too'; +set debug_sync='statistics_mem_alloc_start2 WAIT_FOR first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +--send_eval $Q6 + +connection con1; +--reap + +connection con2; +--reap + +connection default; +set use_stat_tables='preferably'; +disconnect con1; +disconnect con2; + +# +# Test for parallel statistics collection +# +# assumes that start of stats collection code has this line: +# +# DEBUG_SYNC(thd, "statistics_collection_start1"); +# DEBUG_SYNC(thd, "statistics_collection_start2"); +# + +select * from mysql.index_stat where table_name='lineitem' order by index_name; +delete from mysql.index_stat + where table_name='lineitem' and + index_name in ('i_l_shipdate', 'i_l_receiptdate'); +select * from mysql.index_stat where table_name='lineitem' order by index_name; +--disable_result_log +--disable_warnings +analyze table lineitem persistent for columns() indexes (i_l_shipdate); +--enable_warnings +--enable_result_log +select * from mysql.index_stat where table_name='lineitem' order by index_name; +delete from mysql.index_stat + where table_name='lineitem' and index_name= 'i_l_shipdate'; +select * from mysql.index_stat where table_name='lineitem' order by index_name; + +connect (con1, localhost, root,,); +connect (con2, localhost, root,,); + +connection con1; +set debug_sync='statistics_collection_start1 WAIT_FOR second_thread_started_too'; +set debug_sync='statistics_collection_start2 SIGNAL first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +--send analyze table lineitem persistent for columns() indexes (i_l_shipdate) + +connection con2; +set debug_sync='statistics_collection_start1 SIGNAL second_thread_started_too'; +set debug_sync='statistics_collection_start2 WAIT_FOR first_thread_working'; +use dbt3_s001; +set use_stat_tables='preferably'; +--send analyze table lineitem persistent for columns() indexes (i_l_receiptdate) + +connection con1; +--disable_result_log +--disable_warnings +--reap +--enable_warnings +--enable_result_log + +connection con2; +--disable_result_log +--disable_warnings +--reap +--enable_warnings +--enable_result_log + +connection default; +disconnect con1; +disconnect con2; + +select * from mysql.index_stat where table_name='lineitem' order by index_name; DROP DATABASE dbt3_s001; |