开发者

How to optimize full text searches?

I know there are a lot of question already on this subject, but I needed more specific information. So here goes:

  1. Ideally what should be the maximum length of characters upon which a full text search can be performed using minimal resources (CPU, memory)?
  2. When should I decide between using the LIKE %$str% and f开发者_运维问答ull-text search?
  3. Is it important to have both versions LIKE %$str% and full-text search implemented and use the optimal one dynamically?


  1. As far as I know it depends on the number of words, not characters. The fewer, the faster mysql will be. But don't let that get in your way.
  2. Never use LIKE if you can use a full-text search. Except maybe for queries that you would manually run once in a while and you don't want to slow down the INSERTs on that table. You know the speed of select vs speed of insert tradeoff in indexes, right?
  3. Always use FT (full-text) search in queries that you don't run manually. LIKE is slow and becomes really slower when the number of rows increases. This is because the mysql engine has to look into EVERY row to answer your query. And FT keeps an index and knows exactly where to look.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜