表结构为
CREATE TABLE `person` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`address` varchar(255) DEFAULT NULL,
`first_name` varchar(255) DEFAULT NULL,
`tel` varchar(255) DEFAULT NULL,
`job` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `name-address` (`name`,`address`,`first_name`)
) ENGINE=InnoDB AUTO_INCREMENT=16804 DEFAULT CHARSET=utf8;
现有执行计划不走索引
EXPLAIN SELECT * FROM person force index(`name-address`) WHERE `name` = 2 AND `address` LIKE "%222" and first_name LIKE "%222";
EXPLAIN SELECT * FROM person force index(`name-address`) WHERE `name` = 1 AND address = 1
执行计划为