Part 12 · 2 chapters · ~12 min

Expert Mode

Postgres against MySQL argued in both directions with mechanism, the war stories (wraparound, bloat, the autovacuum that never ran, the slot that filled the disk), and where Postgres is going with asynchronous and direct IO and pluggable table access methods.

31

Postgres vs MySQL, both directions

argument for Postgresmechanismargument for MySQLmechanism
richer types and indexesextensible catalogue: GIN, GiST, BRIN, ranges, JSONB, PostGIScheaper primary key lookups and range scans by PKclustered index: the row is in the PK leaf
transactional DDLcatalogue changes are MVCC rows; roll back a migrationno vacuum operations to tuneundo logs and purge clean up versions
a smarter planner for complex SQLmerge join, extended statistics, parallel queryupdate-heavy tables bloat lessupdates in place; secondary indexes unchanged unless their columns change
per-transaction durabilitysynchronous_commit per transactioncheap connectionsthreads, not processes
logical decoding with pluginspgoutput, wal2jsonmature large-scale sharding toolingVitess
32

War stories, and where Postgres is going

storycauselesson
wraparound shutdownan abandoned replication slot held the xmin horizon for months; nobody alerted on age(datfrozenxid)alert on xid age and slot lag; set max_slot_wal_keep_size
the 400 GB table holding 40 GB of datadefault autovacuum scale factor on a hot update table; vacuum never caught upper-table autovacuum settings; pg_repack to recover
the autovacuum that never ranan idle-in-transaction connection from a pooled app since last Tuesdayidle_in_transaction_session_timeout
the slot that filled the diska CDC connector stopped consuming; WAL grew until the primary went read-onlyslot lag alerts, retention caps, runbooks
the migration that took the site downALTER TABLE queued behind a long query (part 10)lock_timeout on every migration

Where it is going: an asynchronous IO subsystem (18) with io_uring on Linux, ongoing work toward direct IO, pluggable table access methods (columnar and undo-based storage experiments such as OrioleDB), better logical replication (sequences, DDL, failover slots), and continued planner work such as skip scans. The architecture's two big costs, vacuum and processes, are where most of the innovation is aimed.