有LIKE子句时的最佳索引类型这是我的查询:SELECT name, usage_guidance, total_used_numFROM tagsWHERE
( name LIKE CONCAT('%', ?, '%') OR
usage_guidance LIKE CONCAT(?, '%') )
AND name NOT IN ($in)ORDER BY name LIKE CONCAT('%', ?, '%') DESC, name ASCLIMIT 6哪一个是最好的指数?tags(name,usage_guidance)tags(usage_guidance,name)tags(name)tags(usage_guidance)或者有更好的选择吗?!你知道,当LIKE进来时,我对创建索引感到困惑。因为LIKE %something永远不会从索引中获益。同样在上面的查询中,我有两个AND,OR并且IN..这就是为什么我问这个问题也知道你对它的看法。这是我的表结构:CREATE TABLE `tags` (
`id` int(11) NOT NULL,
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`usage_guidance` varchar(150) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`description` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`parent_id` int(11) UNSIGNED DEFAULT NULL,
`related` int(11) UNSIGNED DEFAULT NULL,
`total_used_num` int(11) UNSIGNED NOT NULL,
`date_time` int(11) UNSIGNED NOT NULL)ENGINE=InnoDB DEFAULT CHARSET=latin1;我正在尝试制作自动填充建议查询。像这样的东西:
添加回答
举报
0/150
提交
取消