Debian Codegraph @

mysql-test/suite/innodb/t/innodb_stats_auto_recalc.test

raw
1 #
2 # Test the persistent stats auto recalc
3 #
4
5 -- source include/have_innodb.inc
6 # Page numbers printed by this test depend on the page size
7 -- source include/have_innodb_16k.inc
8
9 -- vertical_results
10
11 -- let $check_stats1 = SELECT n_rows, clustered_index_size FROM mysql.innodb_table_stats WHERE table_name = 'autorecalc'
12 -- let $check_stats2 = SELECT index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name = 'autorecalc'
13
14 CREATE TABLE autorecalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
15
16 # the CREATE should have inserted zeroed stats
17 -- eval $check_stats1
18 -- eval $check_stats2
19
20 INSERT INTO autorecalc VALUES (1);
21 INSERT INTO autorecalc VALUES (2);
22
23 # wait for the bg stats thread to update the stats, notice we wait on
24 # innodb_index_stats because innodb_table_stats gets updated first and
25 # it is possible that (if we wait on innodb_table_stats) the wait cond
26 # gets satisfied before innodb_index_stats is updated
27 let $wait_condition = SELECT stat_value = 2 FROM mysql.innodb_index_stats WHERE table_name = 'autorecalc' AND index_name = 'PRIMARY' AND stat_name = 'n_diff_pfx01';
28 -- source include/wait_condition.inc
29
30 # the second INSERT from above should have triggered an auto-recalc
31 -- eval $check_stats1
32 -- eval $check_stats2
33
34 # now DELETE the rows and trigger a second auto-recalc, InnoDB may wait a
35 # few seconds before triggering an auto-recalc again (it tries not to be too
36 # aggressive)
37
38 DELETE FROM autorecalc;
39
40 let $wait_timeout = 25;
41 let $wait_condition = SELECT stat_value = 0 FROM mysql.innodb_index_stats WHERE table_name = 'autorecalc' AND index_name = 'PRIMARY' AND stat_name = 'n_diff_pfx01';
42 -- source include/wait_condition.inc
43
44 # the DELETE from above should have triggered an auto-recalc
45 -- eval $check_stats1
46 -- eval $check_stats2
47
48 DROP TABLE autorecalc;