Databases 10 min read

MariaDB Outperforms MySQL and PostgreSQL in Simple Query Benchmark

The author benchmarks MariaDB 10.3, MySQL 8.0, and PostgreSQL 12 using a real Turkish motorcycle classifieds app with many simple queries, finding MariaDB 5% faster on average and 7% faster at p95 with lower CPU usage, though MySQL handles tail latency better and memory differences stem from default performance_schema settings.

21CTO
21CTO
21CTO
MariaDB Outperforms MySQL and PostgreSQL in Simple Query Benchmark

Application and Workload

The benchmark uses mpazari.com , a Turkish motorcycle classifieds site built with Spring Boot 4, Java 25, and GraalVM native image. The homepage executes about five simple read queries per request (listings, categories, counts, footer). The dataset is small but real: 31 tables, 20,750 rows in the motor_ilanlar table, ~111 MB total. This workload emphasizes many simple queries rather than complex joins or analytical queries.

Test Setup

All tests run on the same Hetzner server (8‑core, 32 GB RAM, Ubuntu 20.04). The same data dump is restored into each database. MariaDB and MySQL listen on localhost (ports 3306 and 3307); MySQL runs in Docker with --network host to avoid NAT overhead. Load is generated with k6: ramp to 50 virtual users over 1 minute, hold 5 minutes, ramp down 1 minute; each iteration loads the homepage and sleeps 1 second. SLA thresholds are p(95) < 200 ms and p(99) < 500 ms. PostgreSQL results come from an earlier production run on the same hardware but with a shared cluster and different SQL dialect, so they provide context rather than a pure engine comparison.

Benchmark Results

MariaDB 10.3.39 leads on average latency (125.52 ms) and p95 (129.73 ms), about 5% and 7% faster than MySQL 8.0.42 (132.40 ms avg, 139.43 ms p95). PostgreSQL 12 averages 156.97 ms (≈25% slower than MariaDB). However, MySQL shows better tail latency: p99 of 150.07 ms vs MariaDB’s 182.13 ms and PostgreSQL’s 177.16 ms. All three meet the SLA thresholds comfortably. Request counts are similar (≈16k), with zero failures.

CPU and Memory Analysis

In a smaller 15‑VU run, MariaDB’s CPU usage is dramatically lower: 0.2% average / 1.0% peak vs MySQL’s 6.6% / 9.0% (with performance_schema on) and 8.3% / 10.0% (with it off). The author attributes this to MariaDB’s executor handling many simple queries with less overhead. Memory (RSS) peaks at 141 MB for MariaDB, 411 MB for MySQL (default), and 1.7 GB for PostgreSQL (shared cluster, not directly comparable).

Impact of performance_schema

MySQL’s higher memory footprint is largely due to performance_schema being enabled by default, while MariaDB disables it by default. Disabling performance_schema reduces MySQL’s RSS to 162 MB, close to MariaDB’s 141 MB. The initial memory gap is therefore a configuration difference, not an inherent engine disadvantage.

Limitations and Conclusions

For this workload — simple queries, small fully‑resident dataset — MariaDB 10.3 is slightly faster on average and p95, and uses less CPU. MySQL 8.0 has better p99 stability. PostgreSQL is slower but the comparison is not pure due to different SQL and shared resources.

The results do not generalize to complex joins, analytical queries, write contention, replication, larger datasets, or newer MariaDB versions (10.6, 11.x). Version differences matter: MariaDB 10.3 is from 2019, MySQL 8.0.42 is newer. The 5% average latency advantage is real but small; schema design, indexing, caching, and connection handling matter more than choosing between MariaDB and MySQL for this application. The answer to the original question: yes, MariaDB is faster for many simple queries in this real‑world case, but the edge is workload‑specific and not decisive.

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.

MySQLPostgreSQLbenchmarkperformance_schemadatabase performanceMariaDBk6simple queries
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

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.