Why Choose PostgreSQL Over MySQL? A Detailed Feature Comparison
The article compares PostgreSQL and MySQL across data types, sequence handling, extensions, monitoring tools, replication, licensing, and MVCC implementation, showing why many Chinese tech giants prefer PostgreSQL for complex, high‑availability workloads while acknowledging MySQL’s strengths in simple web scenarios.
Background
PostgreSQL has become a preferred foundation for domestic Chinese technology companies seeking open‑source, stable, and feature‑rich database platforms, leading to deep customizations such as Tencent Cloud TDSQL PG (TBase), Alibaba Cloud PolarDB for PostgreSQL, Huawei Cloud GaussDB (openGauss), and Hangzhou Yijing openHalo.
Why PostgreSQL Over MySQL?
Richer data types : PostgreSQL supports ARRAY, range types (int4range, tsrange), composite types, and JSONB with indexing, whereas MySQL’s core types are more basic.
Native sequence objects : PostgreSQL provides independent CREATE SEQUENCE objects, enabling cross‑table sequences. MySQL emulates sequences with AUTO_INCREMENT + 3088413 and cannot share sequences across tables.
Extensible ecosystem : Extensions such as TimescaleDB (time‑series), pg_trgm (fuzzy matching), Citus (distributed), and pg_stat_statements (SQL monitoring) are readily available.
Built‑in monitoring : PostgreSQL includes rich statistics views ( pg_stat_activity, pg_stat_statements, pg_locks) and supports EXPLAIN ANALYZE. MySQL relies on Performance Schema and slow_query_log, which are harder to configure and interpret.
Replication model : PostgreSQL offers streaming replication (asynchronous/synchronous), logical replication, and a mature WAL mechanism, providing stronger consistency guarantees than MySQL’s default asynchronous master‑slave replication.
Open‑source licensing : PostgreSQL uses a BSD‑like license with a fully functional community edition, while MySQL’s GPL + commercial licensing is controlled by Oracle.
MVCC implementation : PostgreSQL stores multiple versions per row, allowing true snapshot isolation; MySQL keeps only the current version with undo logs, which can cause faster reads but may suffer from long‑transaction rollback bloat.
Key Comparative Tables (converted to lists)
License & Community
MySQL – GPL + commercial license (Oracle control)
PostgreSQL – BSD‑like, completely free
Enterprise vs Community Features
MySQL – Enterprise edition adds audit, encryption, etc.
PostgreSQL – Community edition includes all features; no functional cuts.
Source Transparency
MySQL – Core development steered by Oracle, limited community contribution.
PostgreSQL – Developed by a global community, fully open.
Long‑Term Stability
MySQL – Subject to corporate roadmap changes (e.g., post‑Sun acquisition).
PostgreSQL – Governed by the PostgreSQL Global Development Group, independent of any single company.
MVCC Details
PostgreSQL – Each row stores multiple versions; old versions remain in the heap until vacuumed, providing complete read/write isolation and true serializable snapshots.
MySQL – Only the current version is stored; previous versions reside in undo logs, offering faster reads but risking undo‑log bloat for long transactions.
Conclusion
PostgreSQL and MySQL are not a simple matter of “which is better”; the choice depends on workload requirements. PostgreSQL excels for long‑term evolution, complex data models, and strong consistency, while MySQL remains efficient for quick‑to‑market, read‑heavy web applications. The rise of domestic databases builds on PostgreSQL’s open‑source strengths to drive independent innovation.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
