Debian Codegraph @

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

raw
1 #
2 # Test that the table option STATS_SAMPLE_PAGES=N|default is indeed
3 # used by InnoDB
4 #
5
6 -- source include/have_innodb.inc
7 # Page numbers printed by this test depend on the page size
8 -- source include/have_innodb_16k.inc
9
10 SET GLOBAL innodb_stats_persistent_sample_pages=17;
11
12 CREATE TABLE test_ps_sample_pages_used (
13 a VARCHAR(512), PRIMARY KEY (a)
14 ) ENGINE=INNODB STATS_SAMPLE_PAGES=default;
15
16 # Insert enough records into the table so that it has more than 2*17+1 pages
17 # If we ask to scan more than the half of the leaf pages, then the sampling
18 # will do full scan and we cannot check whether the sample_pages variable was
19 # honored.
20 BEGIN;
21 -- disable_query_log
22 let $i=999;
23 while ($i) {
24 eval INSERT INTO test_ps_sample_pages_used VALUES (REPEAT(1000+$i, 128));
25 dec $i;
26 }
27 -- enable_query_log
28 COMMIT;
29
30 ANALYZE TABLE test_ps_sample_pages_used;
31
32 # confirm the big number of leaf pages in the index
33 SELECT stat_name, stat_value FROM mysql.innodb_index_stats
34 WHERE table_name='test_ps_sample_pages_used' AND stat_name='n_leaf_pages';
35
36 # confirm that 17 pages were sampled, that is - the global
37 # innodb_stats_persistent_sample_pages is used when the table option
38 # STATS_SAMPLE_PAGES is set to 'default'.
39 SELECT sample_size FROM mysql.innodb_index_stats
40 WHERE table_name='test_ps_sample_pages_used' AND stat_name='n_diff_pfx01';
41
42 ALTER TABLE test_ps_sample_pages_used STATS_SAMPLE_PAGES=14;
43
44 ANALYZE TABLE test_ps_sample_pages_used;
45
46 # confirm that 14 pages were sampled, that is - the table option
47 # STATS_SAMPLE_PAGES is used when it is set.
48 SELECT sample_size FROM mysql.innodb_index_stats
49 WHERE table_name='test_ps_sample_pages_used' AND stat_name='n_diff_pfx01';
50
51 DROP TABLE test_ps_sample_pages_used;
52
53 SET GLOBAL innodb_stats_persistent_sample_pages=default;