1SET DEFAULT_STORAGE_ENGINE='tokudb'; 2DROP TABLE IF EXISTS t1; 3set tokudb_prelock_empty=off; 4create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes)engine=tokudb; 5show create table t1; 6Table Create Table 7t1 CREATE TABLE `t1` ( 8 `a` int(11) NOT NULL, 9 `b` int(11) DEFAULT NULL, 10 `c` int(11) DEFAULT NULL, 11 `d` int(11) DEFAULT NULL, 12 PRIMARY KEY (`a`), 13 KEY `b` (`b`) `clustering`=yes 14) ENGINE=TokuDB DEFAULT CHARSET=latin1 15create index foo on t1(c,d) clustering=yes; 16show create table t1; 17Table Create Table 18t1 CREATE TABLE `t1` ( 19 `a` int(11) NOT NULL, 20 `b` int(11) DEFAULT NULL, 21 `c` int(11) DEFAULT NULL, 22 `d` int(11) DEFAULT NULL, 23 PRIMARY KEY (`a`), 24 KEY `b` (`b`) `clustering`=yes, 25 KEY `foo` (`c`,`d`) `clustering`=yes 26) ENGINE=TokuDB DEFAULT CHARSET=latin1 27alter table t1 drop primary key; 28alter table t1 add primary key (a,b,c,d); 29alter table t1 add key bar(d,c,b,a) clustering=yes; 30show create table t1; 31Table Create Table 32t1 CREATE TABLE `t1` ( 33 `a` int(11) NOT NULL, 34 `b` int(11) NOT NULL, 35 `c` int(11) NOT NULL, 36 `d` int(11) NOT NULL, 37 PRIMARY KEY (`a`,`b`,`c`,`d`), 38 KEY `b` (`b`) `clustering`=yes, 39 KEY `foo` (`c`,`d`) `clustering`=yes, 40 KEY `bar` (`d`,`c`,`b`,`a`) `clustering`=yes 41) ENGINE=TokuDB DEFAULT CHARSET=latin1 42insert into t1 value (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(32,54,12,56); 43explain select * from t1; 44id select_type table type possible_keys key key_len ref rows Extra 451 SIMPLE t1 index NULL PRIMARY 16 NULL 5 Using index 46select * from t1; 47a b c d 481 1 1 1 492 2 2 2 503 3 3 3 514 4 4 4 5232 54 12 56 53explain select d from t1 where d > 30; 54id select_type table type possible_keys key key_len ref rows Extra 551 SIMPLE t1 range bar bar 4 NULL 1 Using where; Using index 56select * from t1 where d > 30; 57a b c d 5832 54 12 56 59drop table t1; 60