如何创建伪文档导向模型?

发布于 2024-10-17 04:00:11 字数 396 浏览 9 评论 0原文

目前,我使用 Rails 和 Mysql 作为后端。不幸的是,我的应用程序的数据规模扩大了,这是启动时未预期或预见到的。现在,随着数据库中条目的增加,我面临着许多性能问题,并且由于使用关系逻辑而引发了无数查询,因此 ActiveRecord 受到了打击。

我已经到了这样的地步:我想为享受适当的关系模型的优势而付出代价。由于速度受到了关注,我不得不对 Mongo DB 等面向文档的模型进行研究,发现它们提供了速度补偿关系功能。

我的问题是,如何慢慢从关系模型迁移到文档模型。也许,我会存储我的临时模式或返回的表,并将它们转储为运行中的批量文档,而不是设置适当的面向文档的数据库(至少在初始阶段)。空间对我来说不是问题。我现在关心的只是时间。但我无法一次性完成这一任务。我想知道如何解决这个问题,任何以前解决过此类问题的链接/参考文献将不胜感激。

Currently, I am using Rails with Mysql as the backend. Unfortunately, my application has scaled in data which was not expected or foreseen when it started. Now, I am facing a lot of performance issues with increasing entries in the database and ActiveRecord is taking hit due to in-numerous queries that are fired as a result of enjoying the Relational logic.

I have come to a point where I feel like paying penalty for enjoying the advantages of a proper Relational model. Since speed has come under the hammer, I had to do research on Document-Oriented Models like Mongo DB and found that they offer speed compensating the Relational features.

My question here is, how to slowly migrate from Relational model to document model. Perhaps, I will store my temporary schemas or the tables returned and dump them as a bulk document on the fly instead of setting up a proper document-oriented DB (at least during the initial phase). Space is not an issue for me. All I care now is time. But then, I cannot do that in one single sweep. I would like to know how to approach this problem, any links/references where this kind of problem has been solved before would be much appreciated.

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

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

发布评论

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

评论(1

月朦胧 2024-10-24 04:00:11

我强烈建议不要迁移到文档数据库,除非您的数据更适合这样的数据库。

出于速度原因进行迁移通常是一个坏主意,您应该在现有的基于 AR 的系统中寻找缓慢的查询并对其进行优化。

I would highly recommend against migrating to a document db unless your data is better suited to such a database.

Migrating for speed reasons would generally be a bad idea, and you should instead look for slow queries in your existing AR based system and optimise them.

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