SQL脚本
CREATE TABLE `test1` (
`id` int(11) NOT NULL,
`a` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
`b` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
`c` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
KEY `i1` (`a`,`b`,`c`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
测试sql:
desc select * from test1 where a='1' and b='1' and c='1'; //走索引
desc select * from test1 where a='1' and b='1'; //走索引
desc select * from test1 where a='1' and c='1'; //走索引
desc select * from test1 where b='1' and c='1'; //没走索引
实际测试结果:bc没有走索引
参考资料: