Percona Lab · Phase 1 · MySQL & MariaDB drivers

SQL Driver Benchmark

How much CPU does the database driver itself burn? MySQL and MariaDB drivers in C, Go, Java and Python ran the same single-threaded workloads against Percona Server 9.7 and MariaDB 12.3. For the same work, the most expensive driver often costs ten to a hundred times the cheapest.

AI-generated results. This benchmark was designed, run and analyzed with an AI assistant (Claude). Results and findings have been spot-checked by a person, but not every number and explanation has been verified in detail, and some may be wrong. The code and raw data are published so you can verify anything here; please report problems as issues on GitHub.

Every figure is client CPU per operation (user + kernel, whole process, GC and JIT threads included), the median of 5 fresh processes on an isolated core at a fixed 3.9 GHz. Server configuration is identical for every driver. Lower is better. A small number next to a value points to a note under its chart: a caveat, a server-side cause, or a result that is still provisional.

—drivers in four languages
—measured combinations (driver × server × test × variant × config)
—checksum failures
—median spread between the 5 runs (% coefficient of variation)

What stands out

Connect · TLS

TLS without a CA file reloads the system trust store on every connection

libmysqlclient spends — µs per TLS connect with no CA configured and — µs with a CA file: it parses all 120 system certificates each time even though it verifies nothing. The same holds for every driver built on libmysqlclient or MariaDB Connector/C.

Connect · TLS · server

MariaDB 12.3 forces the expensive P-521 key exchange

MariaDB negotiates ECDH on secp521r1; Percona Server uses P-256. Every client pays: go-sql-driver needs — µs per TLS connect to Percona and — µs to MariaDB.

Connect

PyMySQL is slow to connect, with or without TLS

A plain TCP connect costs PyMySQL — µs of CPU against — µs for mysqlclient, the same over a Unix socket and on both servers. The profiling pass will show where it goes.

Point select · Go

go-sql-driver's parameterized query costs three round trips by default

Without interpolateParams each Query(sql, args) prepares, executes and closes a statement: — µs per query. With the option: — µs.

Result sets · TLS

libmysqlclient pays twice per row over TLS

It issues two TLS reads for every row, so a 1M-row text result costs — ns/row over TLS against — ns without. MariaDB Connector/C reads in large chunks: — ns/row over TLS.

Large values · server

MySQL converts JSON from binary to text on every read

Percona Server stores JSON in a binary format and reformats it on each read; MariaDB stores text. The same 10 KB documents cost go-sql-driver — ns/KB from Percona and — ns/KB from MariaDB; as LONGBLOB they cost the same on both. A storage trade-off, noted rather than analyzed here.

Bulk insert · Java provisional

Batch APIs range from best to worst choice

Connector/J's executeBatch() costs — µs per 1,000 rows on defaults and — µs with rewriteBatchedStatements. MariaDB Connector/Python's executemany costs — µs on MariaDB (bulk protocol) but — µs on Percona, where it falls back to one execute per row.

Overall

The C libraries set the floor; interpreted drivers sit far above it

Reading 1M integers costs — ns/row in C, — ns in Go (go-mysql), — ns with MariaDB Connector/Python and — ns with pure-Python mysql-connector.

Connect

Open a connection, authenticate, close; 2,000–10,000 times per iteration, no pooling. µs of client CPU per connection.

Point select

SELECT v FROM t_int WHERE id = ?, 200,000 random ids. µs of client CPU per query.

1M-row result

SELECT v FROM t_int, one million integers summed on the client. ns of client CPU per row.

Wide rows

10,000 rows × 100 columns, every cell read with the driver's natural type (DECIMAL, DATETIME, VARCHAR, …). ns of client CPU per cell.

Large values

1,000 documents per query, 20 queries, every value read. ns of client CPU per KB.

Bulk insert

One million rows in 1,000-row statements, values generated in the client. µs of client CPU per 1,000-row statement.

Footprint

Load the driver, connect, run SELECT 1. Resident memory in MB after connecting.

How this was measured
  • One bare-metal host (AMD EPYC 4245P, 32 GB, NVMe), Ubuntu 26.04.1, kernel 7.0. SMT and boost off; the client runs alone on an isolated core, the database on three others.
  • Percona Server 9.7.2-3 and MariaDB 12.3.4 with the same settings: 16 GB buffer pool (all data in memory), binlog off, innodb_flush_log_at_trx_commit=2.
  • Each combination runs as 5 fresh processes; the chart shows the median. Two extra processes per combination collect hardware counters (instructions, IPC, cache misses), shown in the tooltips; counters are never attached to timed runs because counting adds cost to every context switch.
  • Every iteration is checked against a checksum computed when the data was loaded, so no driver can skip work.
  • TLS is off for all tests except the TLS variants. "Tuned" means driver options only (for example rewriteBatchedStatements, interpolateParams, server-side prepared statements); the server is never tuned per driver.
  • "Not supported" lists combinations a driver cannot run, with its own reason. Phase 2 adds Node.js, PHP, Ruby, .NET, Rust and C++.
  • Numbered notes mark results with a known caveat. Java results are provisional: they were measured with a fixed warm-up that did not reach steady state; a rerun that warms up until iterations agree within 5% is under way.

Code, raw results and the full method: github.com/Percona-Lab/sql-driver-benchmark

Results from the Phase 1 run (November 2026). Code, raw data and method: github.com/Percona-Lab/sql-driver-benchmark · Data: cells.json, notes.json · Apache License 2.0