Databases 11 min read

Can Open‑Source Databases Handle Millions of Queries per Second? PostgreSQL vs MySQL Benchmarks

This article presents a detailed benchmark comparing PostgreSQL 9.6 and MySQL 5.7 on identical high‑end hardware using pgbench and SysBench, describing the test methodology, configuration tweaks, performance results for point selects and OLTP workloads, and concluding that both systems scale to modern demanding workloads.

dbaplus Community
dbaplus Community
dbaplus Community
Can Open‑Source Databases Handle Millions of Queries per Second? PostgreSQL vs MySQL Benchmarks

Background

Open‑source database advocates often claim that their systems can process millions of queries per second. Percona engineers benchmarked PostgreSQL 9.6 and MySQL 5.7 on identical, demanding workloads to provide empirical comparison.

Methodology

Two servers were used:

Freematiq server : 4 × 72‑core CPUs (144 virtual cores), 3 TB RAM, ~3 K IOPS, CentOS 7.1, XFS.

Percona server : 2 × 12‑core CPUs (24 virtual cores), 251.9 GB RAM, ~33 K IOPS, Ubuntu 14.04.5, EXT4.

PostgreSQL was exercised with pgbench; MySQL with SysBench. pgbench scripts were converted to SysBench Lua scripts so that comparable tests could run on both databases.

Test Setup and Adjustments

Initial conversions produced similar results, but several issues required fixes:

Run SysBench with --percentile=0 --max-requests=0 to obtain reasonable CPU utilization.

Use the concurrency_kit branch for better concurrency and Lua handling.

Apply the pull request https://github.com/akopytov/sysbench/pull/94 which rewrites Lua scripts to support prepared statements.

Pre‑load jemalloc or tmalloc when starting SysBench and mysqld.

Operating‑system parameters were tuned to the recommended values for both MySQL and PostgreSQL.

Results

Point SELECT

Four configurations were compared:

PostgreSQL 9.6 (standard)

PostgreSQL 9.6 with pgxact-align patch

MySQL 5.7 (Oracle build, “Dimitri”)

MySQL 5.7.15 (Percona build, “Sveta”)

OLTP Read‑Only (RO)

OLTP Read‑Write (RW)

Both databases scaled well on modern hardware. PostgreSQL synchronous commit performed similarly to InnoDB innodb_flush_log_at_trx_commit=1, while asynchronous commit matched innodb_flush_log_at_trx_commit=2. MySQL tests used up to 1024 concurrent connections and showed near‑linear throughput up to that point. Detailed charts (Point SELECT, OLTP RO, OLTP RW with different innodb_flush_log_at_trx_commit settings) confirmed that performance differences are modest and depend mainly on configuration and hardware.

Conclusions

When properly tuned and run on high‑performance servers, PostgreSQL 9.6 and MySQL 5.7 can each approach millions of queries per second and deliver comparable performance across a range of OLTP workloads. Key tuning steps include SysBench parameter adjustments, prepared‑statement support, and appropriate OS settings.

Supplementary Information

Recent InnoDB improvements in MySQL 5.7 that contributed to the results include:

Transaction list optimization – https://blogs.oracle.com/mysqlinnodb/entry/transaction_life_cycle_improvements_in (WL #6047)

Reduced lock_sys_t::mutex contention – http://dev.mysql.com/worklog/task/?id=6899

Index‑lock contention reduction – http://dev.mysql.com/worklog/task/?id=6326

Faster parallel flushes – WL #6642, WL #7047, WL #7868 (see http://dev.mysql.com/worklog/task/?id=6642 etc.)

MDL scalability enhancements – WL #6671, WL #8355, WL #7306, WL #7305 (see http://dev.mysql.com/worklog/task/?id=6671 etc.)

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.

databasemysqlPostgreSQLBenchmarkSysbenchpgbench
dbaplus Community
Written by

dbaplus Community

Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.

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.