MySQL vs PostgreSQL: The Database Wars of 2009
It has been exactly three days since Oracle announced their intent to acquire Sun Microsystems. For us in the system administration world, the panic is palpable. MySQL, the backbone of the LAMP stack, is now in the hands of the database giant it was designed to undercut.
If you are running a serious web application in Norway right now, you are likely asking one question: Is it time to jump ship to PostgreSQL?
I’ve managed clusters for high-traffic portals from Oslo to Kiev, and I’ve seen mysqld crash under load more times than I care to count. Let’s cut through the FUD (Fear, Uncertainty, Doubt) and look at the raw technical reality of these two engines as they stand today, in April 2009.
The Incumbent: MySQL 5.1
MySQL is the default for a reason. It is everywhere. It powers WordPress, Drupal, and likely 90% of the sites hosted on shared cPanel boxes.
The Pros:
- Read Speed: For simple
SELECTqueries, especially with the MyISAM storage engine, it is incredibly fast. - Replication: Setting up Master-Slave replication is trivial compared to the competition.
- Community: If you hit an error, someone on a forum has already solved it.
The Cons (The "Gotchas"):
By default, MySQL still leans heavily on MyISAM, which does not support transactions. If your server loses power in the middle of a write, say goodbye to your data integrity. You have to explicitly use InnoDB to get ACID compliance, but InnoDB can be a memory hog if not tuned correctly.
SysAdmin Tip: If you are running MySQL 5.1 on a VPS, stop using the default configuration. Open/etc/my.cnfand adjust yourinnodb_buffer_pool_size. Set it to 50-70% of your available RAM if you are using InnoDB exclusively. The default values are designed for 2002 hardware, not 2009.
The Challenger: PostgreSQL 8.3
PostgreSQL has always been the "academic" choice, but version 8.3 (and the upcoming 8.4) has made massive strides in performance. It is strictly ACID compliant and handles complex joins far better than MySQL.
The Pros:
- Data Integrity: It uses MVCC (Multi-Version Concurrency Control). Readers don't block writers, and writers don't block readers.
- Features: Triggers, views, and stored procedures are mature. It feels like Oracle, but free.
- Licensing: It is BSD licensed. No matter what Oracle does with MySQL's GPL license, Postgres remains truly free.
The Cons:
It is heavier. A fresh Postgres install consumes more resources than a slim MySQL instance. Until recently, replication was a nightmare (though Slony-I helps). Also, VACUUM processes can kill your I/O performance if scheduled poorly.
Comparison: A Real-World Scenario
| Feature | MySQL 5.1 (MyISAM) | PostgreSQL 8.3 |
|---|---|---|
| Transactions | No (Yes with InnoDB) | Yes (ACID) |
| Locking | Table-level | Row-level |
| Ideal Use Case | Blogs, CMS, Read-heavy sites | Financial apps, Complex Data |
The Bottleneck is Usually Disk, Not Software
Whether you choose MySQL or Postgres, your database is only as fast as the disk it lives on. This is where most generic hosting providers fail you.
In a typical database workload, random I/O is the killer. I recently diagnosed a Magento store suffering from 8-second page loads. The database configuration was fine. The problem? The host was putting them on a crowded server with a single SATA drive shared by 50 other users. The iowait was through the roof.
This is why at CoolVDS, we don't mess around with consumer-grade hardware. We utilize Enterprise SAS 15k RPM RAID-10 arrays. We are also testing early-generation Solid State Drives (SSD) for extreme caching layers. When your disk seeks take 3ms instead of 12ms, your database queries fly, regardless of whether you use SQL or Postgres.
Legal & Latency: The Norwegian Context
Latency matters. If your customers are in Oslo, hosting your database in Texas is a bad idea. The speed of light is a hard limit. Ping times from Oslo to a CoolVDS server in our local datacenter are often under 5ms.
Furthermore, with the Norwegian Personal Data Act (Personopplysningsloven) and the oversight of Datatilsynet, keeping sensitive customer data within national borders is becoming a critical compliance strategy. While we don't know what the legal landscape will look like in 10 years, right now, data sovereignty is your safest bet against legal headaches.
Verdict: Which One?
Choose MySQL if: You are running a standard web app like WordPress or Joomla, and you need maximum compatibility with existing tools. Just make sure you switch to InnoDB for critical data.
Choose PostgreSQL if: You are building a custom application, handling financial transactions, or you are worried about Oracle's stewardship of MySQL. The learning curve is steeper, but the sleep you get at night is worth it.
Ultimately, a tuned database needs a stable home. Don't let slow I/O or oversold CPU cycles kill your application's potential.
Ready to benchmark? Deploy a high-performance Linux VPS with CoolVDS today and see the difference real hardware makes.