dsdt66064367 2010-03-16 23:27
浏览 81
已采纳

MySQL ..使用全文搜索或使用Like? 什么是更好的?

I'm working on a search feature for my application, I want to search all articles in the database. As of now, I'm using a LIKE in my queries, but I want to add a "Related Articles" feature, sort of like what SO has in the sidebar (which I see as a problem if I use Like).

What's better to use for MySQL searching, Fulltext or Like... or anything else I might not know about?

Also, I'm using the Kohana Framework, so If anybody knows an easy way to do fulltext matching using the query builder, I'd appreciate that.

Thanks.

  • 写回答

1条回答 默认 最新

  • duankuixi1930 2010-03-16 23:32
    关注

    First of all, you have to consider that :

    • MySQL FULLTEXT indexes are only possibles for tables in MyISAM -- not for tables in InnoDB
      • And only InnoDB supports foreign keys, transactions, ...
    • Using LIKE is generally pretty slow and bad for performances, as it generally means doing a full-scan of the table for each search.

    I would really not use any of those two solutions for any kind of big/real/important application...


    Instead of those two possibilities, have you considered using a real fulltext indexing/search engine ?

    For instance, you might want to take a look at :

    Note there is an implementation of Lucene that only requires PHP in Zend Framework : Zend_Search_Lucene -- might be useful if you cannot install any additionnal software on your server.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮