简体   繁体   English

MySQL全文搜索vs Like %%

[英]MySQL Full-Text search vs Like %%

What are key differences and what is a use case for both of them? 什么是关键差异以及它们的用例是什么? Thanks! 谢谢!

Full-text search is the kind of search based on special sort of index (full-text, obviously). 全文搜索是一种基于特殊索引的搜索(显然是全文)。 So you get the power of O(lgN) while searching using it. 因此,在使用它时,您可以获得O(lgN)的强大功能。

While like %% always causes table fullscan which can be terrible slow (when you have 100k and more rows). 虽然like %% 总是导致表fullscan,这可能是非常慢(当你有100k和更多行)。

Personally I use Like %% when it is a small table (0-1000 rows) and I'm sure that it will never grow (and, important, when like %% fits the task requirements). 我个人使用Like %%当它是一个小表(0-1000行)时,我确信它永远不会增长(而且,重要的是,当like %%符合任务要求时)。

Note: fulltext indexes are available only for myisam SE. 注意:全文索引仅适用于myisam SE。 If you use innodb - then you need to look at some 3rd party indexing software like sphinx 如果你使用innodb - 那么你需要看看像sphinx这样的第三方索引软件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM