我使用的是MySql 8。我想加快表单表上的搜索速度。
select * FROM dirctory_coop where name like '%mystr%';有人提到使用全文搜索-- https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html。不过,我对此有意见。下面是我的桌子。
mysql> desc directory_coop;
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| name | varchar(250) | NO | | NULL | |
| enabled | tinyint(1) | NO | | NULL | |
| phone_id | int | YES | MUL | NULL | |
| email_id | int | YES | MUL | NULL | |
| web_site | longtext | NO | | NULL | |
+----------+--------------+------+-----+---------+----------------+我尝试了下面的语句来更新我的列定义,但是我得到了以下错误.
mysql> alter table directory_coop modify column name FULLTEXT;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FULLTEXT' at line 1
mysql> alter table directory_coop modify name FULLTEXT;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FULLTEXT' at line 1我还需要做些什么来启用全文搜索应该提供的性能优化?
发布于 2020-08-14 16:43:14
发布于 2020-08-14 16:43:43
必须做的第一件事是创建一个FULLTEXT索引,如下所示:
ALTER TABLE directory_coop ADD FULLTEXT name_ftndx (name);这只是个开始。
接下来需要做的是理解使用FULLTEXT索引的SQL语法。
我有关于使用它们的DBA StackExchange中的许多帖子。
下面是一个启动您的好例子:为什么全文搜索返回的行数少于以下。这将显示使用LIKE和使用MATCH函数之间的区别。
我在DBA StackExchange中提到过两次
Aug 05, 2019:获取InnoDB全文索引的停止词May 05, 2018:Mysql全文搜索不返回任何结果https://dba.stackexchange.com/questions/273760
复制相似问题