Performance Comparison of MariaDB vs MySQL: Insertion and Query Benchmarks
This article presents a detailed performance benchmark of MariaDB and MySQL, covering single‑row and batch inserts, as well as various query scenarios with and without indexes, and concludes that MariaDB generally outperforms MySQL while using more memory.
Introduction
MariaDB inherits the MySQL lineage but has diverged since version 10.0, offering higher data features and performance while remaining fully compatible with MySQL.
Test Environment
CPU: I7
Memory: 8 GB
OS: Windows 10 64‑bit
MySQL: 8.0.19
MariaDB: 10.4.12
Both databases were set up with a performance database and a log table using the InnoDB engine:
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 Insert
MariaDB inserts were roughly twice as fast as MySQL.
Batch Insert
Batch insert results showed mixed performance; MariaDB was sometimes slower but on average still ahead of MySQL.
Query Performance
After populating the tables with 6,785,000 rows, the following queries were executed.
SELECT COUNT(0) FROM LOG;MariaDB took 3.065 s, MySQL 6.404 s, using considerably more memory (≈474 MB vs 66 MB).
Without Index
SELECT MAX(TIME), MIN(TIME) FROM LOG;MariaDB: 6.333 s, MySQL: 8.159 s.
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.
SELECT * FROM LOG WHERE LEVEL = 'info';MariaDB: 0.006 s, MySQL: 0.049 s.
SELECT * FROM LOG WHERE MESSAGE = 'debug';MariaDB: 0.003 s, MySQL: 0.004 s.
With Index
ALTER TABLE `performance`.`log`
ADD INDEX `time` (`time`),
ADD INDEX `level` (`level`),
ADD FULLTEXT INDEX `message` (`message`);Creating indexes took MariaDB 2 min 47 s vs MySQL 3 min 48 s. Subsequent query tests showed mixed results; some indexed queries were slower than their non‑indexed counterparts, indicating that indexing every column is not always beneficial.
Conclusion
The benchmarks demonstrate that MariaDB generally offers better performance than MySQL, especially in read‑heavy scenarios, albeit at the cost of higher memory consumption, which explains why many large‑scale enterprises are migrating to MariaDB.
Architect's Tech Stack
Java backend, microservices, distributed systems, containerized programming, and more.
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.