Why Choose PostgreSQL Over MySQL Despite MySQL’s Popularity?
The article compares PostgreSQL and MySQL across data types, native sequences, extensions, monitoring tools, replication mechanisms, licensing, community governance, and MVCC implementation, showing why many Chinese tech giants favor PostgreSQL for complex, high‑consistency workloads while acknowledging MySQL’s strengths in simple web scenarios.
Domestic PostgreSQL‑based databases
Tencent TDSQL PG (open source name: TBase) – https://github.com/Tencent/TBase Alibaba PolarDB for PostgreSQL – distributed, cloud‑native storage with "one‑write‑many‑read" shared storage.
Huawei GaussDB (compatible with the openGauss ecosystem) – columnar engine and AI optimizer for HTAP workloads – https://opengauss.org Hangzhou Yijing openHalo – open‑source HTAP platform –
https://github.com/HaloTech-Co-Ltd/openHaloWhy PostgreSQL is preferred over MySQL
Data‑type richness
Array types – ARRAY stores multiple values in a single column.
Range types – e.g., int4range, tsrange represent numeric or temporal intervals.
Composite types – custom structures such as POINT(x,y) model real‑world objects.
JSONB – binary JSON with indexing, query and update capabilities, delivering far better performance than plain JSON fields.
Native sequence support
CREATE SEQUENCE order_seq START WITH 1 INCREMENT BY 1; INSERT INTO orders (id, name) VALUES (nextval('order_seq'), 'test');MySQL lacks independent sequence objects. It simulates sequences with AUTO_INCREMENT plus a large offset, and the sequence is bound to a specific table, making cross‑table sharing impossible without external middleware.
ALTER TABLE orders AUTO_INCREMENT = 1000;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 and monitoring.
Monitoring and diagnostics
Built‑in statistical views: pg_stat_activity, pg_stat_statements, pg_locks. EXPLAIN ANALYZE shows actual execution time and row counts.
Third‑party tools with mature integrations: PgAdmin, pg_stat_monitor, Prometheus + Grafana.
Replication and high availability
MySQL default asynchronous replication can cause lag; GTID solves part of the problem but is error‑prone; semi‑sync replication requires extra configuration and has high network demands.
PostgreSQL provides streaming replication (asynchronous or synchronous), logical replication per table or across versions, a mature WAL mechanism for durability, and synchronous replication that waits for at least one standby before committing, achieving zero data loss.
License and community
MySQL – GPL + commercial license controlled by Oracle; enterprise edition adds audit, encryption, etc.
PostgreSQL – BSD‑like license, fully free; community edition provides the complete feature set.
MySQL development is steered by Oracle, limiting community contributions; PostgreSQL is maintained by a global developer community with transparent governance.
MySQL roadmap can shift with corporate decisions (e.g., Oracle’s acquisition of Sun); PostgreSQL is governed by a foundation independent of any single company.
MVCC implementation
PostgreSQL stores multiple versions per row in the heap; old versions remain until vacuum cleans them, providing full read/write isolation and serializable snapshot isolation.
MySQL keeps only the current version in the row; older versions reside in the undo log, offering faster reads but risking undo‑log bloat for long transactions.
Result: In PostgreSQL, readers can see a previous state while a writer updates; in MySQL, uncommitted changes may appear as dirty reads or non‑repeatable reads depending on the isolation level.
Comparative dimensions
License : MySQL – GPL + commercial (Oracle); PostgreSQL – BSD‑like, free.
Enterprise vs community : MySQL enterprise adds features such as audit and encryption; PostgreSQL community edition includes the full feature set without cuts.
Source transparency : MySQL core development is Oracle‑controlled; PostgreSQL is maintained by a worldwide community with open source transparency.
Long‑term stability : MySQL roadmap may change with corporate decisions; PostgreSQL is led by a foundation, ensuring independence from any single vendor.
Feature timeline note
MySQL 8.0 introduced window functions only in version 8.0, whereas PostgreSQL had them much earlier.
IoT Full-Stack Technology
Dedicated to sharing IoT cloud services, embedded systems, and mobile client technology, with no spam ads.
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.
