27
alter table t1 add c int DEFAULT 42 not null, add key using HASH (c,a);
27
alter table t1 add c int not null, add key using HASH (c,a);
29
29
create temporary table t1 (a int not null,b int not null, primary key using HASH (a)) engine=MEMORY comment="testing heaps";
30
30
insert into t1 values(1,1),(2,2),(3,3),(4,4);
160
160
1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where
161
161
select * from t1 where btn like "q%";
163
alter table t1 add column new_col char(1) default "Y" not null, add key using HASH (btn,new_col), drop key btn;
163
alter table t1 add column new_col char(1) not null, add key using HASH (btn,new_col), drop key btn;
164
164
update t1 set new_col=left(btn,1);
165
165
explain select * from t1 where btn="a";
166
166
id select_type table type possible_keys key key_len ref rows Extra
290
290
insert into t2 select * from t1;
291
291
explain select * from t1 where name='matt';
292
292
id select_type table type possible_keys key key_len ref rows Extra
293
1 SIMPLE t1 ref heap_idx,btree_idx heap_idx 82 const 2 Using where
293
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 82 const 1 Using where
294
294
explain select * from t2 where name='matt';
295
295
id select_type table type possible_keys key key_len ref rows Extra
296
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 82 const 2 Using where
296
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 82 const 1 Using where
297
297
explain select * from t1 where name='Lilu';
298
298
id select_type table type possible_keys key key_len ref rows Extra
299
1 SIMPLE t1 ref heap_idx,btree_idx heap_idx 82 const 2 Using where
299
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 82 const 1 Using where
300
300
explain select * from t2 where name='Lilu';
301
301
id select_type table type possible_keys key key_len ref rows Extra
302
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 82 const 2 Using where
302
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 82 const 1 Using where
303
303
explain select * from t1 where name='Phil';
304
304
id select_type table type possible_keys key key_len ref rows Extra
305
1 SIMPLE t1 ref heap_idx,btree_idx heap_idx 82 const 2 Using where
305
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 82 const 1 Using where
306
306
explain select * from t2 where name='Phil';
307
307
id select_type table type possible_keys key key_len ref rows Extra
308
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 82 const 2 Using where
308
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 82 const 1 Using where
309
309
explain select * from t1 where name='Lilu';
310
310
id select_type table type possible_keys key key_len ref rows Extra
311
1 SIMPLE t1 ref heap_idx,btree_idx heap_idx 82 const 2 Using where
311
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 82 const 1 Using where
312
312
explain select * from t2 where name='Lilu';
313
313
id select_type table type possible_keys key key_len ref rows Extra
314
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 82 const 2 Using where
314
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 82 const 1 Using where
315
315
insert into t1 (name) select name from t2;
316
316
insert into t1 (name) select name from t2;
317
317
insert into t1 (name) select name from t2;
327
327
1 SIMPLE t1 ref heap_idx heap_idx 82 const 9 Using where
328
328
show index from t1;
329
329
Table Unique Key_name Seq_in_index Column_name
331
t1 NO heap_idx 1 name
332
t1 NO btree_idx 1 name
331
t1 FALSE heap_idx 1 name
332
t1 FALSE btree_idx 1 name
333
333
show index from t1;
334
334
Table Unique Key_name Seq_in_index Column_name
336
t1 NO heap_idx 1 name
337
t1 NO btree_idx 1 name
336
t1 FALSE heap_idx 1 name
337
t1 FALSE btree_idx 1 name
338
338
create temporary table t3
340
340
a varchar(20) not null,
344
344
insert into t3 select name, name from t1;
345
345
show index from t3;
346
346
Table Unique Key_name Seq_in_index Column_name
349
349
show index from t3;
350
350
Table Unique Key_name Seq_in_index Column_name
353
353
explain select * from t1 ignore key(btree_idx), t3 where t1.name='matt' and t3.a = concat('',t1.name) and t3.b=t1.name;
354
354
id select_type table type possible_keys key key_len ref rows Extra
355
355
1 SIMPLE t1 ref heap_idx heap_idx 82 const 9 Using where