Postgres vs MySQL: Which Database Wins in 2023?
A detailed 2023 comparison of PostgreSQL and MySQL examines licensing, performance, features, extensibility, usability, connection models, ecosystem, and operability, helping developers decide which open‑source relational database best fits their workloads and long‑term strategy.
License
MySQL Community Edition is released under the GPL license.
PostgreSQL is released under the PostgreSQL license, a permissive BSD‑style license.
Performance
For typical workloads PostgreSQL 15 and MySQL 8.0 (InnoDB) show comparable performance, usually within a 30 % margin. Missing indexes can cause query slowdowns of 10 × to 1 000 × in either system.
In write‑intensive workloads MySQL often has a slight edge. Notable case studies:
Uber’s migration from PostgreSQL to MySQL: https://www.uber.com/en-SG/blog/postgres-to-mysql-migration/
Critique of PostgreSQL features: https://ottertune.com/blog/the-part-of-postgresql-we-hate-the-most/
For most businesses performance alone is not decisive; large‑scale services such as Instagram and Notion run successfully on PostgreSQL.
Features
Object hierarchy
MySQL: Instance → Database → Table → Column (4 levels).
PostgreSQL: Instance/Cluster → Database → Schema → Table → Column (5 levels).
ACID transactions
Both databases support ACID, but PostgreSQL provides stronger transaction semantics (e.g., full serializable isolation, two‑phase commit).
Security
Both implement role‑based access control (RBAC).
PostgreSQL includes built‑in row‑level security (RLS); MySQL requires view‑based work‑arounds.
Query optimizer
PostgreSQL’s optimizer is generally regarded as more advanced, offering better cost estimation and plan selection. Discussion: https://news.ycombinator.com/item?id=29455852
Replication
PostgreSQL: physical replication via WAL and logical replication via publish/subscribe.
MySQL: logical replication via binary log (binlog).
JSON support
Both store JSON data.
PostgreSQL provides richer operators, functions, and native indexing on JSONB.
Common Table Expressions (CTE)
PostgreSQL: SELECT, INSERT, UPDATE, DELETE can appear inside CTEs and after CTEs.
MySQL: SELECT inside CTEs; SELECT/UPDATE/DELETE allowed only after the CTE.
Window functions
PostgreSQL supports row and range frames, a broader set of range units (including UNBOUNDED FOLLOWING, BETWEEN), and advanced functions such as LAG(), LEAD(), FIRST_VALUE(), LAST_VALUE().
MySQL supports only row frames and limited range units (UNBOUNDED PRECEDING, CURRENT ROW).
Extensibility
PostgreSQL’s architecture allows extensions that add functionality:
PostGIS – geospatial queries.
Foreign Data Wrappers (FDW) – query external data sources.
pg_stat_statements – query performance statistics.
pgvector – vector similarity search for AI workloads.
MySQL’s pluggable storage‑engine model is dominated by InnoDB; practical extensibility is limited.
Usability
MySQL permits non‑aggregated columns in GROUP BY clauses; PostgreSQL enforces strict grouping.
MySQL is case‑insensitive by default; PostgreSQL is case‑sensitive.
MySQL allows cross‑database JOIN operations; PostgreSQL requires FDW extensions for cross‑database queries.
Connection Model
PostgreSQL creates a new OS process per client connection, providing strong isolation at the cost of higher resource usage. MySQL creates a new thread per connection. For PostgreSQL, connection pooling (e.g., PgBouncer or pgcat) is recommended in production.
Ecosystem
Both databases are supported by common SQL tools, but PostgreSQL’s extensible design and community ownership have fostered a richer ecosystem. Managed services such as Heroku, Supabase, Render, and Fly.io primarily offer PostgreSQL instances.
Operability
PostgreSQL can encounter XID wraparound under very heavy write loads; regular vacuuming mitigates the issue.
MySQL clusters on Google Cloud have reported occasional replication errors in large‑scale deployments.
These issues are rare in typical workloads; both systems provide mature backup, recovery, and monitoring capabilities.
Conclusion
PostgreSQL offers a broader feature set, stronger extensibility, and a more vibrant community, while MySQL is easier to learn and benefits from a massive user base. The optimal choice depends on project requirements, team expertise, and whether PostgreSQL’s additional capabilities justify its steeper learning curve.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
dbaplus Community
Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.
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.
