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