为什么 Heroku 使用 Postgresql?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4394379/
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
Why does Heroku use Postgresql?
提问by markquezada
I'm busy porting some MySQL specific code to Postgresql in order to use it with Heroku. Just wondering if there is any specific reason why Heroku went with Postgresql over MySQL? Performance, architecture, etc?
我正忙着将一些 MySQL 特定代码移植到 Postgresql,以便在 Heroku 中使用它。只是想知道 Heroku 使用 Postgresql 而不是 MySQL 是否有任何具体原因?性能、架构等?
UPDATE: From a heroku blog post:
更新:来自 heroku博客文章:
At Heroku, we believe PostgreSQL offers the best mix of powerful features, data integrity, speed, standards compliance, and open-source code of any SQL database on the planet.
在 Heroku,我们相信 PostgreSQL 提供了地球上任何 SQL 数据库的强大功能、数据完整性、速度、标准合规性和开源代码的最佳组合。
采纳答案by zengr
Postgres is better than mysql in many ways. You can read these posts about migration rails app from mysql to postgres. Though mysql is more popularthan postgres, but instagram is usingpostgres maybe due to thesereasons. I feel postgres is much more mature and robust than mysql. Whereas mysql is more easy and simple to use.
Postgres 在很多方面都比 mysql好。您可以阅读这些关于将 rails 应用程序从 mysql 迁移到 postgres 的帖子。虽然 mysql比 postgres更受欢迎,但instagram 使用postgres 可能是由于这些原因。我觉得 postgres 比 mysql 更加成熟和健壮。而mysql更容易使用。
Migrating MySQL to PostgreSQL in Rails ? m i n d l e v
在 Rails 中将 MySQL 迁移到 PostgreSQL ?心得
Converting Rails application data from MySQL to PostgreSQL
将 Rails 应用程序数据从 MySQL 转换为 PostgreSQL
For data migration, a handy little script: Rake task to transfer a Rails database, say from MySQL to Postgres and back again
对于数据迁移,一个方便的小脚本:Rake task to transfer a Rails database,比如从 MySQL 到 Postgres 再返回
回答by El Yobo
Compare the length of this list of MySQL gotchasto this list of postgresql gotchas. MySQL is much more likely to mess you up.
将这个MySQL 陷阱列表的长度与postgresql 陷阱列表的长度进行比较。MySQL 更有可能把你搞砸。
回答by Scott Marlowe
Generally speaking I find pgsql lends itself to 24/7 operations better than mysql. Also, it seems to have fewer footguns build into it. I think if you're more familiar with one or the other, that's more likely to influence your decision than anything else.
一般来说,我发现 pgsql 比 mysql 更适合 24/7 操作。此外,它似乎内置了更少的脚踏枪。我认为,如果您更熟悉其中一个,那么这比其他任何事情都更有可能影响您的决定。
回答by Tyler Eaves
Well, performance on Postgres is generally better for complex querys, like the kind generated by ORMs. Also, postgres just tends to be more "solid". This is ancedotal but the postgres servers I've managed have always been much less troublesome than mysql, which likes to randomly crash once in a while, occasionally corrupting a table on the way down.
嗯,Postgres 的性能通常更适合复杂查询,比如 ORM 生成的那种。此外,postgres 往往更“可靠”。这是古老的,但我管理的 postgres 服务器总是比 mysql 麻烦得多,mysql 喜欢偶尔随机崩溃,偶尔在下降的过程中损坏表。
回答by Topher Hunt
I'm moving one of my client's Rails apps from Heroku Postgresql to Mysql (the ClearDB addon) at the moment. PostgreSQL is a stricter and more "correct" database service in many ways, which appears to be why Heroku endorses it. However, I find that the Rails framework more or less smoothes over the differences, and the majority of Rails apps won't grow big enough for Mysql's performance issues to become a dealbreaker.
我目前正在将我客户的一个 Rails 应用程序从 Heroku Postgresql 迁移到 Mysql(ClearDB 插件)。PostgreSQL 在很多方面都是更严格和更“正确”的数据库服务,这似乎是 Heroku 认可它的原因。然而,我发现 Rails 框架或多或少地消除了差异,而且大多数 Rails 应用程序不会增长到足以让 Mysql 的性能问题成为破坏者。
On the other hand, PostgreSQL (in particular Heroku's offering) has a couple sharp disadvantages for a startup app:
另一方面,PostgreSQL(尤其是 Heroku 的产品)对于启动应用程序有几个明显的缺点:
- The price.To prevent weekly "Database connection lost" errors when working with Heroku Postgres, you have to shell out $200/ month. On ClearDB, you get a promise of 100% uptime (we haven't had chance to evaluate this claim yet) for the $10/ month plan, which also offers 1 GB of space -- more than we'll ever need.
- Column ordering.When doing Rails development, I refer to the
schema.rb
database schema file every 5 minutes, and to keep this file tidy and readable I find it crucial to be able to specify what order columns should be added in. MySQL supports specifying the order of columns; PostgreSQL doesn't. In many cases, this feature is unimportant, but because of how Rails / ActiveRecord works, my life becomes much harder when I can't reorder columns.
- 价格。为了防止在使用 Heroku Postgres 时每周出现“数据库连接丢失”错误,您必须每月支付 200 美元。在 ClearDB 上,每月10 美元的计划可以获得 100% 正常运行时间的承诺(我们还没有机会评估此声明),该计划还提供 1 GB 的空间——这超出了我们的需要。
- 列排序。在做 Rails 开发时,我
schema.rb
每 5 分钟参考一次数据库模式文件,为了保持这个文件的整洁和可读性,我发现能够指定添加列的顺序至关重要。MySQL 支持指定列的顺序;PostgreSQL 没有。在许多情况下,此功能并不重要,但由于 Rails / ActiveRecord 的工作方式,当我无法对列重新排序时,我的生活变得更加艰难。
回答by Adrien Lamothe
Not contradicting any of the above advice, but if for some reason you really want or need to stick with MySQL, I recently noticed that Heroku is now offering a free MySQL add-on, called ClearDB:
与上述任何建议都不矛盾,但如果出于某种原因你真的想要或需要坚持使用 MySQL,我最近注意到 Heroku 现在提供了一个免费的 MySQL 附加组件,称为 ClearDB:
https://addons.heroku.com/cleardb
https://addons.heroku.com/cleardb
Haven't used it, so I can't vouch for it. Heroku claims 99.95% uptime for the free version (versus 100% uptime claimed for any of the paid versions,) and they disclaim the free version as being "Production Ready." They claim ClearDB is "native, unmodified MySQL."
没用过,所以不敢保证。Heroku 声称免费版本的正常运行时间为 99.95%(而任何付费版本都声称正常运行时间为 100%),并且他们否认免费版本是“生产就绪”。他们声称 ClearDB 是“原生的、未经修改的 MySQL”。