Four databases, four different ways to ruin your weekend. Here's what failed and how to avoid the same mistakes.
PostgreSQL 17.6 (current stable as of August 2025) is solid, but the parallel query optimizer can consume significant memory. Complex queries with parallel workers can spike memory usage beyond what you'd expect. Common memory tuning for production systems:
-- Memory tuning for parallel queries
SET work_mem = '256MB'; -- default 4MB often insufficient
SET shared_buffers = '4GB'; -- default 128MB too small for production
ALTER SYSTEM SET max_parallel_workers_per_gather = 2; -- default 4 can spike memory
PostgreSQL memory tuning guide explains why defaults don't work in production.
MySQL 8.4.6 (LTS from July 2025) is solid, but Oracle's Innovation track (9.0/9.1) is their experimental playground. The new optimizer hints are decent, but anything past 8.4 feels like beta software. Enterprise Firewall in 8.4 can add 200-500ms latency:
-- Check if firewall is murdering performance
SHOW VARIABLES LIKE 'mysql_firewall_mode';
SELECT * FROM INFORMATION_SCHEMA.MYSQL_FIREWALL_WHITELIST;
-- Turn it off if queries are timing out
SET GLOBAL mysql_firewall_mode = OFF;
Stick with MySQL 8.4.6 LTS unless you enjoy 3am debugging sessions with Innovation track weirdness.
MongoDB 8.0.9 (latest stable as of May 2025) delivers substantial performance improvements - 32% faster reads, 59% faster updates, and 200%+ better time-series performance vs 7.0. But the WiredTiger cache management still requires careful tuning:
// Dangerous - can OOM your server
db.adminCommand({setParameter: 1, wiredTigerCacheSizeGB: 30}) // on 32GB server
// Safe approach - leave room for OS
db.adminCommand({setParameter: 1, wiredTigerCacheSizeGB: 20}) // 60-70% max
MongoDB will consume all available RAM if you let it. WiredTiger memory management explains the defaults.
Cassandra 5.0.5 (released August 2025) finally has working SAI indexes. After 10 years of "model your data for your queries" bullshit, you can run multi-column queries without dying inside. But Java 17 broke existing heap configs:
## Old Java 8 config (will break)
-Xms8G -Xmx8G -XX:NewRatio=3
## Java 17 config that actually works
-Xms16G -Xmx16G --add-exports java.base/jdk.internal.misc=ALL-UNNAMED
Cassandra Java 17 migration guide covers the heap tuning nightmare.
What Versions to Actually Use in Production
PostgreSQL 17.6: Stable and reliable for production use. Version 18 is still in beta (18 Beta 3 as of August 2025) - the memory usage patterns in parallel queries need more testing. Stick with 17.x for production. Security updates for 17.x guaranteed until November 2029.
MySQL 8.4.6: The LTS release recommended for production. Oracle's Innovation track (9.0/9.1) introduces new features rapidly but may have stability issues. MySQL LTS lifecycle means 8.4 gets patches until 2032.
MongoDB 8.0.9: Latest stable release with improved bulk write performance. Watch for balancer behavior during peak traffic - chunk migrations can impact performance. The sharding improvements make it worth upgrading from 7.0.x if you can schedule maintenance windows.
Cassandra 5.0.5: Released August 2025, includes working SAI indexes. Major enterprises are beginning 5.0.x migrations. If you're on 4.1.x, thorough testing is essential before upgrading. Cassandra 5.0 migration guide covers upgrade considerations.
The Real Problems Nobody Talks About
Here's what actually breaks in the field, not some textbook explanation:
PostgreSQL: Connection limits can kill busy sites. The error "FATAL: sorry, too many clients already" isn't helpful when traffic spikes. Default 100 concurrent connections, each using 4-8MB RAM. At 500 connections you're using 4GB just for connection overhead. Common fixes:
## Check connection usage
SELECT count(*) FROM pg_stat_activity;
## Kill runaway connections
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE query_start < now() - interval '5 minutes';
PostgreSQL connection pooling with pgbouncer prevents these issues.
MySQL: Binary logs can fill disk space and crash MySQL. The error "ERROR 3 (HY000): Error writing file '/var/lib/mysql/mysql-bin.000142' (errno: 28 - No space left on device)" indicates disk space issues. Monitor binlog growth:
## Check binlog size before it kills you
SHOW BINARY LOGS;
## Purge old logs (CAREFUL!)
PURGE BINARY LOGS BEFORE DATE_SUB(NOW(), INTERVAL 3 DAY);
MySQL binlog management prevents these 3am disasters.
MongoDB: Oplog size limits can break replica set syncing during heavy operations. Default 5% disk space might only represent hours of operations on busy systems.
// Check oplog status before disaster strikes
db.oplog.rs.find().sort({$natural: -1}).limit(1)
db.oplog.rs.find().sort({$natural: 1}).limit(1)
// Resize BEFORE you're fucked
db.adminCommand({replSetResizeOplog: 1, size: 50000}) // 50GB
MongoDB oplog sizing should be 3-5 days minimum.
Cassandra: Delete-heavy workloads accumulate tombstones that can slow reads. The gc_grace_seconds default of 10 days may be too long for high-delete scenarios.
## Check tombstone warnings
grep \"Read [0-9]* live rows and [0-9]* tombstone\" /var/log/cassandra/system.log
## Force cleanup (nuclear option)
nodetool compact keyspace table
Tuning gc_grace_seconds to shorter values (like 3600 for 1 hour) can help, but requires careful testing. Docker on macOS can introduce clock skew issues that affect Cassandra's gossip protocol.
Which Database Will Fuck You First
SQL vs NoSQL isn't just about schemas - it's about failure modes. PostgreSQL fails predictably. MongoDB fails creatively. Cassandra fails in ways that require a PhD to understand.
Based on DB-Engines popularity trends, here's what the data shows:
PostgreSQL is eating Oracle's lunch in enterprise. Every startup that can't afford Oracle licensing goes with Postgres. Stack Overflow Developer Survey 2025 shows it's the second most loved database after SQLite.
MySQL powers half the internet because it's predictable. Facebook, Twitter, YouTube all scaled with MySQL first. MySQL user adoption is driven by "it just works" mentality - boring technology that keeps running.
MongoDB is popular because developers can JSON.stringify()
and call it data modeling. MongoDB community stats show millions of downloads, but production deployments are way lower - everyone tries it, not everyone keeps it.
Cassandra is what Netflix, Apple, and Uber use when MySQL sharding becomes impossible. Cassandra users are companies that actually need global scale, not startups who think they do.
Performance Reality - No Marketing Bullshit
PostgreSQL maxes out around 50k QPS on a single node. After that you need read replicas, Citus sharding, or just switch to something else.
MySQL can hit 100k simple queries per second, but complex JOINs kill performance. MySQL at scale requires careful query optimization.
MongoDB scales horizontally but sharding is a pain in the ass. MongoDB sharding means dealing with shard keys, balancer storms, and chunk migrations that slow everything down.
Cassandra scales infinitely in theory, horribly in practice. Cassandra operations requires dedicated platform teams - not something your PHP developer can manage.