Why MariaDB Outperforms MySQL: A Detailed Performance Comparison
This article traces MySQL’s evolution, introduces its fork MariaDB, and presents a comprehensive performance benchmark—covering single and batch inserts, indexed and non‑indexed queries—on identical hardware, revealing that MariaDB generally delivers faster execution times albeit with higher memory usage.
MySQL Development History
MySQL was created in the mid‑1990s and released under the GPL in 2000. The InnoDB storage engine was introduced in 2001 and later became the default engine in MySQL 5.5 (2010). After Sun acquired MySQL AB in 2008, Oracle bought Sun in 2009, bringing MySQL under Oracle’s control.
MariaDB – The Fork
Concerned about Oracle’s direction, Michael Widenius forked MySQL before it could become closed‑source and created MariaDB, a community‑maintained drop‑in replacement. MariaDB aims for full compatibility with MySQL’s APIs and command‑line tools and uses XtraDB (a variant of InnoDB) as its default storage engine. Versioning diverged from MySQL, starting at 10.0.
Test Environment
CPU: Intel i7
Memory: 8 GB
OS: Windows 10 64‑bit
Disk: SSD
MySQL version: 8.0.19
MariaDB version: 10.4.12
Both servers used an identical schema:
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;Insert Performance
Single‑Row Inserts
Inserting rows one by one showed that MariaDB is roughly twice as fast as MySQL. Average per‑row time:
MySQL: 0.005185 s
MariaDB: 0.002409 s
For 10 000 rows the total elapsed time was 54.98 s (MySQL) vs 24.45 s (MariaDB).
Batch Inserts
When rows were inserted in batches, MariaDB still outperformed MySQL on average, though the margin was smaller.
MySQL average per‑row time: 0.000035 s
MariaDB average per‑row time: 0.000022 s
For 10 000 rows the total time was 0.328 s (MySQL) vs 0.181 s (MariaDB).
Query Performance
Both databases were populated with 6 785 000 rows before running the queries.
No Index
Count rows: MySQL 6.404 s, MariaDB 3.065 s (MariaDB uses ~474 MB vs MySQL ~66 MB).
MAX/MIN `time`: MySQL 8.159 s, MariaDB 6.333 s.
`time` range + sort: MySQL 10.193 s, MariaDB 6.996 s.
`level` = 'info': MySQL 0.049 s, MariaDB 0.006 s.
`message` = 'debug': MySQL 0.004 s, MariaDB 0.003 s.
With Index
Indexes added:
ALTER TABLE `performance`.`log`
ADD INDEX `time` (`time`),
ADD INDEX `level` (`level`),
ADD FULLTEXT INDEX `message` (`message`);Index creation time: MySQL 3 min 48 s, MariaDB 2 min 47 s.
MAX/MIN `time`: MySQL 0.006 s, MariaDB 0.001 s.
`time` range + sort: MySQL 0.398 s, MariaDB 0.020 s.
`level` = 'info': MySQL 0.065 s, MariaDB 0.049 s.
`message` full‑text search: MySQL 0.003 s, MariaDB 0.005 s.
Some indexed queries were slower than their non‑indexed counterparts, illustrating that indiscriminate indexing can be counter‑productive.
Conclusion
Across the benchmarks, MariaDB consistently delivered higher performance than MySQL, especially for insert operations and many read queries. The speed advantage comes at the cost of higher memory consumption, and careful index selection remains important for optimal query performance.
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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
