Databases 6 min read

Performance Comparison of MariaDB and MySQL: Insert and Query Benchmarks

This article presents a detailed performance benchmark comparing MariaDB 10.4.12 and MySQL 8.0.19 on an i7 Windows 10 system, covering single and batch inserts, indexed and non-indexed queries, and analyzes speed and memory usage differences between the two databases.

Architect's Tech Stack
Architect's Tech Stack
Architect's Tech Stack
Performance Comparison of MariaDB and MySQL: Insert and Query Benchmarks

Hello everyone, I am Lei Ge.

MariaDB inherits the MySQL lineage but has diverged, starting its own version numbering from 10.0 while remaining fully compatible with MySQL. Its data characteristics and performance now surpass MySQL.

Test Environment

CPU: i7

Memory: 8 GB

OS: Windows 10 64‑bit

Disk type: SSD

MySQL: 8.0.19

MariaDB: 10.4.12

Both MySQL and MariaDB were used to create a database named performance 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

The single‑row insert test shows that MariaDB is roughly twice as fast as MySQL.

Batch Insert

The batch insert results indicate that MariaDB does not have an absolute advantage; in some cases it is slower, but on average it still outperforms MySQL.

Query Performance

After inserting millions of rows, the following query was executed to count the rows:

SELECT COUNT(0) FROM LOG;

Both tables contain 6,785,000 rows. MariaDB took 3.065 seconds, MySQL took 6.404 seconds. Memory usage was 474 MB for MariaDB and 66 MB for MySQL, indicating MariaDB trades space for speed.

No Index

Maximum and minimum values of the time column:

SELECT MAX(TIME), MIN(TIME) FROM LOG;

MariaDB: 6.333 s, MySQL: 8.159 s.

Filtering rows where time is 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 with level='info' :

SELECT * FROM LOG WHERE LEVEL = 'info';

MariaDB: 0.006 s, MySQL: 0.049 s.

Querying rows with message='debug' :

SELECT * FROM LOG WHERE MESSAGE = 'debug';

MariaDB: 0.003 s, MySQL: 0.004 s.

With Index

Indexes were added to both databases:

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

Index creation time: MariaDB 2 min 47 s, MySQL 3 min 48 s.

Subsequent benchmark results (images omitted) show that adding indexes does not always improve performance; some queries become slower, indicating that indexes should be applied judiciously.

Conclusion

The tests demonstrate that MariaDB generally outperforms MySQL, which explains why many large‑scale enterprises are moving from MySQL to MariaDB.

Author: swanmy Source: blog.csdn.net/zhmh326/article/details/104168710 License: CC 4.0 BY‑SA
SQLDatabasePerformance BenchmarkMySQLQueryMariaDBINSERT
Architect's Tech Stack
Written by

Architect's Tech Stack

Java backend, microservices, distributed systems, containerized programming, and more.

0 followers
Reader feedback

How this landed with the community

login 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.