PostgreSQL vs MySQL vs MariaDB - Help me Decide
PostgreSQL & MySQL are the two most popular open-source databases today.
The less popular MariaDB is a MySQL fork that happened after the acquisition of Sun Microsystems by Oracle on January 27, 2010.
Here's a graph representing the popularity of these 3 databases:

(Source: db-engines.com)
PostgreSQL & MariaDB have been gaining ground recently, while MySQL is slowly declining. But that's not enough to make a decision.
So which one should you choose?
Let's look at this from different angles.
Performance
By running some benchmarks you can get a rough idea of how these databases compare to each other in terms of performance.
For this article, we going to use the HammerDB benchmarking tool.
This tool implements a standardized performance test called TPC-C.
Here's the description:
"TPC-C involves a mix of five concurrent transactions of different types and complexity. The database is comprised of nine types of tables with a wide range of record and population sizes."
Here's the setup:
- Ubuntu 18.04
- 1 GB RAM
- 1 CPU
- MySQL 5.7.23
- MariaDB 10.1
- PostgreSQL 10.5
- Default settings
We ran the tests for 5 minutes for each database.
Here are the results:
- PostgreSQL 18534 TPM, 7972 NOPM
- MySQL 14051 TPM, 4659 NOPM
- MariaDB 21441 TPM, 7172 NOPM
The meaning of these two values (TMP & NOPM) is described like this:
"TPM values cannot be compared between different database types. The NOPM value is based on a metric captured from within the test schema itself. As such NOPM (New Orders Per Minute) is a performance metric independent of any particular database implementation and is the recommended primary metric to use."

Like any benchmark the results depend on the specific scenario the tests are run in.
This particular benchmark tries to reproduce the workload of any industry that must manage, sell or distribute a product or service.
Knowing that, we can conclude that both PostgreSQL & MariaDB are faster than MySQL in this particular scenario, with PostgreSQL coming on top of the raw performance game.
Features
These 3 databases support all the basic SQL operations you would expect.
But when it comes to more advanced features there is a lot of variability between them.
For example, PostgreSQL supports materialized views, while MySQL doesn't.
Here's a feature comparison table:
Looking at this table we can conclude that PostgreSQL has the most features implemented.
Besides these features, you can find some behavior differences.
For example, this query:
select 1000/0;
Returns NULL in MySQL, while PostgreSQL & MariaDB (since version 10.2.4) return a division by zero error.
This can be changed with SQL modes in MySQL.
Administration & Monitoring Tools
Because databases are critical software components there are dozens of tools available for administration, monitoring & troubleshooting.
Starting with the command-line applications:
mysql (MySQL, MariaDB)
psql (PostgreSQL)
These are great for basic administration tasks.
Why?
Because they come built-in with their respective servers so they are always available. There is nothing extra to install.
They both have a command history available, so you can re-run previously executed queries & commands.
And they have a set of bult-in commands that can facilitate interacting with the database.
For example, psql has the \d command to list all your databases, and mysql has the status command to get information like the server version & uptime.
Official graphical tools are also available.
They are:
Here's a screenshot from pgAdmin4:
![pgAdmin4]https://img.stackshare.io/stackups/postgresql_vs_mysql_mariadb_pgAdmin4.png)
And for MySQL Workbench:

Now we move onto more specialized tools like pghero (PostgreSQL).
PgHero is "a performance dashboard for Postgres".
Here's a screenshot:

For MySQL, and MariaDB, you can use MySQL Tuner. This is a Perl script that will analyze your configuration file & database statistics to produce configuration recommendations.
Here's a screenshot:

There are also log-parsing tools to help you find slow queries.
Here's pt-query-digest for MySQL, a tool for analyzing your logs & running queries to find the slowest queries so you can optimize them.
As you can see in this screen, it's also a command-line tool:

And here is pgBadger for PostgreSQL:

pgBadger is like pt-query-digest, but it will analyze PostgreSQL logs & slowest queries.
It looks like PostgreSQL has more graphical tools available, so if you are more comfortable using tools with graphical frontends, instead of command-line applications, then you may want to keep this in mind when making your decision.
Extensibility
You can install plugins & extensions if you need extra features for your database.
Extending MySQL & MariaDB is mostly done in the form of UDFs (User-Defined Functions), which are small plugins written in C.
However, it doesn't seem to be a very popular feature, so it's hard to find any useful UDF extensions.
PostgreSQL has some helpful extensions:
- PostGIS adds spatial search capabilities for geographic information systems (GIS)
- HStore allows you to use key-value storage without having to install a specialized database
- Multicorn allows you to query other sources of data (like Redis, Amazon S3, or even Twitter!) as if they were real tables
If you need any of these extensions then PostgreSQL might be a great choice for you.
Final Considerations
To make a good decision you should consider what your needs are.
- Is your application going to do a lot of work with geographic information? Then the PostGIS extension would be of great help.
- Could your application benefit from specific features that each database supports, like materialized views or partial indexes? Then choose that database.
- Do you need more hosting & support options? Then MySQL or MariaDB may be a better fit.
We hope you found this comparison useful!
MariaDB vs MySQL vs PostgreSQL: What are the differences?
MariaDB, MySQL, and PostgreSQL are all relational database management systems (RDBMS). Here are the key differences between them.
-
Data Processing Language: MariaDB and MySQL both use Structured Query Language (SQL) as their data processing language. However, PostgreSQL not only supports SQL but also extends it with additional features and capabilities. PostgreSQL offers a more robust and advanced SQL implementation compared to MariaDB and MySQL.
-
Storage Engines: MariaDB and MySQL originally had the same storage engine, which is known as the InnoDB engine. However, MariaDB introduced its own storage engines, such as Aria, XtraDB, and others, providing additional options for database optimization and performance tuning. PostgreSQL uses the PostgreSQL Object Relational Database Management System (ORDBMS) as its storage engine, which offers advanced features like JSONB, full-text search, and support for geospatial data.
-
Replication and Clustering: MariaDB and MySQL both offer built-in support for replication, allowing data to be copied and synchronized across multiple database servers. However, MariaDB has further enhanced its replication capabilities and introduced features like parallel replication and multi-source replication. On the other hand, PostgreSQL does not have built-in support for replication and clustering, but it provides various third-party tools and extensions for achieving replication and high availability.
-
Data Types and Indexing: MariaDB and MySQL have similar data types and indexing capabilities, although MariaDB includes some additional data types like JSON and virtual columns. PostgreSQL, on the other hand, provides a wider range of data types, including arrays, hstore (key-value pairs), and enumerated types. PostgreSQL also has advanced indexing options, such as partial indexes and expression indexes, which allow for more efficient querying and data retrieval.
-
Concurrency Control: MariaDB and MySQL use a technique called multi-versioning concurrency control (MVCC) for handling concurrent database operations. This allows multiple users to access the database concurrently without locking the entire tables. PostgreSQL also utilizes MVCC but provides more fine-grained control over transactions, offering features like Serializable isolation level and advisory locks to handle complex concurrency scenarios.
-
Community and Ecosystem: MariaDB and MySQL are both derived from the same codebase and have a similar community of developers and users. They share many libraries, tools, and frameworks. However, MariaDB has been developed as a community-driven open-source project, with a strong focus on being a drop-in replacement for MySQL. PostgreSQL has its own independent community that is known for its dedication to standards compliance, advanced features, and focus on data integrity.
In summary, MariaDB and MySQL share a common origin, with MariaDB aiming for compatibility and additional features, while PostgreSQL stands out for its extensibility, advanced features, and support for complex queries.