#SQL-Benchmark
A synthetic benchmark to compare the performance of various sql-drivers for Go's database/sql package
- Intel Core i5-2500K (3.30 GHz), 8 GB RAM
- MySQL 5.1, Windows 7 x64
- Current Go-MySQL-Driver and mymysql versions as of February 25, 2013
- Java7 (JDBC) + MySQL Connector/J 5.1.23 for comparision
- Please don't try to compare the benchmark sets (Query | QueryRow | Exec) to each other. They test different things. So you can't say QueryRow is faster than Query. In fact QueryRow is just a shortcut which uses Query internally. View the source to understand what we test here.
- The benchmarks are designed to minimize response latency from the server. We try to compare driver performance here and not to test the MySQL Server ;)
- The setup MySQL 5.1 + Windows isn't ideal. Maybe I'll setup a GNU/Linux + MariaDB 10.0 enviornment another time and run this again.
- This benchmark isn't concurrent while most production apps will be. You might get many more queries/second by running them concurrent. I'll add a test some time (feel free to contribute).
- The Go results tend to vary much more. Probably this is caused by the garbage collector.
- go version devel +646803253bb4 Tue Feb 26 09:51:33 2013
- reverted changeset ddb9e6365e57 because of Issue #4802
Benchmark | Go-MySQL-Driver | mymysql godrv | Java (JDBC) + MySQL Connector/J 5.1.23 |
---|---|---|---|
SimpleQuery | 3923 queries/second | 2189 queries/second | 5266 queries/second |
PreparedQuery | 3716 queries/second | 2505 queries/second | 6353 queries/second |
AutoQueryRow | 7748 queries/second | 6038 queries/second | - |
SimpleQueryRow | 15075 queries/second | 6302 queries/second | 14063 queries/second |
PreparedQueryRow | 15539 queries/second | 12780 queries/second | 14327 queries/second |
SimpleExec | 29238 queries/second | 10890 queries/second | 24231 queries/second |
PreparedExec | 30384 queries/second | 28041 queries/second | 25654 queries/second |
Benchmark | Go-MySQL-Driver | mymysql godrv | Java (JDBC) + MySQL Connector/J 5.1.23 |
---|---|---|---|
SimpleQuery | 2789 queries/second | 1762 queries/second | 5266 queries/second |
PreparedQuery | 3279 queries/second | 2015 queries/second | 6353 queries/second |
AutoQueryRow | 7622 queries/second | 5446 queries/second | - |
SimpleQueryRow | 7783 queries/second | 5746 queries/second | 14063 queries/second |
PreparedQueryRow | 15953 queries/second | 11139 queries/second | 14327 queries/second |
SimpleExec | 29332 queries/second | 10531 queries/second | 24231 queries/second |
PreparedExec | 30626 queries/second | 26873 queries/second | 25654 queries/second |
*************************************************************
BENCHMARKING Go-MySQL-Driver [run 1]
*************************************************************
-------------------------------------------------------------
[10000 * Query 100 Rows]
-------------------------------------------------------------
SimpleQuery: 2.5491458s [ 3923 queries/second ]
PreparedQuery: 2.6911539s [ 3716 queries/second ]
-------------------------------------------------------------
[100 * QueryRow] * 1000
-------------------------------------------------------------
AutoQueryRow: 12.9067382s [ 7748 queries/second ]
SimpleQueryRow: 6.6333794s [ 15075 queries/second ]
PreparedQueryRow: 6.435368s [ 15539 queries/second ]
-------------------------------------------------------------
[100000 * Exec]
-------------------------------------------------------------
SimpleExec: 3.4201956s [ 29238 queries/second ]
PreparedExec: 3.2911882s [ 30384 queries/second ]
*************************************************************
BENCHMARKING mymysql godrv [run 1]
*************************************************************
-------------------------------------------------------------
[10000 * Query 100 Rows]
-------------------------------------------------------------
SimpleQuery: 4.7472715s [ 2106 queries/second ]
PreparedQuery: 4.0132295s [ 2492 queries/second ]
-------------------------------------------------------------
[100 * QueryRow] * 1000
-------------------------------------------------------------
AutoQueryRow: 17.1259795s [ 5839 queries/second ]
SimpleQueryRow: 16.3869373s [ 6102 queries/second ]
PreparedQueryRow: 8.2984746s [ 12050 queries/second ]
-------------------------------------------------------------
[100000 * Exec]
-------------------------------------------------------------
SimpleExec: 9.5775478s [ 10441 queries/second ]
PreparedExec: 3.635208s [ 27509 queries/second ]
*************************************************************
BENCHMARKING Go-MySQL-Driver [run 2]
*************************************************************
-------------------------------------------------------------
[10000 * Query 100 Rows]
-------------------------------------------------------------
SimpleQuery: 2.7761588s [ 3602 queries/second ]
PreparedQuery: 2.8571634s [ 3500 queries/second ]
-------------------------------------------------------------
[100 * QueryRow] * 1000
-------------------------------------------------------------
AutoQueryRow: 13.1287509s [ 7617 queries/second ]
SimpleQueryRow: 6.9363968s [ 14417 queries/second ]
PreparedQueryRow: 6.5493746s [ 15269 queries/second ]
-------------------------------------------------------------
[100000 * Exec]
-------------------------------------------------------------
SimpleExec: 3.5402025s [ 28247 queries/second ]
PreparedExec: 3.3021889s [ 30283 queries/second ]
*************************************************************
BENCHMARKING mymysql godrv [run 2]
*************************************************************
-------------------------------------------------------------
[10000 * Query 100 Rows]
-------------------------------------------------------------
SimpleQuery: 4.5682613s [ 2189 queries/second ]
PreparedQuery: 3.9912283s [ 2505 queries/second ]
-------------------------------------------------------------
[100 * QueryRow] * 1000
-------------------------------------------------------------
AutoQueryRow: 16.5629474s [ 6038 queries/second ]
SimpleQueryRow: 15.8679076s [ 6302 queries/second ]
PreparedQueryRow: 7.8244476s [ 12780 queries/second ]
-------------------------------------------------------------
[100000 * Exec]
-------------------------------------------------------------
SimpleExec: 9.1825252s [ 10890 queries/second ]
PreparedExec: 3.566204s [ 28041 queries/second ]
*************************************************************
BENCHMARKING Go-MySQL-Driver [run 1]
*************************************************************
-------------------------------------------------------------
[10000 * Query 100 Rows]
-------------------------------------------------------------
SimpleQuery: 3.6292076s [ 2755 queries/second ]
PreparedQuery: 3.1391796s [ 3186 queries/second ]
-------------------------------------------------------------
[100 * QueryRow] * 1000
-------------------------------------------------------------
AutoQueryRow: 13.1207505s [ 7622 queries/second ]
SimpleQueryRow: 12.8477349s [ 7783 queries/second ]
PreparedQueryRow: 6.2683586s [ 15953 queries/second ]
-------------------------------------------------------------
[100000 * Exec]
-------------------------------------------------------------
SimpleExec: 3.409195s [ 29332 queries/second ]
PreparedExec: 3.2651867s [ 30626 queries/second ]
*************************************************************
BENCHMARKING mymysql godrv [run 1]
*************************************************************
-------------------------------------------------------------
[10000 * Query 100 Rows]
-------------------------------------------------------------
SimpleQuery: 5.7593294s [ 1736 queries/second ]
PreparedQuery: 4.9632839s [ 2015 queries/second ]
-------------------------------------------------------------
[100 * QueryRow] * 1000
-------------------------------------------------------------
AutoQueryRow: 18.9370832s [ 5281 queries/second ]
SimpleQueryRow: 17.6690106s [ 5660 queries/second ]
PreparedQueryRow: 9.2945316s [ 10759 queries/second ]
-------------------------------------------------------------
[100000 * Exec]
-------------------------------------------------------------
SimpleExec: 9.6345511s [ 10379 queries/second ]
PreparedExec: 3.7902168s [ 26384 queries/second ]
*************************************************************
BENCHMARKING Go-MySQL-Driver [run 2]
*************************************************************
-------------------------------------------------------------
[10000 * Query 100 Rows]
-------------------------------------------------------------
SimpleQuery: 3.585205s [ 2789 queries/second ]
PreparedQuery: 3.0501745s [ 3279 queries/second ]
-------------------------------------------------------------
[100 * QueryRow] * 1000
-------------------------------------------------------------
AutoQueryRow: 13.3307625s [ 7501 queries/second ]
SimpleQueryRow: 13.0667473s [ 7653 queries/second ]
PreparedQueryRow: 6.5433743s [ 15283 queries/second ]
-------------------------------------------------------------
[100000 * Exec]
-------------------------------------------------------------
SimpleExec: 3.4541975s [ 28950 queries/second ]
PreparedExec: 3.3351908s [ 29983 queries/second ]
*************************************************************
BENCHMARKING mymysql godrv [run 2]
*************************************************************
-------------------------------------------------------------
[10000 * Query 100 Rows]
-------------------------------------------------------------
SimpleQuery: 5.6753246s [ 1762 queries/second ]
PreparedQuery: 4.9732845s [ 2011 queries/second ]
-------------------------------------------------------------
[100 * QueryRow] * 1000
-------------------------------------------------------------
AutoQueryRow: 18.3610502s [ 5446 queries/second ]
SimpleQueryRow: 17.4029953s [ 5746 queries/second ]
PreparedQueryRow: 8.9775135s [ 11139 queries/second ]
-------------------------------------------------------------
[100000 * Exec]
-------------------------------------------------------------
SimpleExec: 9.4955431s [ 10531 queries/second ]
PreparedExec: 3.7212129s [ 26873 queries/second ]
Same machine, Java (JDK7 / 64 bit) + MySQL Connector/J 5.1.23
-------------------------------------------------------------
[10000 * Query 100 Rows]
-------------------------------------------------------------
SimpleQuery: 1.899s [ 5266 queries/second ]
PreparedQuery: 1.574s [ 6353 queries/second ]
-------------------------------------------------------------
[100 * QueryRow] * 1000
-------------------------------------------------------------
SimpleQueryRow: 7.111s [ 14063 queries/second ]
PreparedQueryRow: 6.98s [ 14327 queries/second ]
-------------------------------------------------------------
[100000 * Exec]
-------------------------------------------------------------
SimpleExec: 4.127s [ 24231 queries/second ]
PreparedExec: 3.898s [ 25654 queries/second ]