PostgreSQL 9.2 vs MySQL 5.5: The Architecture of Choice for Norwegian Systems
The LAMP stack isn't what it used to be. Since Oracle's acquisition of Sun Microsystems, a quiet panic has settled over the open-source community. While many developers are blindly sticking to default configurations, those of us managing high-traffic clusters know that the choice between MySQL 5.5 and the newly released PostgreSQL 9.2 is no longer just a matter of preference—it's a matter of survival.
In Norway, where data integrity laws like Personopplysningsloven are strict and latency to NIX (Norwegian Internet Exchange) defines user experience, you cannot afford a database that locks up under load. I have spent the last month migrating a high-traffic e-commerce platform from a shared hosting environment to a dedicated KVM setup, and the benchmarks revealed uncomfortable truths about how these engines handle storage I/O.
The MySQL 5.5 Reality: Speed vs. Reliability
MySQL is the devil we know. It is ubiquitous, driving everything from WordPress blogs to Facebook. With version 5.5, InnoDB finally became the default storage engine, replacing the archaic MyISAM. This is critical because MyISAM supports only table-level locking. If one user writes to a table, everyone else waits. In a high-concurrency environment, this is death.
However, MySQL 5.5 still has its quirks. The replication is asynchronous by default, meaning if your master node crashes, you will lose committed transactions that haven't reached the slave yet. For a blog, this is fine. For a financial transaction in Oslo, it is unacceptable.
The Configuration That Matters
Most default my.cnf files are optimized for 512MB RAM servers from 2005. If you are running MySQL 5.5 on a modern VPS, you must tune the buffer pool. Here is the configuration I deploy on CoolVDS instances with 4GB+ RAM:
[mysqld]
# Allocate 70-80% of RAM to buffer pool on a dedicated DB server
innodb_buffer_pool_size = 3G
# Critical for SSD longevity and performance
innodb_flush_method = O_DIRECT
# Stop shared hosting tenants from starving your I/O
innodb_io_capacity = 2000
# Per-table tablespaces are mandatory for reclaiming disk space
innodb_file_per_table = 1
PostgreSQL 9.2: The New Heavyweight
PostgreSQL has long been dismissed by web developers as "too slow" or "too academic." That ends with version 9.2, released just last month. The introduction of Index-Only Scans allows Postgres to fetch data directly from the index without touching the heap, dramatically reducing I/O requirements.
Furthermore, 9.2 introduces native JSON support. While the NoSQL crowd is shouting about MongoDB, Postgres is quietly offering a hybrid solution: ACID compliance with schema-less flexibility. This is massive for developers dealing with evolving data structures.
Pro Tip: If you are migrating from Oracle, Postgres is your only logical path. The PL/pgSQL language is remarkably similar to PL/SQL, making the transition less painful than rewriting logic for MySQL.
Tuning Postgres for Throughput
Postgres is conservative out of the box. To make it fly on Linux, you need to adjust shared memory kernel parameters and the postgresql.conf file:
# Check your kernel limits first: sysctl -a | grep shm
# postgresql.conf
shared_buffers = 1GB # Typically 25% of RAM is sufficient due to OS caching
work_mem = 32MB # Be careful, this is per-operation!
maintenance_work_mem = 256MB
wal_buffers = 16MB
checkpoint_completion_target = 0.9 # Spreads out writes to avoid I/O spikes
The Hardware Bottleneck: Why I/O Kills Databases
You can tune your config files all day, but if your underlying storage is slow, your database will crawl. This is where most generic VPS providers fail. They oversell their storage arrays, putting fifty tenants on a single RAID array of 7.2k RPM SATA drives.
I recently diagnosed a server experiencing 40% iowait during backups. The CPU was idle, but the disk queue length was over 100. The solution wasn't software; it was moving to solid-state storage.
Benchmarking I/O
Don't trust the marketing. Test the disk speed yourself using dd with the fsync flag to bypass caching:
dd if=/dev/zero of=testfile bs=64k count=16k conv=fdatasync
On a standard shared host, you might see 40-50 MB/s. On a CoolVDS instance backed by enterprise SSDs, we consistently see numbers north of 300 MB/s. For a database doing heavy random writes (like an active Magento store), this difference is the gap between a sub-second page load and a timeout.
The Verdict: Which to Choose?
| Feature | MySQL 5.5 | PostgreSQL 9.2 |
|---|---|---|
| Primary Use Case | Read-heavy web apps (WordPress, Drupal) | Complex queries, financial data, geospatial (PostGIS) |
| Replication | Asynchronous (Standard), easy to set up | Streaming Replication (Built-in), Hot Standby |
| JSON Support | None (Stored as text) | Native JSON data type (New in 9.2) |
| Licensing | GPL (Oracle owned) | BSD / MIT style (Community owned) |
If you need simple read-scaling for a CMS, MySQL 5.5 on a tuned LEMP stack is sufficient. However, for anything requiring complex JOINs, strict data integrity, or JSON manipulation, PostgreSQL 9.2 is the superior technical choice.
Regardless of your engine, latency matters. Hosting your database in Germany or the US while your customers are in Oslo adds unnecessary milliseconds to every handshake. The Norwegian Data Protection Authority (Datatilsynet) is also becoming increasingly vocal about where user data physically resides. Keeping data within Norwegian borders or close proximity in Northern Europe is the safest play for compliance.
Database performance is rarely about raw CPU power; it is almost always about I/O throughput and memory management. Don't let a slow disk queue destroy your application's responsiveness. Spin up a test environment on CoolVDS today, run your own benchmarks, and see what dedicated KVM resources and SSD storage can actually do for your query times.