Databases 10 min read

Why Choose MySQL When PostgreSQL Offers So Many Advantages?

The article compares PostgreSQL and MySQL, highlighting PostgreSQL's richer data types, true sequence support, powerful extensions, built‑in monitoring, advanced replication, open‑source licensing, and MVCC implementation, while acknowledging MySQL's strengths in quick deployment and read‑heavy workloads.

Java Companion
Java Companion
Java Companion
Why Choose MySQL When PostgreSQL Offers So Many Advantages?

Background and Motivation

With the push for domestic innovation and the need for open‑source, stable, and feature‑rich databases, PostgreSQL has become the preferred foundation for many Chinese tech giants. Companies such as Tencent (TBase), Alibaba (PolarDB for PostgreSQL), Huawei (GaussDB/openGauss), and HaloTech (openHalo) have built distributed, cloud‑native, or HTAP systems on top of PostgreSQL ( https://github.com/Tencent/TBase, https://opengauss.org, etc.).

Why Not MySQL?

The article asks why these enterprises favor PostgreSQL over the widely used MySQL and proceeds to enumerate MySQL's key shortcomings and PostgreSQL's corresponding advantages.

1. Limited Data Types in MySQL

MySQL’s core data types are basic and struggle with complex scenarios. PostgreSQL offers:

Array types : store multiple values in a single column.

Range types (e.g., int4range, tsrange) for intervals.

Composite types : custom structures like POINT(x,y).

JSONB : binary JSON with indexing and efficient queries.

2. Lack of True Sequence Objects in MySQL

MySQL 5.7+ simulates sequences with AUTO_INCREMENT + 3088413, but it cannot create an independent sequence object. Example:

-- PostgreSQL creates an 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');

In MySQL the equivalent requires binding to a table:

-- Must bind to a table's AUTO_INCREMENT
ALTER TABLE orders AUTO_INCREMENT = 1000;
-- Or simulate with a variable
SET @next_id = 3088413 + 1;

Cannot share sequences across tables.

Ensuring uniqueness in distributed environments often needs external middleware such as Redis.

3. Extension Ecosystem

PostgreSQL’s extensibility is a major advantage. Notable extensions include: 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. Performance Monitoring Tools

MySQL provides limited built‑in tools such as Performance Schema and slow_query_log, which are complex to configure and interpret. PostgreSQL offers rich built‑in views ( pg_stat_activity, pg_stat_statements, pg_locks) and mature third‑party tools like PgAdmin, pg_stat_monitor, and Prometheus + Grafana integrations.

5. Replication Capabilities

MySQL’s default asynchronous master‑slave replication can cause lag, lacks strong consistency guarantees, and GTID configuration is error‑prone. PostgreSQL provides:

Streaming Replication : supports both async and sync modes.

Logical Replication : table‑level replication and cross‑version migration.

WAL (Write‑Ahead Logging) : ensures durability and consistency.

Synchronous Replication : primary waits for at least one replica to confirm before committing, achieving zero data loss.

6. Open‑Source Licensing

MySQL is released under GPL with a commercial license controlled by Oracle, while PostgreSQL uses a BSD‑like license that is completely free and community‑driven.

7. MVCC Implementation Differences

PostgreSQL stores multiple versions per row, keeping old versions in the heap until vacuumed, which provides full isolation and serializable snapshot isolation. MySQL keeps only the current version, storing old versions in the undo log; this yields faster reads but can cause undo‑log bloat for long transactions.

Specific effects:

In PostgreSQL, readers can see a previous state even while a write is in progress.

In MySQL, uncommitted changes may appear as dirty reads or non‑repeatable reads depending on the isolation level.

Comparative Table (Summarized)

License : MySQL – GPL + commercial (Oracle); PostgreSQL – BSD‑like, fully free.

Enterprise vs Community : MySQL’s enterprise edition adds features like auditing and encryption; PostgreSQL’s community edition is complete.

Source Transparency : MySQL’s core development is Oracle‑controlled; PostgreSQL is maintained by a global community.

Long‑Term Stability : MySQL’s roadmap can shift with corporate decisions; PostgreSQL is governed by the PostgreSQL Global Development Group, independent of any single company.

Conclusion

Choosing between PostgreSQL and MySQL is not about which is universally better but which fits the specific requirements. PostgreSQL is a solid foundation for systems demanding long‑term evolution, complex data models, and strong consistency. MySQL remains efficient for rapid deployment and read‑heavy web applications. The rise of domestic databases in China demonstrates that building on PostgreSQL’s open, community‑driven core enables independent innovation.

MySQLreplicationPostgreSQLDatabase comparisonMVCCExtensions
Java Companion
Written by

Java Companion

A highly professional Java public account

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.