开发者

What would be the most efficient way to do this search (mysql or text)?

Suppose I have 500 rows of data, each with a paragraph of text (like this paragraph). That's it.I want to do a search that matches part of words. (%LIKE%, not FULL_TEXT)

What would be faster?

  1. SELECT * FROM ...WHERE LIKE "%query%"; This would put load on the database server.
  2. 开发者_开发百科
  3. Select all. Then, go through each one and do .find >= 0 This would put load on the web server.

This is a website, and people will be searching frequently.


This is very hard for us to determine without knowing:

  • the amount of text to search
  • the load and configuration on the database server
  • the load and configuration on on the webserver
  • etc etc ...

With that said i would conceptually definitely go for the first scenario. It should be lightening-fast when searching only 500 rows.


You can use a full text search if you use myisam engine. http://dev.mysql.com/doc/refman/5.1/en/fulltext-query-expansion.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜