You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mysql-test/suite/innodb/t/innodb_defragment_fill_factor.test
+93-49Lines changed: 93 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -11,10 +11,10 @@ DROP TABLE if exists t2;
11
11
12
12
--echo Testing tables with large records
13
13
# Create table.
14
-
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), KEY SECOND(a, b)) ENGINE=INNODB;
14
+
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), c VARCHAR(256), KEY SECOND(a, b,c)) ENGINE=INNODB;
15
15
16
16
# Populate table.
17
-
INSERT INTO t1 VALUES (1, REPEAT('A', 256));
17
+
INSERT INTO t1 VALUES (1, REPEAT('A', 256), REPEAT('B', 256));
18
18
INSERT INTO t1 (b) SELECT b from t1;
19
19
INSERT INTO t1 (b) SELECT b from t1;
20
20
INSERT INTO t1 (b) SELECT b from t1;
@@ -36,28 +36,24 @@ while ($size)
36
36
}
37
37
--enable_query_log
38
38
39
+
--source include/wait_innodb_all_purged.inc
39
40
--source include/restart_mysqld.inc
40
41
optimize table t1;
41
-
select sleep(1);
42
42
43
-
--source include/restart_mysqld.inc
44
43
select count(*) from t1;
45
44
46
-
# After deletion & defragmentation, there are 800 records left. Each page can hold about 57 records. We fill the page 90% full,
47
-
# so there should be less than 16 pages total.
48
45
--let $primary_before = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY', Value, 1)
49
46
50
47
select count(*) from t1 force index (second);
51
48
52
-
# secondary index is slightly bigger than primary index so the number of pages should be similar.
53
49
--let $second_before = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second', Value, 1)
54
50
55
51
--echo # A few more insertions on the page should not cause a page split.
56
-
insert into t1 values (81, REPEAT('A', 256));
57
-
insert into t1 values (83, REPEAT('A', 256));
58
-
insert into t1 values (87, REPEAT('A', 256));
59
-
insert into t1 values (82, REPEAT('A', 256));
60
-
insert into t1 values (86, REPEAT('A', 256));
52
+
insert into t1 values (81, REPEAT('A', 256), REPEAT('B', 256));
53
+
insert into t1 values (83, REPEAT('A', 256), REPEAT('B', 256));
54
+
insert into t1 values (87, REPEAT('A', 256), REPEAT('B', 256));
55
+
insert into t1 values (82, REPEAT('A', 256), REPEAT('B', 256));
56
+
insert into t1 values (86, REPEAT('A', 256), REPEAT('B', 256));
61
57
--let $primary_after = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY', Value, 1)
62
58
--let $second_after = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second', Value, 1)
63
59
@@ -69,28 +65,52 @@ if ($second_before != $second_after) {
69
65
--echo Insertion caused page split on second, which should be avoided by innodb_defragment_fill_factor.
70
66
}
71
67
72
-
--echo # More insertions will cause page splits
73
-
insert into t1 values (88, REPEAT('A', 256));
74
-
insert into t1 values (85, REPEAT('A', 256));
75
-
insert into t1 values (84, REPEAT('A', 256));
68
+
--echo # Insert more rows to cause a page split
69
+
insert into t1 values (180, REPEAT('A', 256), REPEAT('B', 256));
70
+
insert into t1 values (181, REPEAT('A', 256), REPEAT('B', 256));
71
+
insert into t1 values (182, REPEAT('A', 256), REPEAT('B', 256));
72
+
insert into t1 values (183, REPEAT('A', 256), REPEAT('B', 256));
73
+
insert into t1 values (184, REPEAT('A', 256), REPEAT('B', 256));
74
+
insert into t1 values (185, REPEAT('A', 256), REPEAT('B', 256));
75
+
insert into t1 values (186, REPEAT('A', 256), REPEAT('B', 256));
76
+
insert into t1 values (187, REPEAT('A', 256), REPEAT('B', 256));
77
+
insert into t1 values (188, REPEAT('A', 256), REPEAT('B', 256));
78
+
insert into t1 values (189, REPEAT('A', 256), REPEAT('B', 256));
79
+
insert into t1 values (190, REPEAT('A', 256), REPEAT('B', 256));
80
+
insert into t1 values (191, REPEAT('A', 256), REPEAT('B', 256));
81
+
insert into t1 values (192, REPEAT('A', 256), REPEAT('B', 256));
82
+
insert into t1 values (193, REPEAT('A', 256), REPEAT('B', 256));
83
+
insert into t1 values (194, REPEAT('A', 256), REPEAT('B', 256));
84
+
insert into t1 values (195, REPEAT('A', 256), REPEAT('B', 256));
85
+
insert into t1 values (196, REPEAT('A', 256), REPEAT('B', 256));
86
+
insert into t1 values (197, REPEAT('A', 256), REPEAT('B', 256));
87
+
insert into t1 values (198, REPEAT('A', 256), REPEAT('B', 256));
88
+
insert into t1 values (199, REPEAT('A', 256), REPEAT('B', 256));
89
+
insert into t1 values (200, REPEAT('A', 256), REPEAT('B', 256));
90
+
insert into t1 values (201, REPEAT('A', 256), REPEAT('B', 256));
91
+
insert into t1 values (202, REPEAT('A', 256), REPEAT('B', 256));
92
+
insert into t1 values (203, REPEAT('A', 256), REPEAT('B', 256));
93
+
insert into t1 values (204, REPEAT('A', 256), REPEAT('B', 256));
94
+
76
95
--let $primary_after = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY', Value, 1)
96
+
77
97
--let $second_after = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second', Value, 1)
78
98
79
99
if ($primary_before == $primary_after) {
80
-
--echo Too much space are reserved on primary index.
100
+
--echo Too little space is reserved on primary index.
81
101
}
82
102
83
103
if ($second_before == $second_after) {
84
-
--echo Too much space are reserved on second index.
104
+
--echo Too little space is reserved on second index.
85
105
}
86
106
87
107
DROP TABLE t1;
88
108
89
109
--echo Testing table with small records
90
-
CREATE TABLE t2 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARchar(16), KEY SECOND(a,b)) ENGINE=INNODB;
110
+
CREATE TABLE t2 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(16), c VARCHAR(32), KEY SECOND(a,b,c)) ENGINE=INNODB;
91
111
# Populate table.
92
112
--disable_query_log
93
-
INSERT INTO t2 VALUES (1, REPEAT('A', 16));
113
+
INSERT INTO t2 VALUES (1, REPEAT('A', 16), REPEAT('B', 32));
94
114
INSERT INTO t2 (b) SELECT b from t2;
95
115
INSERT INTO t2 (b) SELECT b from t2;
96
116
INSERT INTO t2 (b) SELECT b from t2;
@@ -115,52 +135,76 @@ while ($size)
115
135
}
116
136
--enable_query_log
117
137
138
+
--source include/wait_innodb_all_purged.inc
118
139
--source include/restart_mysqld.inc
119
140
optimize table t2;
120
-
select sleep(1);
121
141
122
-
--source include/restart_mysqld.inc
142
+
select count(*) from t2;
123
143
select count(*) from t2 force index(second);
124
144
125
145
--let $second_before = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t2%' and index_name = 'second', Value, 1)
126
146
127
147
--echo The page should have room for about 20 insertions
128
-
insert into t2 values(1181, REPEAT('A', 16));
129
-
insert into t2 values(1191, REPEAT('A', 16));
130
-
insert into t2 values(1182, REPEAT('A', 16));
131
-
insert into t2 values(1192, REPEAT('A', 16));
132
-
insert into t2 values(1183, REPEAT('A', 16));
133
-
insert into t2 values(1193, REPEAT('A', 16));
134
-
insert into t2 values(1184, REPEAT('A', 16));
135
-
insert into t2 values(1194, REPEAT('A', 16));
136
-
insert into t2 values(1185, REPEAT('A', 16));
137
-
insert into t2 values(1195, REPEAT('A', 16));
138
-
insert into t2 values(1186, REPEAT('A', 16));
139
-
insert into t2 values(1196, REPEAT('A', 16));
140
-
insert into t2 values(1187, REPEAT('A', 16));
141
-
insert into t2 values(1197, REPEAT('A', 16));
142
-
insert into t2 values(1188, REPEAT('A', 16));
143
-
insert into t2 values(1198, REPEAT('A', 16));
144
-
insert into t2 values(1189, REPEAT('A', 16));
145
-
insert into t2 values(1199, REPEAT('A', 16));
146
-
insert into t2 values(1190, REPEAT('A', 16));
147
-
insert into t2 values(1180, REPEAT('A', 16));
148
+
insert into t2 values(1181, REPEAT('A', 16), REPEAT('B',32));
149
+
insert into t2 values(1191, REPEAT('A', 16), REPEAT('B',32));
150
+
insert into t2 values(1182, REPEAT('A', 16), REPEAT('B',32));
151
+
insert into t2 values(1192, REPEAT('A', 16), REPEAT('B',32));
152
+
insert into t2 values(1183, REPEAT('A', 16), REPEAT('B',32));
153
+
insert into t2 values(1193, REPEAT('A', 16), REPEAT('B',32));
154
+
insert into t2 values(1184, REPEAT('A', 16), REPEAT('B',32));
155
+
insert into t2 values(1194, REPEAT('A', 16), REPEAT('B',32));
156
+
insert into t2 values(1185, REPEAT('A', 16), REPEAT('B',32));
157
+
insert into t2 values(1195, REPEAT('A', 16), REPEAT('B',32));
158
+
insert into t2 values(1186, REPEAT('A', 16), REPEAT('B',32));
159
+
insert into t2 values(1196, REPEAT('A', 16), REPEAT('B',32));
160
+
insert into t2 values(1187, REPEAT('A', 16), REPEAT('B',32));
161
+
insert into t2 values(1197, REPEAT('A', 16), REPEAT('B',32));
162
+
insert into t2 values(1188, REPEAT('A', 16), REPEAT('B',32));
163
+
insert into t2 values(1198, REPEAT('A', 16), REPEAT('B',32));
164
+
insert into t2 values(1189, REPEAT('A', 16), REPEAT('B',32));
165
+
insert into t2 values(1199, REPEAT('A', 16), REPEAT('B',32));
166
+
insert into t2 values(1190, REPEAT('A', 16), REPEAT('B',32));
167
+
insert into t2 values(1180, REPEAT('A', 16), REPEAT('B',32));
148
168
149
169
--let $second_after = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t2%' and index_name = 'second', Value, 1)
150
170
151
171
if ($second_before != $second_after) {
152
172
--echo Insertion caused page split on second, which should be avoided by innodb_defragment_fill_factor.
153
173
}
154
174
155
-
--echo More insertions will cause page split.
156
-
insert into t2 values(1280, REPEAT('A', 16));
157
-
insert into t2 values(1290, REPEAT('A', 16));
158
-
insert into t2 values(1281, REPEAT('A', 16));
159
-
insert into t2 values(1291, REPEAT('A', 16));
175
+
--echo # Insert more rows to cause a page split
176
+
insert into t2 values (180, REPEAT('A', 16), REPEAT('B', 32));
177
+
insert into t2 values (181, REPEAT('A', 16), REPEAT('B', 32));
178
+
insert into t2 values (182, REPEAT('A', 16), REPEAT('B', 32));
179
+
insert into t2 values (183, REPEAT('A', 16), REPEAT('B', 32));
180
+
insert into t2 values (184, REPEAT('A', 16), REPEAT('B', 32));
181
+
insert into t2 values (185, REPEAT('A', 16), REPEAT('B', 32));
182
+
insert into t2 values (186, REPEAT('A', 16), REPEAT('B', 32));
183
+
insert into t2 values (187, REPEAT('A', 16), REPEAT('B', 32));
184
+
insert into t2 values (188, REPEAT('A', 16), REPEAT('B', 32));
185
+
insert into t2 values (189, REPEAT('A', 16), REPEAT('B', 32));
186
+
insert into t2 values (190, REPEAT('A', 16), REPEAT('B', 32));
187
+
insert into t2 values (191, REPEAT('A', 16), REPEAT('B', 32));
188
+
insert into t2 values (192, REPEAT('A', 16), REPEAT('B', 32));
189
+
insert into t2 values (193, REPEAT('A', 16), REPEAT('B', 32));
190
+
insert into t2 values (194, REPEAT('A', 16), REPEAT('B', 32));
191
+
insert into t2 values (195, REPEAT('A', 16), REPEAT('B', 32));
192
+
insert into t2 values (196, REPEAT('A', 16), REPEAT('B', 32));
193
+
insert into t2 values (197, REPEAT('A', 16), REPEAT('B', 32));
194
+
insert into t2 values (198, REPEAT('A', 16), REPEAT('B', 32));
195
+
insert into t2 values (199, REPEAT('A', 16), REPEAT('B', 32));
196
+
insert into t2 values (200, REPEAT('A', 16), REPEAT('B', 32));
197
+
insert into t2 values (201, REPEAT('A', 16), REPEAT('B', 32));
198
+
insert into t2 values (202, REPEAT('A', 16), REPEAT('B', 32));
199
+
insert into t2 values (203, REPEAT('A', 16), REPEAT('B', 32));
200
+
insert into t2 values (204, REPEAT('A', 16), REPEAT('B', 32));
160
201
161
202
--let $second_after = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t2%' and index_name = 'second', Value, 1)
203
+
162
204
if ($second_before == $second_after) {
163
-
--echo Too much space are reserved on second index.
205
+
--echo Too little space is reserved on second index.
0 commit comments