app和微网站的区别是什么,wordpress添加网页背景图片大小,网站建设合同细节,网站建设宣传ppt模板对于mysql 5.6.4以上版本innodb支持全文索引的测试 在mysql官网#xff0c;innodb引擎在5.6.4版本提供了对全文索引的支持#xff0c;笔者对此做了测试#xff0c;发现对中文全文检索的支持依然不理想#xff0c;但却确实提供了对英文的全文支持。 12.9.5 Full-Text Restri… 对于mysql 5.6.4以上版本innodb支持全文索引的测试 在mysql官网innodb引擎在5.6.4版本提供了对全文索引的支持笔者对此做了测试发现对中文全文检索的支持依然不理想但却确实提供了对英文的全文支持。 12.9.5 Full-Text Restrictions
Full-text searches are supported for InnoDB and MyISAM tables only. FULLTEXT index support for InnoDB tables requires MySQL 5.6.4 or higher. 测试过程如下 1、版本选择选5.6.27 版。 2、安装完成后添加全文索引进行测试表引擎为Innodb 1修改ft_min_word_len参数值为1默认是42个汉字调整全文索引检索字段的最小长度为1个字节 mysql show variables like %ft_min_word_len%;------------------------
| Variable_name | Value |
------------------------
| ft_min_word_len | 1 |
------------------------1 row in set (0.00 sec) 2对表A的content列添加全文索引 1 alter table ask_questions add fulltext ind_ask_questions_content(content); 查看 1 show index from ask_questions; mysql show index from ask_questions;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| ask_questions | 1 | ind_ask_questions_content_cft | 1 | content | NULL | 1 | NULL | NULL | | FULLTEXT | | |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------9 rows in set (0.00 sec) 模糊匹配查询看看包含关键字的行数 1 select count(*) from ask_questions where content like %xxx%; 一共有182行其中包括四种情况%xxx%,%xxx,xxx%,xxx。 在全文索引查看的时候只能对 xxx 这种情况进行检索其他的行由于汉字与英文字母的断字不一样而忽略掉了 1 select * from ask_questions where MATCH(content) AGAINST (好玩吗) order by id limit 10; 但是其中的行比如不被空格?等隔开的行是不会被检索出来的 1 select * from ask_question_bak where content like %好玩吗% limit 10; 我们可以通过查看id列看出来差别 3、myisam中的中文全文索引测试 对于mysql自带的功能也是一样的支持并不是很好。 4、myisam安装mysqlcft插件测试对中文全文索引的支持 从coder.google下载mysqlcft下载地址:https://code.google.com/p/mysqlcft/downloads/list (1) 解压安装plugin。 查看插件目录: 1 show variables like %plugin%; ------------------------------------------------
| Variable_name | Value |
------------------------------------------------
| plugin_dir | /usr/local/mysql56//lib/plugin/ |------------------------------------------------ (2)解压把mysqlcfg.so文件cp到这个目录下安装plugin 1 INSTALL PLUGIN mysqlcft SONAME mysqlcft.so; (3)查看。 1 select * from mysql.plugin; -----------------------
| name | dl |
-----------------------
| mysqlcft | mysqlcft.so |
----------------------- 安装mysqlcft插件成功 测试查看查询数目与模糊查询一致效率提高了300倍左右 本文转自crazy_charles 51CTO博客原文链接http://blog.51cto.com/douya/1732130如需转载请自行联系原作者