Why Leading Chinese Tech Giants Prefer PostgreSQL Over MySQL: A Deep Technical Comparison
The article examines why major Chinese cloud and technology providers are building distributed, cloud‑native or HTAP databases on PostgreSQL instead of MySQL, detailing differences in data types, sequences, extensions, monitoring, replication, licensing, and MVCC implementation.
Background
With the push for domestic‑controlled databases, PostgreSQL’s open‑source nature, stability, and rich feature set have made it the preferred foundation for Chinese technology leaders. Companies such as Tencent (TBase), Alibaba (PolarDB for PostgreSQL), Huawei (GaussDB/openGauss), and Hangzhou EasyJing (openHalo) have built customized, distributed, cloud‑native, or HTAP systems on top of PostgreSQL.
Why PostgreSQL Over MySQL?
Several technical dimensions give PostgreSQL a clear edge over MySQL.
1. Richer Data Types
MySQL’s core types are basic, while PostgreSQL offers:
ARRAY : store multiple values in a single column.
Range Types (e.g., int4range, tsrange) for intervals.
Composite Types : custom structs like POINT(x,y).
JSONB : binary JSON with indexing, querying, and updating capabilities.
2. Native Sequence Support
PostgreSQL provides independent sequence objects, enabling true auto‑increment without tying to a table. Example:
-- PostgreSQL: create independent 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 simulates sequences with AUTO_INCREMENT + 3088413 or user‑defined variables, which cannot be shared across tables and are hard to guarantee uniqueness in distributed environments.
3. Extension Ecosystem
PostgreSQL’s extensibility allows powerful add‑ons such as: 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 & Diagnostics
MySQL’s built‑in tools ( Performance Schema, slow_query_log) are limited and complex to interpret. PostgreSQL ships with rich statistical views ( pg_stat_activity, pg_stat_statements, pg_locks) and supports EXPLAIN ANALYZE for real execution metrics. Mature third‑party tools like PgAdmin, pg_stat_monitor, and Prometheus + Grafana integrate seamlessly.
5. Replication Capabilities
MySQL’s default asynchronous replication suffers from latency, lacks strong consistency, and requires extra configuration for semi‑sync or GTID, which can be error‑prone. PostgreSQL offers:
Streaming Replication (async or sync modes).
Logical Replication for per‑table or cross‑version replication.
Mature WAL mechanism ensuring durability.
Synchronous Replication that waits for at least one standby to confirm before commit, achieving zero data loss.
6. Licensing & Openness
MySQL is released under GPL with a commercial Oracle‑controlled edition, limiting community influence. PostgreSQL uses a BSD‑like license, fully community‑driven, with transparent development and no feature restrictions between “community” and “enterprise” editions.
7. MVCC Implementation
PostgreSQL stores multiple row versions directly in the heap, providing full isolation and serializable snapshot isolation. MySQL keeps only the current version in the table and retains old versions in the undo log, which can lead to faster reads but may cause undo‑log bloat for long‑running transactions.
Supplementary Perspective
Despite PostgreSQL’s technical superiority, MySQL retains advantages in certain scenarios:
Minimal deployment and operational overhead.
Excellent read performance with InnoDB buffer pool and replication.
Broad web ecosystem support (WordPress, Laravel, Django, Drupal).
Deep optimization by cloud providers (Alibaba Cloud RDS, AWS RDS, Tencent Cloud CDB).
Rich community resources on CSDN, Stack Overflow, Zhihu.
Conclusion
The choice between PostgreSQL and MySQL is not about one being universally better, but about matching the database to the workload. For systems requiring long‑term evolution, complex data models, and strong consistency, PostgreSQL provides a solid foundation; for rapid‑launch, read‑heavy web applications, MySQL remains an efficient option. Domestic databases are increasingly built on PostgreSQL, leveraging its openness to drive independent innovation.
Architect's Tech Stack
Java backend, microservices, distributed systems, containerized programming, and more.
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.
