polardbxengine/mysql-test/suite/xengine/t/statistics.test

82 lines
2.6 KiB
Plaintext

--source suite/xengine/include/have_xengine.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
--enable_warnings
# table with index in default CF
create table t1(
id bigint not null primary key auto_increment,
a varchar(255) not null,
b bigint,
index t1_1(b)
) engine=xengine;
# a table with index in a different CF
create table t2(
id bigint not null primary key auto_increment,
a varchar(255) not null,
b bigint,
index t2_1(b) comment 'cf_t3'
) engine=xengine;
# a table wint index in a reverse CF
create table t3(
id bigint not null primary key auto_increment,
a varchar(255) not null,
b bigint,
index t3_1(b) comment 'rev:cf_t4'
) engine=xengine;
--disable_query_log
let $i=0;
while ($i<10000)
{
inc $i;
eval insert t1(a,b) values(concat('a',$i,'b',$i,'c',$i), $i);
if ($i<3000)
{
eval insert t2(a,b) values(concat('a',$i,'b',$i,'c',$i), $i);
eval insert t3(a,b) values(concat('a',$i,'b',$i,'c',$i), $i);
}
}
--enable_query_log
set information_schema_stats_expiry=1;
--exec sleep 2
# should have some statistics before the memtable flush
--replace_column 2 1000
SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE() and table_name <> 't1';
# due to inconsistencies in when the memtable is flushed, just verify t1 has fewer
# than the expected number of rows.
SELECT CASE WHEN table_rows < 10000 then 'true' else 'false' end from information_schema.tables where table_name = 't1';
# flush and get even better statistics
set global xengine_force_flush_memtable_now = true;
--exec sleep 2
SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE();
SELECT table_name, data_length>0, index_length>0 FROM information_schema.tables WHERE table_schema = DATABASE();
# restart the server, check the stats
--source include/restart_mysqld.inc
# give the server a chance to load in statistics
--exec sleep 5
SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE();
SELECT table_name, data_length>0, index_length>0 FROM information_schema.tables WHERE table_schema = DATABASE();
analyze table t1,t2,t3,t4,t5;
# make sure that stats do not change after calling analyze table
SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE();
SELECT table_name, data_length>0, index_length>0 FROM information_schema.tables WHERE table_schema = DATABASE();
drop table t1, t2, t3;
--source suite/xengine/include/check_xengine_log_error.inc