MySQL全文本搜索与“喜欢" %% [英] MySQL Full-Text search vs Like %%
问题描述
主要区别是什么?两者的用例是什么?谢谢!
What are key differences and what is a use case for both of them? Thanks!
推荐答案
全文搜索是一种基于特殊索引(显然是全文索引)的搜索.因此,您可以在使用O(lgN)
进行搜索时获得它的力量.
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.
like %%
总是时,导致表全扫描可能非常慢(当您有100k和更多的行时).
While like %%
always causes table fullscan which can be terrible slow (when you have 100k and more rows).
我个人使用Like %%
当它是一个小表(0-1000行)时,并且我确定它永远不会增长(并且重要的是,当like %%
满足任务要求时).
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).
注意:全文索引仅适用于myisam SE.如果您使用innodb-那么您需要查看一些第三方索引软件,例如 sphinx
Note: fulltext indexes are available only for myisam SE. If you use innodb - then you need to look at some 3rd party indexing software like sphinx
这篇关于MySQL全文本搜索与“喜欢" %%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!