DBA专家门诊三期:性能诊断优化
                                                    mysql如何实现like民生这样的有效索引查询。
mysql如何实现like '%民生%' 这样的有效索引查询。
1、我创建一个表:
CREATE TABLE `tb_news` (
  `id` bigint(20) NOT NULL auto_increment,
  `title` varchar(100) default NULL,
  `content` mediumtext,
  `keywords` varchar(50) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312
2、同时创建索引:
create index tb_news_title on tb_news(title);
3、有10万条数据,实现按标题title的模糊查询如:
select id,title from news where title like '%民生%';
4、我知道:
select id,title from news where title like '民生%';
索引是有效的。
可是select id,title from news where title like '%民生%';
索引就无效了。
有什么好的办法解决标题title的模糊查询。
感谢希望给予回复!
-------------------------
 回23楼俞月的帖子
多谢您的指导!
                                                    
                                                        赞0
                                                        踩0