[フレーム]
BT

InfoQ Software Architects' Newsletter

A monthly overview of things you need to know as an architect or aspiring architect.

View an example

We protect your privacy.

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Unlock the full InfoQ experience

Unlock the full InfoQ experience by logging in! Stay updated with your favorite authors and topics, engage with content, and download exclusive resources.

Log In
or

Don't have an InfoQ account?

Register
  • Stay updated on topics and peers that matter to youReceive instant alerts on the latest insights and trends.
  • Quickly access free resources for continuous learningMinibooks, videos with transcripts, and training materials.
  • Save articles and read at anytimeBookmark articles to read whenever youre ready.

Topics

Choose your language

InfoQ Homepage News Uber Engineering Moving from Postgres to MySQL

Uber Engineering Moving from Postgres to MySQL

This item in japanese

Aug 12, 2016 2 min read

Write for InfoQ

Feed your curiosity. Help 550k+ global
senior developers
each month stay ahead.
Get in touch

In a recent blog post, Uber detailed why they have chosen to replace PostgreSQL with MySQL.

Uber’s main problem stems from the write amplification issue in Postgres. The write amplification happens because an update to a single row that touches indexes needs to update all indexes resulting in many writes to the disk which can be an even bigger issue when using SSDs. HOT(Heap-Only-Tuples) feature can alleviate this issue and may be a solution in some use cases. Consequently, the write amplification issue leaks into replication causing multiple updates to be transferred over wire for simple updates, which can cause major issues in disaster recovery scenarios where data centers may be far away from each other and bandwidth cannot be cheap or readily available.

Also, during a routine upgrade, a Postgres 9.2 bug caused data corruption in some tables. This was caused because of missing marking some entries as inactive as they should had been. Calculating the number of entries affected was not possible and because replication happens at the physical layer, there was the risk of ruining the database indexes.

Postgres also lacks true replica MVCC support. Replicas have to apply the same WAL(Write Ahead Log) writes as the master. Combined with Postgres design to block database updates if they affect rows open by a transaction it can seriously affect long running transactions. Long running transactions will be killed by Postgres since they block the WAL thread and this can be a problem since application developers may not be aware of the problem especially if using an ORM that isn’t transparent in transaction boundaries.

Again because replication works in the physical level, database updates have to happen at the same time for all nodes or else replication can not work. This means that for the size of Uber, upgrading to a new release was really problematic. This has been fixed using pglogical starting from 9.4 .

As for MySQL, in Uber’s case having flexibility in replication, lighter thread per connection instead of process per connection and less expensive caching are some of the advantages that they considered in their design decision. In the main issue of on disk representation, using InnoDB storage makes compaction more efficient and won’t affect many indexes or result in the write amplification problem as was the case with Postgres.

Some great rebuttals to Uber’s use case are available by Markus Winand, Simon Riggs and Robert Haas where they detail how these issues can be solved in several use cases and how it is not the case that Postgres should be ditched in every case for MySQL or vice versa.

Rate this Article

Adoption
Style

Related Content

The InfoQ Newsletter

A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example

We protect your privacy.

BT

AltStyle によって変換されたページ (->オリジナル) /