1
drop table if exists t1, t2, t3;
2
SET @save_key_buffer=@@key_buffer_size;
3
SELECT @@key_buffer_size, @@small.key_buffer_size;
4
@@key_buffer_size @@small.key_buffer_size
6
SET @@global.key_buffer_size=16*1024*1024;
7
SET @@global.default.key_buffer_size=16*1024*1024;
8
SET @@global.default.key_buffer_size=16*1024*1024;
9
SET @@global.small.key_buffer_size=1*1024*1024;
10
SET @@global.medium.key_buffer_size=4*1024*1024;
11
SET @@global.medium.key_buffer_size=0;
12
SET @@global.medium.key_buffer_size=0;
13
SHOW VARIABLES like "key_buffer_size";
15
key_buffer_size 16777216
16
SELECT @@key_buffer_size;
19
SELECT @@global.key_buffer_size;
20
@@global.key_buffer_size
22
SELECT @@global.default.key_buffer_size;
23
@@global.default.key_buffer_size
25
SELECT @@global.default.`key_buffer_size`;
26
@@global.default.`key_buffer_size`
28
SELECT @@global.`default`.`key_buffer_size`;
29
@@global.`default`.`key_buffer_size`
31
SELECT @@`default`.key_buffer_size;
32
@@`default`.key_buffer_size
34
SELECT @@small.key_buffer_size;
35
@@small.key_buffer_size
37
SELECT @@medium.key_buffer_size;
38
@@medium.key_buffer_size
40
SET @@global.key_buffer_size=@save_key_buffer;
41
SELECT @@default.key_buffer_size;
42
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'default.key_buffer_size' at line 1
43
SELECT @@skr.storage_engine="test";
44
ERROR HY000: Variable 'storage_engine' is not a variable component (can't be used as XXXX.variable_name)
45
select @@keycache1.key_cache_block_size;
46
@@keycache1.key_cache_block_size
48
select @@keycache1.key_buffer_size;
49
@@keycache1.key_buffer_size
51
set global keycache1.key_cache_block_size=2048;
52
select @@keycache1.key_buffer_size;
53
@@keycache1.key_buffer_size
55
select @@keycache1.key_cache_block_size;
56
@@keycache1.key_cache_block_size
58
set global keycache1.key_buffer_size=1*1024*1024;
59
select @@keycache1.key_buffer_size;
60
@@keycache1.key_buffer_size
62
select @@keycache1.key_cache_block_size;
63
@@keycache1.key_cache_block_size
65
set global keycache2.key_buffer_size=4*1024*1024;
66
select @@keycache2.key_buffer_size;
67
@@keycache2.key_buffer_size
69
select @@keycache2.key_cache_block_size;
70
@@keycache2.key_cache_block_size
72
set global keycache1.key_buffer_size=0;
73
select @@keycache1.key_buffer_size;
74
@@keycache1.key_buffer_size
76
select @@keycache1.key_cache_block_size;
77
@@keycache1.key_cache_block_size
79
select @@key_buffer_size;
82
select @@key_cache_block_size;
83
@@key_cache_block_size
85
set global keycache1.key_buffer_size=1024*1024;
86
create table t1 (p int primary key, a char(10)) delay_key_write=1;
87
create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a));
88
show status like 'key_blocks_used';
91
show status like 'key_blocks_unused';
93
Key_blocks_unused KEY_BLOCKS_UNUSED
94
insert into t1 values (1, 'qqqq'), (11, 'yyyy');
95
insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
96
(3, 1, 'yyyy'), (4, 3, 'zzzz');
107
update t1 set p=2 where p=1;
108
update t2 set i=2 where i=1;
109
show status like 'key_blocks_used';
112
show status like 'key_blocks_unused';
114
Key_blocks_unused KEY_BLOCKS_UNUSED
115
cache index t1 key (`primary`) in keycache1;
116
Table Op Msg_type Msg_text
117
test.t1 assign_to_keycache status OK
118
explain select p from t1;
119
id select_type table type possible_keys key key_len ref rows Extra
120
1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
125
explain select i from t2;
126
id select_type table type possible_keys key key_len ref rows Extra
127
1 SIMPLE t2 index NULL k1 5 NULL 4 Using index
134
explain select count(*) from t1, t2 where t1.p = t2.i;
135
id select_type table type possible_keys key key_len ref rows Extra
136
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using index
137
1 SIMPLE t2 ref k1 k1 5 test.t1.p 2 Using index
138
select count(*) from t1, t2 where t1.p = t2.i;
141
cache index t2 in keycache1;
142
Table Op Msg_type Msg_text
143
test.t2 assign_to_keycache status OK
144
update t2 set p=p+1000, i=2 where a='qqqq';
145
cache index t2 in keycache2;
146
Table Op Msg_type Msg_text
147
test.t2 assign_to_keycache status OK
148
insert into t2 values (2000, 3, 'yyyy');
149
cache index t2 in keycache1;
150
Table Op Msg_type Msg_text
151
test.t2 assign_to_keycache status OK
152
update t2 set p=3000 where a='zzzz';
160
explain select p from t2;
161
id select_type table type possible_keys key key_len ref rows Extra
162
1 SIMPLE t2 index NULL PRIMARY 4 NULL 5 Using index
170
explain select i from t2;
171
id select_type table type possible_keys key key_len ref rows Extra
172
1 SIMPLE t2 index NULL k1 5 NULL 5 Using index
180
explain select a from t2;
181
id select_type table type possible_keys key key_len ref rows Extra
182
1 SIMPLE t2 index NULL k2 11 NULL 5 Using index
190
cache index t1 in unknown_key_cache;
191
ERROR HY000: Unknown key cache 'unknown_key_cache'
192
cache index t1 key (unknown_key) in keycache1;
193
Table Op Msg_type Msg_text
194
test.t1 assign_to_keycache Error Key 'unknown_key' doesn't exist in table 't1'
195
test.t1 assign_to_keycache status Operation failed
196
select @@keycache2.key_buffer_size;
197
@@keycache2.key_buffer_size
199
select @@keycache2.key_cache_block_size;
200
@@keycache2.key_cache_block_size
202
set global keycache2.key_buffer_size=0;
203
select @@keycache2.key_buffer_size;
204
@@keycache2.key_buffer_size
206
select @@keycache2.key_cache_block_size;
207
@@keycache2.key_cache_block_size
209
set global keycache2.key_buffer_size=1024*1024;
210
select @@keycache2.key_buffer_size;
211
@@keycache2.key_buffer_size
213
update t2 set p=4000 where a='zzzz';
215
set global keycache1.key_buffer_size=0;
230
explain select i from t2;
231
id select_type table type possible_keys key key_len ref rows Extra
232
1 SIMPLE t2 index NULL k1 5 NULL 5 Using index
240
explain select a from t2;
241
id select_type table type possible_keys key key_len ref rows Extra
242
1 SIMPLE t2 index NULL k2 11 NULL 5 Using index
258
create table t3 (like t1);
259
cache index t3 in small;
260
Table Op Msg_type Msg_text
261
test.t3 assign_to_keycache status OK
262
insert into t3 select * from t1;
263
cache index t3 in keycache2;
264
Table Op Msg_type Msg_text
265
test.t3 assign_to_keycache status OK
266
cache index t1,t2 in default;
267
Table Op Msg_type Msg_text
268
test.t1 assign_to_keycache status OK
269
test.t2 assign_to_keycache status OK
271
show status like 'key_blocks_used';
274
show status like 'key_blocks_unused';
276
Key_blocks_unused KEY_BLOCKS_UNUSED
277
set global keycache2.key_buffer_size=0;
278
set global keycache3.key_buffer_size=100;
280
Warning 1292 Truncated incorrect key_buffer_size value: '100'
281
set global keycache3.key_buffer_size=0;
282
create table t1 (mytext text, FULLTEXT (mytext));
283
insert t1 values ('aaabbb');
285
Table Op Msg_type Msg_text
286
test.t1 check status OK
287
set @my_key_cache_block_size= @@global.key_cache_block_size;
288
set GLOBAL key_cache_block_size=2048;
290
Table Op Msg_type Msg_text
291
test.t1 check status OK
293
set global key_cache_block_size= @my_key_cache_block_size;
294
CREATE TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY);
295
SET @my_key_cache_block_size= @@global.key_cache_block_size;
296
SET GLOBAL key_cache_block_size=1536;
297
INSERT INTO t1 VALUES (1);
298
SELECT @@key_cache_block_size;
299
@@key_cache_block_size
302
Table Op Msg_type Msg_text
303
test.t1 check status OK
305
CREATE TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY, b int);
306
CREATE TABLE t2(a int NOT NULL AUTO_INCREMENT PRIMARY KEY, b int);
307
SET GLOBAL key_cache_block_size=1536;
308
INSERT INTO t1 VALUES (1,0);
309
INSERT INTO t2(b) SELECT b FROM t1;
310
INSERT INTO t1(b) SELECT b FROM t2;
311
INSERT INTO t2(b) SELECT b FROM t1;
312
INSERT INTO t1(b) SELECT b FROM t2;
313
INSERT INTO t2(b) SELECT b FROM t1;
314
INSERT INTO t1(b) SELECT b FROM t2;
315
INSERT INTO t2(b) SELECT b FROM t1;
316
INSERT INTO t1(b) SELECT b FROM t2;
317
INSERT INTO t2(b) SELECT b FROM t1;
318
INSERT INTO t1(b) SELECT b FROM t2;
319
INSERT INTO t2(b) SELECT b FROM t1;
320
INSERT INTO t1(b) SELECT b FROM t2;
321
INSERT INTO t2(b) SELECT b FROM t1;
322
INSERT INTO t1(b) SELECT b FROM t2;
323
INSERT INTO t2(b) SELECT b FROM t1;
324
INSERT INTO t1(b) SELECT b FROM t2;
325
INSERT INTO t2(b) SELECT b FROM t1;
326
INSERT INTO t1(b) SELECT b FROM t2;
327
SELECT COUNT(*) FROM t1;
330
SELECT @@key_cache_block_size;
331
@@key_cache_block_size
334
Table Op Msg_type Msg_text
335
test.t1 check status OK
337
set global key_cache_block_size= @my_key_cache_block_size;
338
set @@global.key_buffer_size=0;
340
Warning 1438 Cannot drop default keycache
341
select @@global.key_buffer_size;
342
@@global.key_buffer_size
344
SET @bug28478_key_cache_block_size= @@global.key_cache_block_size;
345
SET GLOBAL key_cache_block_size= 1536;
347
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
353
INSERT INTO t1 (c1, c2, c3) VALUES
354
('a', 'b', 'c'), ('b', 'c', 'd'), ('c', 'd', 'e'), ('d', 'e', 'f'),
355
('e', 'f', 'g'), ('f', 'g', 'h'), ('g', 'h', 'i'), ('h', 'i', 'j'),
356
('i', 'j', 'k'), ('j', 'k', 'l'), ('k', 'l', 'm'), ('l', 'm', 'n'),
357
('m', 'n', 'o'), ('n', 'o', 'p'), ('o', 'p', 'q'), ('p', 'q', 'r'),
358
('q', 'r', 's'), ('r', 's', 't'), ('s', 't', 'u'), ('t', 'u', 'v'),
359
('u', 'v', 'w'), ('v', 'w', 'x'), ('w', 'x', 'y'), ('x', 'y', 'z');
360
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1;
361
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1;
362
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1;
364
Table Op Msg_type Msg_text
365
test.t1 check status OK
366
SHOW VARIABLES LIKE 'key_cache_block_size';
368
key_cache_block_size 1536
369
SET GLOBAL key_cache_block_size= @bug28478_key_cache_block_size;