Skip to content

Performance

Everyday workloads at 100,000 and 1,000,000 rows, each driver in its own process against the same MySQL 8.4 on the same machine, over plain TCP. The more rows an application reads or writes, the bigger the difference. When the time goes into the network round trip of many tiny queries, or into building ORM objects one by one, every driver gets closer to the others.

mysql-connector-python runs with its C extension, on Python 3.14 (it has none for 3.15 yet). The asyncio sections compare rustmy.aio with asyncmy, aiomysql and mysql.connector.aio.

Where the numbers come from

The charts and tables below are generated by benches/showcase.py and are the same as in the README, for the last release measured. Open Numbers under each chart for the table.

CPython 3.14.3 · MySQL 8.4.13 · Darwin arm64 · rustmy 1.4.0, mysqlclient 2.3.1, PyMySQL 2.2.8, mysql-connector-python 26.10.0 (C extension), SQLAlchemy 2.1.9, Django 6.1.3 · best of 5 (100k) and 3 (1M) · 2026-11-26T11:14:45+00:00

DB-API

DB-API: time per driver, lower is better

Numbers
Workload Rows rustmy mysqlclient PyMySQL mysql-connector vs mysqlclient
Read rows (tuples) 100,000 40 ms 124 ms 310 ms 156 ms 3.1× faster
Read rows (dicts) 100,000 54 ms 145 ms 342 ms 210 ms 2.7× faster
Stream rows 100,000 33 ms 106 ms 322 ms 184 ms 3.2× faster
Insert rows (executemany) 100,000 316 ms 1.09 s 639 ms 581 ms 3.4× faster
Read rows (tuples) 1,000,000 399 ms 1.32 s 3.19 s 1.63 s 3.3× faster
Read rows (dicts) 1,000,000 571 ms 1.41 s 3.52 s 2.11 s 2.5× faster
Stream rows 1,000,000 276 ms 1.03 s 3.20 s 1.81 s 3.7× faster
Insert rows (executemany) 1,000,000 3.37 s 10.98 s 6.45 s 5.91 s 3.3× faster

Prepared statements

Prepared statements: time per driver, lower is better

Numbers
Workload Rows rustmy (prepared) rustmy (text) mysql-connector (prepared) mysqlclient PyMySQL vs mysqlclient
Read rows 100,000 38 ms 40 ms 183 ms 126 ms 319 ms 3.3× faster
Read rows 1,000,000 420 ms 399 ms 1.83 s 1.50 s 3.20 s 3.6× faster

SQLAlchemy 2

SQLAlchemy 2: time per driver, lower is better

Numbers
Workload Rows rustmy mysqlclient PyMySQL mysql-connector vs mysqlclient
Core: read rows 100,000 50 ms 148 ms 329 ms 170 ms 3.0× faster
ORM: load objects 100,000 241 ms 327 ms 521 ms 361 ms 1.4× faster
ORM: stream objects (yield_per) 100,000 196 ms 257 ms 485 ms 330 ms 1.3× faster
ORM: bulk insert 100,000 565 ms 1.36 s 903 ms 1.02 s 2.4× faster
Core: read rows 1,000,000 434 ms 1.34 s 3.32 s 1.70 s 3.1× faster
ORM: load objects 1,000,000 2.56 s 3.46 s 5.41 s 3.79 s 1.4× faster
ORM: stream objects (yield_per) 1,000,000 1.89 s 2.45 s 4.77 s 3.25 s 1.3× faster
ORM: bulk insert 1,000,000 5.68 s 14.44 s 9.20 s 10.11 s 2.5× faster

Django

Django: time per driver, lower is better

Numbers
Workload Rows rustmy mysqlclient PyMySQL mysql-connector vs mysqlclient
QuerySet: load objects 100,000 209 ms 294 ms 483 ms 409 ms 1.4× faster
QuerySet: values_list() 100,000 47 ms 143 ms 330 ms 250 ms 3.0× faster
QuerySet: iterator() 100,000 175 ms 248 ms 452 ms 370 ms 1.4× faster
bulk_create() 100,000 1.15 s 1.41 s 1.40 s 1.93 s 1.2× faster
QuerySet: load objects 1,000,000 2.01 s 2.74 s 4.79 s 4.02 s 1.4× faster
QuerySet: values_list() 1,000,000 449 ms 1.23 s 3.34 s 2.48 s 2.7× faster
QuerySet: iterator() 1,000,000 1.69 s 2.47 s 4.54 s 3.67 s 1.5× faster
bulk_create() 1,000,000 11.36 s 13.81 s 13.95 s 19.14 s 1.2× faster

Memory

Memory: peak memory per driver, lower is better

Numbers
Workload Rows rustmy mysqlclient PyMySQL mysql-connector vs mysqlclient
Peak memory of fetchall() 1,000,000 504 MiB 697 MiB 511 MiB 496 MiB 28% less memory

asyncio: asyncmy 0.2.18, aiomysql 0.3.2 and mysql.connector.aio (mysql-connector-python 26.10.0, pure Python), on asyncio's default event loop; compared with asyncmy, the fastest of them. mysql.connector.aio's pool fails instead of waiting when no connection is idle, so it has no pool figure; SQLAlchemy has no asyncio dialect for it.

asyncio

asyncio: time per driver, lower is better

Numbers
Workload Rows rustmy asyncmy aiomysql mysql.connector.aio vs asyncmy
Read rows (tuples) 100,000 40 ms 35 ms 371 ms 454 ms 1.1× slower
Read rows (dicts) 100,000 50 ms 60 ms 405 ms 510 ms 1.2× faster
Stream rows 100,000 58 ms 61 ms 397 ms 606 ms 1.1× faster
Insert rows (executemany) 100,000 342 ms 538 ms 630 ms 1.07 s 1.6× faster
Read rows (tuples) 1,000,000 342 ms 374 ms 3.84 s 4.66 s 1.1× faster
Read rows (dicts) 1,000,000 555 ms 719 ms 4.14 s 5.17 s 1.3× faster
Stream rows 1,000,000 540 ms 563 ms 3.97 s 6.00 s on par with asyncmy
Insert rows (executemany) 1,000,000 3.76 s 5.49 s 6.37 s 10.20 s 1.5× faster
Pool: 32 tasks, 8 connections 6,400 queries 191 ms 186 ms 413 ms n/a on par with asyncmy

SQLAlchemy 2, asyncio

SQLAlchemy 2, asyncio: time per driver, lower is better

Numbers
Workload Rows rustmy asyncmy aiomysql vs asyncmy
Core: read rows 100,000 48 ms 46 ms 393 ms 1.1× slower
ORM: load objects 100,000 239 ms 255 ms 580 ms 1.1× faster
ORM: stream objects (yield_per) 100,000 477 ms 462 ms 843 ms on par with asyncmy
ORM: bulk insert 100,000 578 ms 762 ms 856 ms 1.3× faster
Core: read rows 1,000,000 462 ms 555 ms 3.92 s 1.2× faster
ORM: load objects 1,000,000 2.96 s 3.11 s 6.44 s 1.1× faster
ORM: stream objects (yield_per) 1,000,000 5.29 s 5.91 s 9.33 s 1.1× faster
ORM: bulk insert 1,000,000 6.56 s 8.44 s 9.45 s 1.3× faster

Why it is fast

  • Batches with the GIL released. Rows are read in batches of about 4 KiB with the GIL released, and each batch is converted in Rust while the server sends the next one: network and conversion overlap.
  • No intermediate objects. Values go straight from the wire to Python objects; date, datetime and timedelta are built directly, and dict rows are built in Rust with their keys created once per result.
  • Out of the garbage collector. Tuple rows of atomic values (numbers, text, bytes, dates, None, Decimal) are untracked as they are built, so collections during a large read do not traverse every row read so far.
  • Fewer round trips. executemany batches INSERT … VALUES into multi-row statements and pipelines everything else.

More scenarios

How it was measured, more scenarios (character sets, conv=, cursors, compression over slow links, pipelining with latency) and the history of every optimization are in the benchmark notes. Every pull request is also measured on CodSpeed.