Pymysql Benchmarks

Benchmarks of various asynchronous Python MySQL client libraries
Alternatives To Pymysql Benchmarks
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
21 days ago1February 27, 2018160gpl-2.0C
Scriptable database and system performance benchmark
9 months ago48gpl-2.0C++
AliSQL is a MySQL branch originated from Alibaba Group. Fetch document from Release Notes at bottom.
3 months ago1February 27, 2018123gpl-2.0Erlang
Tsung is a high-performance benchmark framework for various protocols including HTTP, XMPP, LDAP, etc.
Laravel Binary Uuid523
24 years ago15September 24, 2018mitPHP
Optimised binary UUIDs in Laravel
a month ago37gpl-3.0Tcl
HammerDB Database Load Testing and Benchmarking Tool
3 years ago4apache-2.0Java
Facebook Graph Benchmark
Sysbench Tpcc180
a year ago17apache-2.0Lua
Sysbench scripts to generate a tpcc-like workload for MySQL and PostgreSQL
Benchmark Php140
2 years ago1mitPHP
:rocket: A benchmark script for PHP and MySQL (Archived)
Mysql Haskell104
82 years ago15October 23, 20188bsd-3-clauseHaskell
Pure haskell mysql driver
a year ago1gpl-3.0Go
benchyou is a benchmark tool for MySQL, real-time monitoring TPS and vmstat/iostat
Alternatives To Pymysql Benchmarks
Select To Compare

Alternative Project Comparisons

This is a simple benchmark for various asynchronous Python MySQL client libraries.

The client libraries tested here are:

  • Twisted's adbapi which uses the MySQL client library written in C.
  • the pure Python txMySQL asynchronous client library
  • my own interface using tornado and adisp

The adbapi and txMySQL libraries assume they're running on the Twisted framework. The benchmarks allow you to run different reactor implementations:

  • Twisted's default reactor
  • the Tornado-based reactor for Twisted

The library is designed to run directly on top of Tornado and uses to make asynchronous programming a lot easier.

Here is how you write asynchronous database code with the adb and adisp modules:

from adisp import process from adb import Database

def __init__(self):
    self.adb = Database(driver="psycopg2",

def someFunctionInvokedFromIOLoop(self):
    # Drop the table if it exists
    yield self.adb.runOperation("drop table if exists benchmark")
# Create a table to insert the data into
    yield self.adb.runOperation("""
      create table benchmark (
        userid int not null primary key,
        data VARCHAR(100)
    rows_to_insert = 100000
    # Insert some rows in parallel
    start_time = time.time()
    stmts = []
    for i in xrange(rows_to_insert):
            ("insert into benchmark (userid, data) values (%s, %s)",
             (i, i)))
    numrows = yield map(self.adb.runOperation, stmts)
    end_time = time.time()

    rows = yield self.adb.runQuery("select count(*) from benchmark")
    print 'inserted %s records, time taken = %s seconds' % \
        (rows, end_time - start_time)

You can also use transactions:

def transactions(self):
    txId = yield self.adb.beginTransaction()
    yield self.adb.runOperation(
        "insert into mytable (userid, data) values (%s, %s)",
        (1, "test"),
    yield self.adb.commitTransaction(txId)

To rollback a transaction, use rollbackTransaction(txId) instead of commitTransaction().

The command line options for the benchmark are the following:

--db The database to use --dbhost Database host --dbpasswd Database user's password --dbuser Database user to use --pool_size Database connection pool size --use_adb Use database module --use_adbapi Use twisted's adbapi module --use_tornado Use tornado twisted reactor instead of twisted's reactor --use_txmysql Use txMySQL database module. Only works with Twisted and MySQL

Below are some benchmark results. The benchmark program runs on my Hackintosh Core i7-2600K 3.4GHz (4 cores 8 threads) running MacOS X 10.6.7. The database servers were run on the same machine. The benchmark connects to the databases using TCP sockets instead of Unix domain sockets.

The MySQL server version used was 5.1, while Postgres version was 9.0.4.

The pool size specified was --pool_size=10

Here are the times in seconds reported by the program:

MySQL: Tornado Twisted adb 11.79 N/A adbapi 18.99 19.74 txMySQL 45.19 43.80 (numbers from a previous version of this benchmark)

Postgres: Tornado Twisted adb 9.03 N/A adbapi 16.49 17.00


The new module running on top of Tornado is 40% faster than Twisted's adbapi. As a bonus, in this benchmark the memory usage of adb was 140MB versus the 300MB used by Twisted's adbapi.

When used with adisp, programming asynchronous database operations with adb and Tornado is a real breeze, since you no longer need to worry about creating callbacks to handle the results from the database.


The txMySQL implementation tested against is available in the main trunk at:


The Tornado-based reactor implementation used is available in the main trunk at:


Popular Mysql Projects
Popular Benchmark Projects
Popular Data Storage Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.