mirror of
https://github.com/MariaDB/server.git
synced 2025-05-28 13:01:41 +03:00
engine-independent statistics. If a table was created for InnoDB then the execution of the ANALYZE command over this table blocked any INSERT/DELETE/UPDATE of the table.
204 lines
5.3 KiB
Plaintext
204 lines
5.3 KiB
Plaintext
--source include/have_stat_tables.inc
|
|
--source include/have_debug_sync.inc
|
|
--source include/not_embedded.inc
|
|
|
|
set @save_use_stat_tables=@@use_stat_tables;
|
|
|
|
set use_stat_tables='preferably';
|
|
|
|
--disable_warnings
|
|
DROP DATABASE IF EXISTS dbt3_s001;
|
|
--enable_warnings
|
|
|
|
CREATE DATABASE dbt3_s001;
|
|
|
|
use dbt3_s001;
|
|
|
|
set @save_optimizer_switch=@@optimizer_switch;
|
|
set optimizer_switch='extended_keys=off';
|
|
|
|
--disable_query_log
|
|
--disable_result_log
|
|
--disable_warnings
|
|
--source include/dbt3_s001.inc
|
|
delete from mysql.table_stats;
|
|
delete from mysql.column_stats;
|
|
delete from mysql.index_stats;
|
|
ANALYZE TABLE
|
|
customer, lineitem, nation, orders, part, partsupp, region, supplier;
|
|
--enable_warnings
|
|
--enable_result_log
|
|
--enable_query_log
|
|
|
|
select * from mysql.table_stats;
|
|
select * from mysql.index_stats;
|
|
|
|
|
|
#
|
|
# 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;
|
|
set debug_sync='RESET';
|
|
|
|
#
|
|
# 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_stats where table_name='lineitem' order by index_name;
|
|
delete from mysql.index_stats
|
|
where table_name='lineitem' and
|
|
index_name in ('i_l_shipdate', 'i_l_receiptdate');
|
|
select * from mysql.index_stats 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_stats where table_name='lineitem' order by index_name;
|
|
delete from mysql.index_stats
|
|
where table_name='lineitem' and index_name= 'i_l_shipdate';
|
|
select * from mysql.index_stats 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;
|
|
set debug_sync='RESET';
|
|
|
|
select * from mysql.index_stats where table_name='lineitem' order by index_name;
|
|
|
|
#
|
|
# Test for parallel statistics collection and update (innodb)
|
|
#
|
|
|
|
select * from mysql.index_stats where table_name='lineitem'
|
|
order by index_name, prefix_arity;
|
|
set debug_sync='RESET';
|
|
|
|
let $innodb_storage_engine= 0;
|
|
if (`SELECT UPPER(@@storage_engine) = 'INNODB'`)
|
|
{
|
|
let $innodb_storage_engine= 1;
|
|
}
|
|
|
|
connect (con1, localhost, root,,);
|
|
connect (con2, localhost, root,,);
|
|
|
|
connection con1;
|
|
set debug_sync='statistics_collection_start SIGNAL parked WAIT_FOR finish';
|
|
use dbt3_s001;
|
|
set use_stat_tables='preferably';
|
|
--send analyze table lineitem persistent for all
|
|
|
|
connection con2;
|
|
set debug_sync='now WAIT_FOR parked';
|
|
use dbt3_s001;
|
|
set use_stat_tables='never';
|
|
if ($innodb_storage_engine)
|
|
{
|
|
select * from lineitem where l_orderkey=1 and l_partkey=156;
|
|
delete from lineitem where l_orderkey=1 and l_partkey=156;
|
|
select * from lineitem where l_orderkey=1 and l_partkey=156;
|
|
}
|
|
set debug_sync='now SIGNAL finish';
|
|
|
|
connection con1;
|
|
--disable_result_log
|
|
--disable_warnings
|
|
--reap
|
|
--enable_warnings
|
|
--enable_result_log
|
|
|
|
connection default;
|
|
disconnect con1;
|
|
disconnect con2;
|
|
set debug_sync='RESET';
|
|
|
|
select * from mysql.index_stats where table_name='lineitem'
|
|
order by index_name, prefix_arity;
|
|
|
|
DROP DATABASE dbt3_s001;
|
|
|
|
use test;
|
|
|
|
set use_stat_tables=@save_use_stat_tables;
|