Why Leading Companies Choose PostgreSQL Over MySQL: A Technical Comparison
This article compares PostgreSQL and MySQL, highlighting PostgreSQL's richer data types, native sequences, extensible ecosystem, advanced monitoring, robust replication, open licensing, and MVCC implementation, while also acknowledging MySQL's strengths in simplicity and read‑heavy web workloads.
Background
In recent years, with the push for domestic innovation and the need for self‑controllable databases, PostgreSQL has become the preferred open‑source foundation for many Chinese tech giants. Companies such as Tencent Cloud (TBase), Alibaba Cloud (PolarDB), Huawei Cloud (GaussDB/openGauss) and Hangzhou Yijing Shutong (openHalo) have built distributed, cloud‑native or HTAP systems on top of PostgreSQL.
Why choose PostgreSQL over MySQL?
PostgreSQL offers richer data types, native sequence objects, a powerful extension ecosystem, advanced monitoring views, and mature replication mechanisms, making it more suitable for complex, high‑consistency workloads.
1. Richer data types
Array : store multiple values in a single column.
Range : int4range, tsrange, etc., for intervals.
Composite : custom structs such as POINT(x,y).
JSONB : binary JSON with indexing and fast queries.
2. Native sequence support
PostgreSQL provides independent SEQUENCE objects that can be used without tying to a table. Example:
-- Create a standalone sequence
CREATE SEQUENCE order_seq START WITH 1 INCREMENT BY 1;
-- Use the sequence to generate IDs
INSERT INTO orders (id, name) VALUES (nextval('order_seq'), 'test');MySQL only simulates sequences with AUTO_INCREMENT + offset and cannot share a sequence across tables, which complicates uniqueness in distributed environments.
3. Extension ecosystem
TimescaleDB: time‑series database with automatic partitioning and compression. pg_trgm: fuzzy matching and similarity search. Citus: distributed database extension. pg_stat_statements: SQL execution statistics.
4. Monitoring and diagnostics
Built‑in views such as pg_stat_activity, pg_stat_statements, pg_locks.
Support for EXPLAIN ANALYZE showing real execution time and row counts.
Third‑party tools like PgAdmin, pg_stat_monitor, and Prometheus + Grafana provide mature visualisation.
5. Replication and high availability
Streaming replication (asynchronous or synchronous).
Logical replication for table‑level or cross‑version migration.
WAL (Write‑Ahead Logging) ensures durability.
Synchronous replication can achieve zero data loss.
6. Licensing and community
PostgreSQL uses a BSD‑like license, fully free and community‑driven.
MySQL’s GPL + commercial licensing is controlled by Oracle, with a split between enterprise and community editions.
PostgreSQL’s development is transparent and not tied to a single vendor.
7. MVCC implementation
PostgreSQL stores multiple versions per row, keeping old versions until vacuum cleans them, providing true snapshot isolation. MySQL keeps only the current version, with older versions in the undo log, which can lead to faster reads but may cause undo‑log bloat for long transactions.
Conclusion
PostgreSQL is not simply “better” than MySQL; it excels in scenarios that require complex data models, strong consistency, and long‑term evolution. MySQL remains advantageous for quick‑to‑market web applications with read‑heavy workloads. The rise of domestic databases in China builds on PostgreSQL’s open‑source foundation.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
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.
