PostgreSQL vs MySQL vs MariaDB
Origins and Governance
PostgreSQL traces its roots to the POSTGRES project at UC Berkeley, which began in 1986 under Professor Michael Stonebraker. The project became PostgreSQL in 1996 when SQL support was added, and it has been developed by a global community of contributors ever since. No single company controls PostgreSQL. The PostgreSQL Global Development Group oversees releases, and the independent PostgreSQL community manages the project's direction. This decentralized governance gives users confidence that no corporate acquisition or licensing change will disrupt their database strategy.
MySQL was created in 1995 by Michael "Monty" Widenius and David Axmark at the Swedish company MySQL AB. Sun Microsystems acquired MySQL AB in 2008 for one billion dollars, and Oracle Corporation acquired Sun in 2010, giving Oracle control over MySQL. Oracle continues to invest engineering resources into MySQL, but the dual-licensing model (GPL for open source, commercial license for proprietary embedding) and centralized decision-making have led some organizations to seek alternatives.
MariaDB was created in 2009 by Monty Widenius himself, immediately after the Oracle acquisition, as a guarantee that a community-governed MySQL-compatible database would always exist. The MariaDB Foundation oversees the project, and MariaDB Corporation (now MariaDB plc) provides commercial products and services around it. MariaDB has become the default MySQL replacement in most major Linux distributions.
SQL Compliance and Feature Depth
PostgreSQL has the most complete SQL standard compliance of any open source database. It supports advanced SQL features including recursive CTEs, lateral joins, window functions with full frame specifications, MERGE statements, JSON path queries, generated columns (stored and virtual), row-level security policies, and domain types. PostgreSQL's type system is extensible, allowing users to define custom data types with their own input/output functions, operators, and index support.
MySQL 8.4 has closed much of the feature gap with PostgreSQL by adding window functions, CTEs (including recursive), JSON table functions, invisible indexes, functional indexes, and CHECK constraints (which MySQL previously accepted but silently ignored). However, MySQL still lacks several features that PostgreSQL users take for granted, including partial indexes, expression indexes on arbitrary expressions, table inheritance, array types, range types, and the ability to create custom aggregate functions in SQL.
MariaDB tracks MySQL's feature set while adding its own extensions. It supports system-versioned temporal tables (which automatically maintain a full history of all row changes), sequences, window functions, CTEs, Oracle-compatible PL/SQL syntax, and the Spider storage engine for table federation across remote servers. In areas where MySQL and PostgreSQL offer similar features, MariaDB typically follows the MySQL syntax and behavior.
Performance Characteristics
All three databases perform well for typical web application workloads, and the differences between them on standard OLTP benchmarks are often smaller than the differences caused by hardware, configuration tuning, and schema design. That said, each database has performance characteristics that favor certain workload types.
MySQL has historically been faster for simple read-heavy workloads, particularly single-table lookups and filtered queries that use indexed columns. The InnoDB buffer pool is tuned for this pattern, and MySQL's simpler query planner adds less overhead for straightforward queries. For applications like content management systems, e-commerce product catalogs, and session stores where most queries are simple lookups, MySQL's raw throughput is competitive or faster.
PostgreSQL's optimizer is more sophisticated and handles complex queries better. For workloads involving multi-table joins, subqueries, aggregations, and analytical queries, PostgreSQL generally produces better query plans. Its MVCC implementation handles mixed read-write workloads with less contention than MySQL's approach, particularly under high concurrency. PostgreSQL also benefits from parallel query execution, which can dramatically speed up large sequential scans and aggregations on multi-core servers.
MariaDB's performance is similar to MySQL for most workloads, since it shares the same InnoDB storage engine. Where MariaDB diverges is in its optimizer, which includes features like table elimination (removing unnecessary joins), condition pushdown, and more aggressive subquery optimization. For certain query patterns, particularly those involving subqueries and derived tables, MariaDB's optimizer produces faster plans than MySQL's.
JSON and Document Support
All three databases now support JSON storage and querying, though with different implementations and capabilities. PostgreSQL offers two JSON types: json (stores text) and jsonb (stores binary, indexed, faster to query). JSONB supports GIN indexes that make queries against JSON attributes fast even on large datasets. PostgreSQL's JSON path query syntax (introduced in version 12) follows the SQL/JSON standard and provides expressive filtering, array operations, and value extraction.
MySQL stores JSON in a binary format similar to BSON, supports JSON path expressions for querying, and provides functions for creating, modifying, and searching JSON documents. MySQL can create functional indexes on JSON expressions, allowing indexed lookups on specific JSON attributes. However, MySQL's JSON capabilities are less mature than PostgreSQL's, with fewer indexing options and less expressive query syntax.
MariaDB also supports JSON storage and a set of JSON functions compatible with MySQL's implementation. It treats JSON as a standard LONGTEXT column with validation, rather than a separate binary storage format. This approach simplifies some operations but means that MariaDB's JSON performance is generally slower than PostgreSQL's JSONB for query-intensive workloads involving JSON data.
Replication and High Availability
PostgreSQL supports streaming replication (binary, asynchronous or synchronous) for creating hot standby replicas, and logical replication for selectively replicating specific tables or transformations. Patroni, a widely-used open source tool, automates PostgreSQL failover with consensus-based leader election. The CloudNativePG operator manages PostgreSQL clusters on Kubernetes with automated failover, backup, and scaling.
MySQL offers binary log replication (asynchronous, semi-synchronous, or fully synchronous via Group Replication), InnoDB Cluster for automated failover with MySQL Router, and MySQL Shell for cluster administration. ProxySQL and MySQL Router handle connection routing and load balancing. MySQL's replication ecosystem is mature and well-documented.
MariaDB provides Galera Cluster for synchronous multi-master replication, where all nodes can accept writes and the cluster stays consistent without manual failover. This is MariaDB's standout feature for high availability. MariaDB also supports standard MySQL-style binary log replication and MariaDB MaxScale as a proxy for query routing, load balancing, and failover management.
Licensing Differences
PostgreSQL uses the PostgreSQL License (similar to BSD/MIT), the most permissive of the three. You can use, modify, and distribute PostgreSQL in any product, open source or proprietary, without restriction. No dual licensing, no contributor license agreements, no complications.
MySQL is dual-licensed: GPL for open source use, commercial license available from Oracle for proprietary embedding. Using MySQL as a database server for your application (connecting via the network protocol) does not trigger GPL obligations for your application code. But embedding MySQL's source code into a proprietary product requires a commercial license.
MariaDB uses the GPL, same as MySQL's open source license. The MariaDB Foundation maintains the project's open source commitment. MariaDB Corporation offers additional proprietary tools (MaxScale, ColumnStore Enterprise) under separate commercial licenses, but the core database server remains GPL.
When to Choose Each Database
Choose PostgreSQL when you need advanced SQL features, extensibility, complex query handling, strong JSON capabilities, geospatial support, or when licensing simplicity is a priority. PostgreSQL is the best starting point for new projects that may grow in complexity over time.
Choose MySQL when you are building on an existing MySQL ecosystem (WordPress, Drupal, Magento, Laravel), when your workload is primarily simple read-heavy queries, when you need the broadest possible hosting support, or when your team has deep MySQL expertise.
Choose MariaDB when you want MySQL compatibility with community governance, when you need Galera Cluster for synchronous multi-master replication, when you want temporal tables for automatic history tracking, or when your Linux distribution ships MariaDB by default and you want to work with the platform's native database.
PostgreSQL is the strongest default for new projects. MySQL is the proven standard for web applications. MariaDB is the best drop-in MySQL replacement with stronger community governance. All three are production-ready, actively maintained, and capable of handling demanding workloads.