Debian Codegraph @

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

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