MongoDB 与 MySQL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4448194/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:00:31  来源:igfitidea点击:

MongoDB vs MySQL

mysqlactiverecordcomparisonmongodbruby-on-rails-3

提问by PeterWong

I used to build Ruby on Rails apps with MySQL.

我曾经使用 MySQL 构建 Ruby on Rails 应用程序。

MongoDB currently become more and more famous and I am now starting to give it a try.

MongoDB 目前变得越来越有名,我现在开始尝试一下。

The problem is, I don't know the underlying theory of how MongoDB is working (am using mongoid gem if it matter)

问题是,我不知道 MongoDB 如何工作的基本理论(如果重要,我正在使用 mongoid gem)

So I would like to have a comparison on the performance between using MySQL+ActiveRecord and model generated by mongoid gem, could anyone help me to figure it out?

所以我想比较一下使用 MySQL+ActiveRecord 和 mongoid gem 生成的模型之间的性能,有人可以帮我弄清楚吗?

采纳答案by cristian

The article entitled: What the heck are you actually using NoSQL for?does a very good job at presenting the pros and cons of using NoSQL.

这篇文章标题为:你到底在使用 NoSQL 做什么?在介绍使用 NoSQL 的利弊方面做得非常好。

Edit: Also read http://blog.fatalmind.com/2011/05/13/choosing-nosql-for-the-right-reason/blog post too

编辑:另请阅读http://blog.fatalmind.com/2011/05/13/choosing-nosql-for-the-right-reason/博客文章

Re-edit: I found some recent material (published in 2014) on this topic that I consider to be relevant: What's left of NoSQL?

重新编辑:我发现了一些关于这个主题的最新材料(2014 年发布),我认为这些材料是相关的:NoSQL 还剩下什么?

回答by Henrik

I don't know much of the underlying theory. But this is the advice I got: only use MongoDB if you run it across multiple servers; that's when it'll shine. As far as I understand, the NoSQL movement appeared in no small part due to the pain of load-balancing relational databases across multiple servers. So if you're hosting your application on no more than one server, MySQL would be the preferred choice.

我对基本理论知之甚少。但这是我得到的建议:只有在跨多个服务器运行时才使用 MongoDB;那时它会发光。据我所知,NoSQL 运动的出现在很大程度上是由于跨多个服务器的负载平衡关系数据库的痛苦。因此,如果您在不超过一台服务器上托管您的应用程序,MySQL 将是首选。

The good people over at the Doctrine projectrecently wrote a quite useful blog poston the subject.

Doctrine 项目的好人最近写了一篇关于这个主题的非常有用的博客文章

回答by Imhou

From what I have read so far... here is my take on it.

从我到目前为止所读到的……这是我的看法。

Standard SQL trades lower performance for feature richness... i.e. it allows you to do Joins and Transactions across data sets (tables/collections if you will) among other things.

标准 SQL 以较低的性能换取功能丰富……也就是说,它允许您跨数据集(表/集合,如果您愿意的话)进行连接和事务处理等。

This allows a application developer to push some of the application complexity into the database layer. This has it's advantages of not having to worry about data integrity and the rest of the ACID properties by the application by depending upon proven technology. The lack of extreme scalability works for pretty much all projects as long as one can manage to keep the application working within expected time limits, which may sometimes result in having to purchase high performance/expensive relational database systems.

这允许应用程序开发人员将一些应用程序复杂性推入数据库层。其优点是无需担心数据完整性和应用程序依赖成熟技术的其余 ACID 属性。只要能够设法使应用程序在预期的时间限制内工作,几乎所有项目都缺乏极端的可扩展性,这有时可能导致不得不购买高性能/昂贵的关系数据库系统。

On the other hand, Mongo DB, deliberately excludes much of the inherent complexity associated with relational databases, there by allowing for better scalable performance.

另一方面,Mongo DB 有意排除了与关系数据库相关的许多固有复杂性,从而实现了更好的可扩展性能。

This approach forces the application developer to re-architect the application to work around the lack of relational features... which in and itself is a good thing, but the effort involved is generally only worth it if you have the scalability requirements. Please note that with MongoDB depending upon the data requirements w.r.t ACID properties, the application will have to step up and handle as necessary.

这种方法迫使应用程序开发人员重新构建应用程序以解决缺乏关系特性的问题……这本身是一件好事,但通常只有在您有可扩展性要求时,所涉及的努力才值得。请注意,对于 MongoDB,根据 ACID 属性的数据要求,应用程序必须根据需要加强和处理。