Debian Codegraph @

mysql-test/suite/innodb/include/innodb_merge_threshold_secondary.inc

raw
1 #
2 # Test to cause merge of the pages (at secondary index by deleting)
3 # test/tab1 should be created already
4 # The definition is intended to be based on
5 # "create table tab1 (a bigint primary key, b blob) engine=InnoDB row_format=dynamic;"
6 # "create index index1 on tab1(b(750));"
7 #
8
9 # turn on flags
10 --disable_query_log
11 SET GLOBAL innodb_monitor_enable=index_page_merge_attempts;
12 SET GLOBAL innodb_monitor_reset=index_page_merge_attempts;
13 SET GLOBAL innodb_monitor_enable=index_page_merge_successful;
14 SET GLOBAL innodb_monitor_reset=index_page_merge_successful;
15 --enable_query_log
16
17 --echo # check MERGE_THRESHOLD
18 select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD
19 from INFORMATION_SCHEMA.INNODB_SYS_TABLES t, INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
20 where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%';
21
22 INSERT INTO tab1 VALUES (1, concat("01", repeat('a',8190)));
23 INSERT INTO tab1 VALUES (2, concat("02", repeat('a',8190)));
24 INSERT INTO tab1 VALUES (3, concat("03", repeat('a',8190)));
25 INSERT INTO tab1 VALUES (4, concat("04", repeat('a',8190)));
26 INSERT INTO tab1 VALUES (5, concat("05", repeat('a',8190)));
27 INSERT INTO tab1 VALUES (6, concat("06", repeat('a',8190)));
28 INSERT INTO tab1 VALUES (7, concat("07", repeat('a',8190)));
29 INSERT INTO tab1 VALUES (8, concat("08", repeat('a',8190)));
30 INSERT INTO tab1 VALUES (9, concat("09", repeat('a',8190)));
31 INSERT INTO tab1 VALUES (10, concat("10", repeat('a',8190)));
32
33 INSERT INTO tab1 VALUES (22, concat("22", repeat('a',8190)));
34 INSERT INTO tab1 VALUES (23, concat("23", repeat('a',8190)));
35 INSERT INTO tab1 VALUES (24, concat("24", repeat('a',8190)));
36 INSERT INTO tab1 VALUES (25, concat("25", repeat('a',8190)));
37 INSERT INTO tab1 VALUES (26, concat("26", repeat('a',8190)));
38 INSERT INTO tab1 VALUES (27, concat("27", repeat('a',8190)));
39 INSERT INTO tab1 VALUES (28, concat("28", repeat('a',8190)));
40 INSERT INTO tab1 VALUES (29, concat("29", repeat('a',8190)));
41 INSERT INTO tab1 VALUES (30, concat("30", repeat('a',8190)));
42 INSERT INTO tab1 VALUES (31, concat("31", repeat('a',8190)));
43 INSERT INTO tab1 VALUES (32, concat("32", repeat('a',8190)));
44 INSERT INTO tab1 VALUES (33, concat("33", repeat('a',8190)));
45
46 INSERT INTO tab1 VALUES (11, concat("11", repeat('a',8190)));
47 INSERT INTO tab1 VALUES (12, concat("12", repeat('a',8190)));
48 INSERT INTO tab1 VALUES (13, concat("13", repeat('a',8190)));
49 INSERT INTO tab1 VALUES (14, concat("14", repeat('a',8190)));
50 INSERT INTO tab1 VALUES (15, concat("15", repeat('a',8190)));
51 INSERT INTO tab1 VALUES (16, concat("16", repeat('a',8190)));
52 INSERT INTO tab1 VALUES (17, concat("17", repeat('a',8190)));
53 INSERT INTO tab1 VALUES (18, concat("18", repeat('a',8190)));
54 INSERT INTO tab1 VALUES (19, concat("19", repeat('a',8190)));
55 INSERT INTO tab1 VALUES (20, concat("20", repeat('a',8190)));
56 INSERT INTO tab1 VALUES (21, concat("21", repeat('a',8190)));
57
58 INSERT INTO tab1 VALUES (34, concat("34", repeat('a',8190)));
59 INSERT INTO tab1 VALUES (35, concat("35", repeat('a',8190)));
60 INSERT INTO tab1 VALUES (36, concat("36", repeat('a',8190)));
61 INSERT INTO tab1 VALUES (37, concat("37", repeat('a',8190)));
62 INSERT INTO tab1 VALUES (38, concat("38", repeat('a',8190)));
63 INSERT INTO tab1 VALUES (39, concat("39", repeat('a',8190)));
64 INSERT INTO tab1 VALUES (40, concat("40", repeat('a',8190)));
65 INSERT INTO tab1 VALUES (41, concat("41", repeat('a',8190)));
66 INSERT INTO tab1 VALUES (42, concat("42", repeat('a',8190)));
67
68 # clustered index is still root page only with the 42 records.
69 # secondary index is filled 2 leaf pages have been prepared
70 # | 1,..,21 | 22,..,42 |
71
72 select PAGE_NUMBER, NUMBER_RECORDS
73 from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
74 INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
75 where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
76 and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
77
78 begin;
79 delete from tab1 where a = 33;
80 delete from tab1 where a = 34;
81 delete from tab1 where a = 35;
82 delete from tab1 where a = 36;
83 delete from tab1 where a = 37;
84 delete from tab1 where a = 38;
85 delete from tab1 where a = 39;
86 delete from tab1 where a = 40;
87 delete from tab1 where a = 41;
88 delete from tab1 where a = 42;
89 delete from tab1 where a = 12;
90 delete from tab1 where a = 13;
91 delete from tab1 where a = 14;
92 delete from tab1 where a = 15;
93 delete from tab1 where a = 16;
94 delete from tab1 where a = 17;
95 delete from tab1 where a = 18;
96 delete from tab1 where a = 19;
97 delete from tab1 where a = 20;
98 delete from tab1 where a = 21;
99 commit;
100
101 # wait for purge view progress (records are deleted actually by purge)
102 --source include/wait_all_purged.inc
103
104 # secondary index is not merged yet
105 # | 1,..,11 | 22,..,32 |
106
107 --echo # check page merge happens (nothing is expected)
108 SELECT name,count_reset FROM information_schema.innodb_metrics
109 WHERE name like 'index_page_merge_%';
110
111 select PAGE_NUMBER, NUMBER_RECORDS
112 from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES s1,
113 INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2
114 where s1.SPACE = s2.SPACE AND NAME like 'test/tab1%'
115 and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS;
116
117
118 delete from tab1 where a = 32;
119 # wait for purge view progress (records are deleted actually by purge)
120 --source include/wait_all_purged.inc
121
122 --echo # check page merge happens (MERGE_THRESHOLD=50 causes merge here)
123 SELECT name,count_reset FROM information_schema.innodb_metrics
124 WHERE name like 'index_page_merge_%';
125
126
127 delete from tab1 where a = 31;
128 # wait for purge view progress (records are deleted actually by purge)
129 --source include/wait_all_purged.inc
130
131 --echo # check page merge happens (MERGE_THRESHOLD=45 causes merge here)
132 SELECT name,count_reset FROM information_schema.innodb_metrics
133 WHERE name like 'index_page_merge_%';
134
135
136 delete from tab1 where a = 30;
137 # wait for purge view progress (records are deleted actually by purge)
138 --source include/wait_all_purged.inc
139
140 --echo # check page merge happens (MERGE_THRESHOLD=40 causes merge here)
141 SELECT name,count_reset FROM information_schema.innodb_metrics
142 WHERE name like 'index_page_merge_%';
143
144 --disable_query_log
145 # Reset flags
146 SET GLOBAL innodb_monitor_disable=index_page_merge_attempts;
147 SET GLOBAL innodb_monitor_disable=index_page_merge_successful;
148
149 --disable_warnings
150 set global innodb_monitor_enable = default;
151 set global innodb_monitor_disable = default;
152 set global innodb_monitor_reset = default;
153 set global innodb_monitor_reset_all = default;
154 --enable_warnings
155 --enable_query_log