Databases 9 min read

MySQL vs MariaDB: Real-World Performance Benchmark and Analysis

This article reviews the history of MySQL and MariaDB, describes a test environment, runs insertion, batch, and query benchmarks (with and without indexes), and concludes that MariaDB generally outperforms MySQL in speed and memory usage while highlighting trade‑offs of indexing.

Open Source Linux
Open Source Linux
Open Source Linux
MySQL vs MariaDB: Real-World Performance Benchmark and Analysis

MySQL and MariaDB Performance Comparison

History of MySQL

MySQL originated in 1979 when Michael "Monty" Widenius created an API for a reporting tool and later integrated SQL support using mSQL code. After several releases, MySQL 1.0 launched in 1996, followed quickly by Solaris and Linux versions. In 1999 Widenius founded MySQL AB, open‑sourced the product under GPL in 2000, and introduced the InnoDB storage engine in 2001, which remains the default. Sun acquired MySQL AB in 2008, then Oracle bought Sun in 2009, bringing MySQL under Oracle's control. Since then Oracle has altered development practices, raising concerns about the future openness of MySQL.

What Is MariaDB?

Disappointed by Oracle's direction, Widenius forked MySQL before it could become closed‑source, naming the fork MariaDB after his daughter. MariaDB is a community‑driven, GPL‑licensed drop‑in replacement for MySQL, initially using XtraDB (a fork of InnoDB) and maintaining API compatibility. Over time it diverged, adopting its own versioning (starting at 10.0) and offering performance and feature improvements over MySQL.

Test Environment

CPU: i7

Memory: 8 GB

OS: Windows 10 64‑bit

Disk: SSD

MySQL: 8.0.19

MariaDB: 10.4.12

Both databases were used to create a performance database with a log table using InnoDB:

CREATE TABLE `performance`.`log` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `time` DATETIME NOT NULL,
  `level` ENUM('info','debug','error') NOT NULL,
  `message` TEXT NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=INNODB CHARSET=utf8;

Insertion Performance

Single Row Inserts

Results (see image) show MariaDB inserting single rows roughly twice as fast as MySQL.

Batch Inserts

Batch insert tests (see image) indicate MariaDB generally outperforms MySQL, though the advantage is not absolute.

Query Performance Without Indexes

After populating both databases with millions of rows, a simple SELECT COUNT(0) FROM LOG took 3.065 s on MariaDB and 6.404 s on MySQL. Memory usage was 474 MB vs 66 MB respectively, showing MariaDB trades space for speed. SELECT COUNT(0) FROM LOG; Finding the min/max timestamps: SELECT MAX(TIME), MIN(TIME) FROM LOG; MariaDB: 6.333 s, MySQL: 8.159 s.

Filtering rows between 00:00 and 01:00 and ordering by time:

SELECT * FROM LOG WHERE TIME > '2020-02-04 00:00:00' AND TIME < '2020-02-04 01:00:00' ORDER BY TIME;

MariaDB: 6.996 s, MySQL: 10.193 s.

Querying rows where level='info': SELECT * FROM LOG WHERE LEVEL = 'info'; MariaDB: 0.006 s, MySQL: 0.049 s.

Querying rows where message='debug': SELECT * FROM LOG WHERE MESSAGE = 'debug'; MariaDB: 0.003 s, MySQL: 0.004 s.

Query Performance With Indexes

Indexes were added on time, level, and a full‑text index on message:

ALTER TABLE `performance`.`log`
  ADD INDEX `time`(`time`),
  ADD INDEX `level`(`level`),
  ADD FULLTEXT INDEX `message`(`message`);

Creating the indexes took 2 min 47 s on MariaDB and 3 min 48 s on MySQL. Subsequent benchmark results (see image) show mixed effects: some queries became faster, while others performed worse, illustrating that indexing is not universally beneficial.

Conclusion

The tests demonstrate that MariaDB generally offers better performance and higher memory consumption than MySQL, supporting the trend of many organizations migrating from MySQL to MariaDB for speed‑critical workloads.

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.

SQLindexingInnoDBmysqlBenchmarkDatabase PerformanceMariaDB
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

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.