MySQL vs PostgreSQL
The oldest database rivalry in tech. One prioritizes simplicity. One prioritizes correctness. Choose accordingly.
The short answer
PostgreSQL over MySQL for most cases. PostgreSQL is the better database for almost everything built after 2015.
- Pick MySQL if running WordPress, need dead-simple replication, or your team already knows MySQL inside and out
- Pick PostgreSQL if starting a new project, need advanced features like JSONB or PostGIS, or want a database that grows with you
- Also consider: If you're choosing between managed services, look at Neon (Postgres) or PlanetScale (MySQL). The managed experience matters more than the engine for most teams.
— Nice Pick, opinionated tool recommendations
The Classic Showdown
MySQL and Postgres have been fighting since the 90s. MySQL won the LAMP stack era. Postgres is winning the modern era. Here's why.
MySQL was built for speed and simplicity. Postgres was built for correctness and extensibility. For a long time, MySQL's speed advantage mattered. With modern hardware, it doesn't.
Why Postgres Wins Now
JSONB support that actually works. Full-text search without Elasticsearch. PostGIS for geospatial. pg_vector for AI embeddings. Extensions like TimescaleDB and Citus.
Postgres is a platform, not just a database. You can build entire applications on its feature set without bolting on 5 other services.
Where MySQL Still Makes Sense
WordPress runs on MySQL. That's 43% of the web. If you're in the WordPress ecosystem, MySQL is the obvious choice.
MySQL replication is simpler to set up. If you need read replicas and don't want to think too hard, MySQL makes it easy.
And honestly, for simple CRUD apps, MySQL is perfectly fine. Not everything needs JSONB and CTEs.
Performance: Read vs. Read-Write, Complex Queries, and MVCC
MySQL screams on simple reads with its single-threaded replication and buffer pool, but throw in concurrent writes or complex joins and it stumbles. PostgreSQL’s multi-version concurrency control (MVCC) is superior—no row-level locking contention, no gap lock nightmares. In read-write workloads with 100+ concurrent connections, Postgres maintains throughput while MySQL degrades. For complex analytical queries (window functions, CTEs, recursive queries), Postgres is 2-5x faster. MySQL’s query optimizer is weak on subqueries and joins; Postgres uses a cost-based optimizer that actually works. If your app does anything beyond key-value lookups, Postgres wins performance-wise. Period.
ACID Compliance and Data Integrity
Both claim ACID, but MySQL’s default storage engine (InnoDB) has caveats: DDL statements are not transactional, and replication can lag leading to phantom reads. PostgreSQL is fully ACID—every statement, every DDL, every replication slot is transactional. Its WAL (Write-Ahead Log) is crash-safe; MySQL’s binary log can lose data on crash without sync_binlog=1, which kills performance. Postgres enforces foreign keys, check constraints, and exclusion constraints strictly; MySQL silently ignores invalid dates and truncates strings. If data integrity matters (and it should), Postgres is the only honest choice.
Feature Set and Extensibility: Data Types, Extensions, and Ecosystem
MySQL’s data type support is basic: no arrays, no native JSON indexing (it’s just text), no range types, no geometric types. PostgreSQL offers arrays, hstore, native JSONB with GIN indexes, range types, network types, and more. Extensions? Postgres has PostGIS (spatial), pgvector (AI embeddings), and pg_partman (partitioning). MySQL’s plugin ecosystem is anemic. For scalability, Postgres’s declarative partitioning and parallel query execution handle terabytes; MySQL’s partitioning is limited and buggy. In managed hosting, RDS for PostgreSQL now matches MySQL’s options (Aurora, etc.) but with better performance. Migration? Use pgloader—it’s fast and handles most types. Postgres’s community is developer-focused; MySQL’s is DBA-heavy. For replication, Postgres’s logical replication is flexible; MySQL’s group replication is complex and fragile. The verdict: Postgres scales better, does more, and costs the same.
Quick Comparison
| Factor | MySQL | PostgreSQL |
|---|---|---|
| JSON Support | Basic | JSONB (excellent) |
| Extensions | Limited | Rich ecosystem |
| Replication | Simple, mature | More complex |
| Standards Compliance | Partial | Strict |
| Full-Text Search | Basic | Built-in, good |
| Hosting Options | Everywhere | Everywhere |
| WordPress Compat | Native | Not supported |
The Verdict
Use MySQL if: You're running WordPress, need dead-simple replication, or your team already knows MySQL inside and out.
Use PostgreSQL if: You're starting a new project, need advanced features like JSONB or PostGIS, or want a database that grows with you.
Consider: If you're choosing between managed services, look at Neon (Postgres) or PlanetScale (MySQL). The managed experience matters more than the engine for most teams.
PostgreSQL is the better database for almost everything built after 2015. Better JSON support, better extension ecosystem, better standards compliance. MySQL is fine if you inherited it, but you shouldn't start new projects on it.
Related Comparisons
Disagree? nice@nicepick.dev