简体   繁体   中英

Why does Heroku use Postgresql?

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?

UPDATE: From a heroku blog post :

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.

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 popular than postgres, but instagram is using postgres maybe due to these reasons. I feel postgres is much more mature and robust than mysql. Whereas mysql is more easy and simple to use.

Migrating MySQL to PostgreSQL in Rails « mindlev

Converting Rails application data from MySQL to PostgreSQL

For data migration, a handy little script: Rake task to transfer a Rails database, say from MySQL to Postgres and back again

Compare the length of this list of MySQL gotchas to this list of postgresql gotchas . MySQL is much more likely to mess you up.

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.

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.

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.

On the other hand, PostgreSQL (in particular Heroku's offering) has a couple sharp disadvantages for a startup app:

  • 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.

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:

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."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM