Rails 中的 MySQL 全文搜索?

发布于 2024-08-22 11:47:59 字数 241 浏览 4 评论 0原文

当我向我的第一个 Rails 应用程序添加搜索功能时,我使用了 Sphinx,因为我了解到使用 MySQL 的内置全文搜索是一个坏主意。虽然 Sphinx 运行良好,但设置起来有点复杂,而且我觉得我的应用程序中所需的简单搜索功能负担过重。

我的网站上执行的搜索并不频繁(最多每 3-4 秒一次搜索),因此我不太担心负载。

我的问题:与 Sphinx/Ferret/Solr/etc 相比,为什么使用 MySQL 的全文搜索是一个坏主意?

When I added search functionality to my first Rails app, I used Sphinx, after reading that using MySQL's built-in fulltext search was a bad idea. While Sphinx works well, it's a bit complicated to set up, and I feel there's too much overload for the simple searching functionality I require in my app.

Searches aren't performed very often on my site (at most one search every 3-4 seconds), so I'm not too worried about load.

My question: Why exactly is using MySQL's full text search a bad idea, compared to Sphinx/Ferret/Solr/etc..?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一笔一画续写前缘 2024-08-29 11:47:59

MySQL 是一个关系数据库,而不是一个搜索服务器,所以我们现在谈论的是使用不是专门为该任务构建的东西。话虽这么说,MySQL 的全文搜索效果非常好;但是,如果您需要扩展,那就不好了。

  1. 您不希望数据库服务器执行超出其必须执行的操作,因为即使没有运行全文搜索等功能,它通常也是应用程序的瓶颈。
  2. MySQL 全文搜索要求您使用 MyISAM 引擎,如果您关心数据的一致性,那么这是一个问题。
  3. MyISAM 不支持 InnoDB 等引擎支持的许多增强的数据验证工具,因此从 MyISAM 开始,您通常会处于不利地位。

但是,YMMV 并且如果您的应用程序能够承受 MyISAM 的缺点,请务必使用它。只需知道它并不是适合大多数任务(不是全部,但大多数)的出色生产引擎。

MySQL is a relational database and not a search server so right off, we are talking about using something that wasn't built specifically for the task. That being said, MySQL's full text search works pretty well; however, it isn't good if you need to scale.

  1. You don't want your DB server doing more than it has to as it is usually the bottleneck of the application even without something like full-text search running.
  2. The MySQL full-text search requires that you use the MyISAM engine which is a problem if you care about the consistency of your data.
  3. MyISAM doesn't support many of the enhanced data validation facilities supported by engines like InnoDB so you are generally at a disadvantage by starting with MyISAM.

But, YMMV and if your application can survive being subjected to MyISAM's shortcomings, by all means, use it. Just know that it is not a great production engine for MOST tasks (not ALL, but most).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文