Databases 11 min read

PostgreSQL vs MySQL 2023: In‑Depth Feature, Performance, and Ecosystem Comparison

This article compares PostgreSQL and MySQL across licensing, performance, features, scalability, security, query optimization, replication, JSON support, CTEs, window functions, and ecosystem, using data from the 2023 Stack Overflow survey and practical experience to help developers choose the right open‑source relational database.

21CTO
21CTO
21CTO
PostgreSQL vs MySQL 2023: In‑Depth Feature, Performance, and Ecosystem Comparison

According to the 2023 Stack Overflow Developer Survey, PostgreSQL has overtaken MySQL as the most loved and most wanted open‑source relational database.

While MySQL remains the most widely installed open‑source database, PostgreSQL is positioned as the most advanced open‑source relational database.

License

MySQL Community Edition is licensed under the GPL.

PostgreSQL is released under the PostgreSQL License, a permissive BSD‑like license.

Some users worry that MySQL is owned by Oracle, which led to the creation of MariaDB as a fork.

Performance

For most workloads, PostgreSQL and MySQL differ by at most 30% in performance. Queries without proper indexes can degrade performance by 10‑1000× for either database.

MySQL shows an advantage in extreme write‑intensive workloads, but for typical applications the performance gap is not decisive.

Features

Object Hierarchy

MySQL uses a four‑level hierarchy: Instance → Database → Table → Column.

PostgreSQL uses a five‑level hierarchy: Instance (Cluster) → Database → Schema → Table → Column.

ACID Transactions

Database

Scenario

Transaction Support

MySQL 8.0 (pre‑8.0)

Data Manipulation Language

Yes

MySQL 8.0 (post‑8.0)

Data Manipulation Language

Yes

MySQL 8.0 (pre‑8.0)

Data Definition Language

No

MySQL 8.0 (post‑8.0)

Data Definition Language

Yes, but not within another transaction

PostgreSQL

Data Manipulation Language

Yes

PostgreSQL

Data Definition Language

Yes

Security

Both databases support role‑based access control (RBAC). PostgreSQL offers built‑in row‑level security, whereas MySQL requires additional views to emulate this behavior.

Query Optimizer

PostgreSQL provides a more advanced query optimizer compared with MySQL.

Replication

PostgreSQL uses physical replication based on WAL. MySQL uses logical replication based on binlog. PostgreSQL also supports logical replication via a publish/subscribe model.

JSON Support

Both databases support JSON columns, but PostgreSQL offers more operators and allows indexing on JSON fields.

Common Table Expressions (CTE)

PostgreSQL supports full CTE usage for SELECT, INSERT, UPDATE, DELETE inside and after CTEs. MySQL supports CTEs for SELECT inside and SELECT/UPDATE/DELETE after CTEs.

Window Functions

MySQL only supports ROWS frame type and limited range units. PostgreSQL supports both ROWS and RANGE frames, more range units, and advanced functions such as LAG, LEAD, FIRST_VALUE, and LAST_VALUE, generally with better performance.

Scalability

PostgreSQL’s extensibility shines with extensions like PostGIS, FDW, pg_stat_statements, and pgvector for AI workloads. MySQL’s pluggable storage engine architecture is now dominated by InnoDB, offering limited extensibility.

Availability

MySQL permits non‑aggregated columns in GROUP BY; PostgreSQL does not.

MySQL is case‑insensitive by default; PostgreSQL is case‑sensitive.

MySQL can join tables across databases; PostgreSQL requires FDW extensions for cross‑database queries.

Connection Model

PostgreSQL creates a new process per connection, providing stronger isolation but higher resource consumption. MySQL creates a new thread per connection, using fewer resources.

For PostgreSQL production, connection pooling tools like PgBouncer or pgcat are recommended.

Ecosystem

Both databases are well supported by standard SQL tools, but PostgreSQL’s community‑driven ecosystem has grown rapidly, with many managed services (e.g., Heroku, Supabase, Render, Fly.io) favoring PostgreSQL.

Operability

PostgreSQL can suffer from XID wraparound under heavy load; MySQL may encounter replication errors on large queues in cloud environments. Under typical workloads, both are mature and reliable, and managed platforms provide backup, recovery, and monitoring.

Final Comparison

POSTGRES

MYSQL

License

PostgreSQL License (MIT‑like)

GPL

Performance

Internet‑scale workloads

Comparable, better on extreme write‑intensive workloads

Features

More advanced in transactions, security, optimizer, JSON, CTE, window functions

Capable

Scalability

PAM + extensions

PAM

Availability

Strict standards compliance

More permissive, follows conventions

Connection Model

Process per connection

Thread per connection

Ecosystem

Vibrant community, more hosted providers

Large installation base

Operability

Steeper learning curve but powerful

Easy to use and operate

Overall, PostgreSQL offers richer features, a thriving community, and a stronger ecosystem, while MySQL provides a gentler learning curve and a larger user base. Developers should weigh the added complexity of PostgreSQL against the simplicity of MySQL when choosing a database for their projects.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performancemysqlLicensingPostgreSQLdatabase comparison
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

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.