├── java ├── SQLBenchmark.class ├── run.bat ├── mysql-connector-java-5.1.26 │ ├── mysql-connector-java-5.1.26-bin.jar │ └── COPYING └── SQLBenchmark.java ├── main.go ├── framework └── suite.go ├── benchmarks.go ├── results ├── results_2013-02-26.md ├── results_2013-03-02.md ├── results-linux_2013-03-19.md └── results-osx_2013-03-19.md └── README.md /java/SQLBenchmark.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sql-driver/sql-benchmark/HEAD/java/SQLBenchmark.class -------------------------------------------------------------------------------- /java/run.bat: -------------------------------------------------------------------------------- 1 | java -cp .\mysql-connector-java-5.1.26\mysql-connector-java-5.1.26-bin.jar;. SQLBenchmark 1>bench.log 2>&1 -------------------------------------------------------------------------------- /java/mysql-connector-java-5.1.26/mysql-connector-java-5.1.26-bin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sql-driver/sql-benchmark/HEAD/java/mysql-connector-java-5.1.26/mysql-connector-java-5.1.26-bin.jar -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "./framework" 5 | "database/sql" 6 | "fmt" 7 | _ "github.com/go-sql-driver/mysql" 8 | _ "github.com/ziutek/mymysql/godrv" 9 | ) 10 | 11 | func warmup(db *sql.DB) error { 12 | db.SetMaxIdleConns(16) 13 | 14 | for i := 0; i < 100000; i++ { 15 | rows, err := db.Query("SELECT \"Hello Gophers!\"") 16 | if err != nil { 17 | return err 18 | } 19 | 20 | if err = rows.Close(); err != nil { 21 | return err 22 | } 23 | } 24 | return nil 25 | } 26 | 27 | func main() { 28 | var err error 29 | 30 | bs := framework.BenchmarkSuite{ 31 | WarmUp: warmup, 32 | Repetitions: 3, 33 | PrintStats: true, 34 | } 35 | 36 | if err = bs.AddDriver("mymysql godrv", "mymysql", "/root/root"); err != nil { 37 | fmt.Println(err) 38 | return 39 | } 40 | if err = bs.AddDriver("Go-MySQL-Driver", "mysql", "root:root@/"); err != nil { 41 | fmt.Println(err) 42 | return 43 | } 44 | 45 | bs.AddBenchmark("SimpleExec", 250000, bmSimpleExec) 46 | bs.AddBenchmark("PreparedExec", 250000, bmPreparedExec) 47 | bs.AddBenchmark("SimpleQueryRow", 250000, bmSimpleQueryRow) 48 | bs.AddBenchmark("PreparedQueryRow", 250000, bmPreparedQueryRow) 49 | bs.AddBenchmark("PreparedQueryRowParam", 250000, bmPreparedQueryRowParam) 50 | bs.AddBenchmark("EchoMixed5", 250000, bmEchoMixed5) 51 | bs.AddBenchmark("SelectLargeString", 50000, bmSelectLargeString) 52 | bs.AddBenchmark("SelectPreparedLargeString", 50000, bmSelectPreparedLargeString) 53 | bs.AddBenchmark("SelectLargeBytes", 50000, bmSelectLargeBytes) 54 | bs.AddBenchmark("SelectPreparedLargeBytes", 50000, bmSelectPreparedLargeBytes) 55 | bs.AddBenchmark("SelectLargeRaw", 50000, bmSelectLargeRaw) 56 | bs.AddBenchmark("SelectPreparedLargeRaw", 50000, bmSelectPreparedLargeRaw) 57 | bs.AddBenchmark("PreparedExecConcurrent1", 500000, bmPreparedExecConcurrent1) 58 | bs.AddBenchmark("PreparedExecConcurrent2", 500000, bmPreparedExecConcurrent2) 59 | bs.AddBenchmark("PreparedExecConcurrent4", 500000, bmPreparedExecConcurrent4) 60 | bs.AddBenchmark("PreparedExecConcurrent8", 500000, bmPreparedExecConcurrent8) 61 | bs.AddBenchmark("PreparedExecConcurrent16", 500000, bmPreparedExecConcurrent16) 62 | bs.AddBenchmark("PreparedQueryConcurrent1", 500000, bmPreparedQueryConcurrent1) 63 | bs.AddBenchmark("PreparedQueryConcurrent2", 500000, bmPreparedQueryConcurrent2) 64 | bs.AddBenchmark("PreparedQueryConcurrent4", 500000, bmPreparedQueryConcurrent4) 65 | bs.AddBenchmark("PreparedQueryConcurrent8", 500000, bmPreparedQueryConcurrent8) 66 | bs.AddBenchmark("PreparedQueryConcurrent16", 500000, bmPreparedQueryConcurrent16) 67 | 68 | bs.Run() 69 | } 70 | -------------------------------------------------------------------------------- /framework/suite.go: -------------------------------------------------------------------------------- 1 | package framework 2 | 3 | import ( 4 | "database/sql" 5 | "fmt" 6 | "runtime" 7 | "sort" 8 | "time" 9 | ) 10 | 11 | type driver struct { 12 | name string 13 | db *sql.DB 14 | } 15 | 16 | type Result struct { 17 | Err error 18 | Queries int 19 | Duration time.Duration 20 | Allocs uint64 21 | Bytes uint64 22 | } 23 | 24 | func (res *Result) QueriesPerSecond() float64 { 25 | return float64(res.Queries) / res.Duration.Seconds() 26 | } 27 | 28 | func (res *Result) AllocsPerQuery() int { 29 | return int(res.Allocs) / res.Queries 30 | } 31 | 32 | func (res *Result) BytesPerQuery() int { 33 | return int(res.Bytes) / res.Queries 34 | } 35 | 36 | var memStats runtime.MemStats 37 | 38 | type benchmark struct { 39 | name string 40 | n int 41 | bm func(*sql.DB, int) error 42 | } 43 | 44 | func (b *benchmark) run(db *sql.DB) Result { 45 | runtime.GC() 46 | 47 | runtime.ReadMemStats(&memStats) 48 | var ( 49 | startMallocs = memStats.Mallocs 50 | startTotalAlloc = memStats.TotalAlloc 51 | startTime = time.Now() 52 | ) 53 | 54 | err := b.bm(db, b.n) 55 | 56 | endTime := time.Now() 57 | runtime.ReadMemStats(&memStats) 58 | 59 | return Result{ 60 | Err: err, 61 | Queries: b.n, 62 | Duration: endTime.Sub(startTime), 63 | Allocs: memStats.Mallocs - startMallocs, 64 | Bytes: memStats.TotalAlloc - startTotalAlloc, 65 | } 66 | } 67 | 68 | type BenchmarkSuite struct { 69 | drivers []driver 70 | benchmarks []benchmark 71 | WarmUp func(*sql.DB) error 72 | Repetitions int 73 | PrintStats bool 74 | } 75 | 76 | func (bs *BenchmarkSuite) AddDriver(name, drv, dsn string) error { 77 | db, err := sql.Open(drv, dsn) 78 | if err != nil { 79 | return fmt.Errorf("Error registering driver '%s': %s", name, err.Error()) 80 | } 81 | 82 | if err = db.Ping(); err != nil { 83 | return fmt.Errorf("Error on driver '%s': %s", name, err.Error()) 84 | } 85 | 86 | bs.drivers = append(bs.drivers, driver{ 87 | name: name, 88 | db: db, 89 | }) 90 | return nil 91 | } 92 | 93 | func (bs *BenchmarkSuite) AddBenchmark(name string, n int, bm func(*sql.DB, int) error) { 94 | bs.benchmarks = append(bs.benchmarks, benchmark{ 95 | name: name, 96 | n: n, 97 | bm: bm, 98 | }) 99 | } 100 | 101 | func (bs *BenchmarkSuite) Run() { 102 | startTime := time.Now() 103 | 104 | if len(bs.drivers) < 1 { 105 | fmt.Println("No drivers registered to run benchmarks with!") 106 | return 107 | } 108 | 109 | if len(bs.benchmarks) < 1 { 110 | fmt.Println("No benchmark functions registered!") 111 | return 112 | } 113 | 114 | if bs.WarmUp != nil { 115 | for _, driver := range bs.drivers { 116 | fmt.Println("Warming up " + driver.name + "...") 117 | if err := bs.WarmUp(driver.db); err != nil { 118 | fmt.Println(err.Error()) 119 | return 120 | } 121 | } 122 | fmt.Println() 123 | } 124 | 125 | fmt.Println("Run Benchmarks...") 126 | fmt.Println() 127 | 128 | var qps []float64 129 | if bs.Repetitions > 1 && bs.PrintStats { 130 | qps = make([]float64, bs.Repetitions) 131 | } else { 132 | bs.PrintStats = false 133 | } 134 | 135 | for _, benchmark := range bs.benchmarks { 136 | fmt.Println(benchmark.name, benchmark.n, "iterations") 137 | for _, driver := range bs.drivers { 138 | fmt.Println(driver.name) 139 | for i := 0; i < bs.Repetitions; i++ { 140 | res := benchmark.run(driver.db) 141 | if res.Err != nil { 142 | fmt.Println(res.Err.Error()) 143 | } else { 144 | fmt.Println( 145 | " " + 146 | res.Duration.String(), "\t ", 147 | int(res.QueriesPerSecond()+0.5), "queries/sec\t ", 148 | res.AllocsPerQuery(), "allocs/query\t ", 149 | res.BytesPerQuery(), "B/query", 150 | ) 151 | if bs.Repetitions > 1 { 152 | qps[i] = res.QueriesPerSecond() 153 | } 154 | } 155 | } 156 | 157 | if bs.PrintStats { 158 | var totalQps float64 159 | for i := range qps { 160 | totalQps += qps[i] 161 | } 162 | 163 | sort.Float64s(qps) 164 | 165 | fmt.Println( 166 | " -- " + 167 | "avg", int(totalQps/float64(len(qps)) +0.5), "qps; "+ 168 | "median", int(qps[len(qps)/2]+0.5), "qps", 169 | ) 170 | } 171 | } 172 | 173 | fmt.Println() 174 | } 175 | endTime := time.Now() 176 | fmt.Println("Finished... Total running time:", endTime.Sub(startTime).String()) 177 | } 178 | -------------------------------------------------------------------------------- /benchmarks.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "database/sql" 5 | "sync" 6 | "sync/atomic" 7 | ) 8 | 9 | func bmSimpleExec(db *sql.DB, n int) error { 10 | for i := 0; i < n; i++ { 11 | if _, err := db.Exec("DO 1"); err != nil { 12 | return err 13 | } 14 | } 15 | return nil 16 | } 17 | 18 | func bmPreparedExec(db *sql.DB, n int) error { 19 | stmt, err := db.Prepare("DO 1") 20 | if err != nil { 21 | return err 22 | } 23 | 24 | for i := 0; i < n; i++ { 25 | if _, err := stmt.Exec(); err != nil { 26 | return err 27 | } 28 | } 29 | 30 | return stmt.Close() 31 | } 32 | 33 | func bmSimpleQueryRow(db *sql.DB, n int) error { 34 | var num int 35 | 36 | for i := 0; i < n; i++ { 37 | if err := db.QueryRow("SELECT 1").Scan(&num); err != nil { 38 | return err 39 | } 40 | } 41 | return nil 42 | } 43 | 44 | func bmPreparedQueryRow(db *sql.DB, n int) error { 45 | var num int 46 | 47 | stmt, err := db.Prepare("SELECT 1") 48 | if err != nil { 49 | return err 50 | } 51 | 52 | for i := 0; i < n; i++ { 53 | if err := stmt.QueryRow().Scan(&num); err != nil { 54 | return err 55 | } 56 | } 57 | 58 | return stmt.Close() 59 | } 60 | 61 | func bmPreparedQueryRowParam(db *sql.DB, n int) error { 62 | var num int 63 | 64 | stmt, err := db.Prepare("SELECT ?") 65 | if err != nil { 66 | return err 67 | } 68 | 69 | for i := 0; i < n; i++ { 70 | if err := stmt.QueryRow(i).Scan(&num); err != nil { 71 | return err 72 | } 73 | } 74 | 75 | return stmt.Close() 76 | } 77 | 78 | func bmEchoMixed5(db *sql.DB, n int) error { 79 | stmt, err := db.Prepare("SELECT ?, ?, ?, ?, ?") 80 | if err != nil { 81 | return err 82 | } 83 | defer stmt.Close() 84 | 85 | // Some random data with different types 86 | type entry struct { 87 | id int64 88 | name string 89 | ratio float64 90 | other interface{} 91 | hire bool 92 | } 93 | 94 | in := entry{ 95 | id: 42, 96 | name: "Gopher", 97 | ratio: 1.618, 98 | other: nil, 99 | hire: true, 100 | } 101 | 102 | var out entry 103 | 104 | for i := 0; i < n; i++ { 105 | if err := stmt.QueryRow( 106 | in.id, 107 | in.name, 108 | in.ratio, 109 | in.other, 110 | in.hire, 111 | ).Scan( 112 | &out.id, 113 | &out.name, 114 | &out.ratio, 115 | &out.other, 116 | &out.hire, 117 | ); err != nil { 118 | return err 119 | } 120 | } 121 | return nil 122 | } 123 | 124 | func bmSelectLargeString(db *sql.DB, n int) error { 125 | var str string 126 | for i := 0; i < n; i++ { 127 | if err := db.QueryRow("SELECT REPEAT('A', 10000)").Scan(&str); err != nil { 128 | return err 129 | } 130 | } 131 | return nil 132 | } 133 | 134 | func bmSelectPreparedLargeString(db *sql.DB, n int) error { 135 | stmt, err := db.Prepare("SELECT REPEAT('A', 10000)") 136 | if err != nil { 137 | return err 138 | } 139 | defer stmt.Close() 140 | 141 | var str string 142 | for i := 0; i < n; i++ { 143 | if err := stmt.QueryRow().Scan(&str); err != nil { 144 | return err 145 | } 146 | } 147 | return nil 148 | } 149 | 150 | func bmSelectLargeBytes(db *sql.DB, n int) error { 151 | var raw []byte 152 | for i := 0; i < n; i++ { 153 | if err := db.QueryRow("SELECT REPEAT('A', 10000)").Scan(&raw); err != nil { 154 | return err 155 | } 156 | } 157 | return nil 158 | } 159 | 160 | func bmSelectPreparedLargeBytes(db *sql.DB, n int) error { 161 | stmt, err := db.Prepare("SELECT REPEAT('A', 10000)") 162 | if err != nil { 163 | return err 164 | } 165 | defer stmt.Close() 166 | 167 | var raw []byte 168 | for i := 0; i < n; i++ { 169 | if err := stmt.QueryRow().Scan(&raw); err != nil { 170 | return err 171 | } 172 | } 173 | return nil 174 | } 175 | 176 | func bmSelectLargeRaw(db *sql.DB, n int) error { 177 | var raw sql.RawBytes 178 | for i := 0; i < n; i++ { 179 | rows, err := db.Query("SELECT REPEAT('A', 10000)") 180 | if err != nil { 181 | return err 182 | } 183 | 184 | if !rows.Next() { 185 | return sql.ErrNoRows 186 | } 187 | 188 | if err = rows.Scan(&raw); err != nil { 189 | return err 190 | } 191 | 192 | if err = rows.Close(); err != nil { 193 | return err 194 | } 195 | } 196 | return nil 197 | } 198 | 199 | func bmSelectPreparedLargeRaw(db *sql.DB, n int) error { 200 | stmt, err := db.Prepare("SELECT REPEAT('A', 10000)") 201 | if err != nil { 202 | return err 203 | } 204 | defer stmt.Close() 205 | 206 | var raw sql.RawBytes 207 | for i := 0; i < n; i++ { 208 | rows, err := stmt.Query() 209 | if err != nil { 210 | return err 211 | } 212 | 213 | if !rows.Next() { 214 | return sql.ErrNoRows 215 | } 216 | 217 | if err = rows.Scan(&raw); err != nil { 218 | return err 219 | } 220 | 221 | if err = rows.Close(); err != nil { 222 | return err 223 | } 224 | } 225 | return nil 226 | } 227 | 228 | func runPreparedExecConcurrent(db *sql.DB, n int, co int) error { 229 | stmt, err := db.Prepare("DO 1") 230 | if err != nil { 231 | return err 232 | } 233 | 234 | remain := int64(n) 235 | var wg sync.WaitGroup 236 | wg.Add(co) 237 | 238 | for i := 0; i < co; i++ { 239 | go func() { 240 | for { 241 | if atomic.AddInt64(&remain, -1) < 0 { 242 | wg.Done() 243 | return 244 | } 245 | 246 | if _, err1 := stmt.Exec(); err1 != nil { 247 | wg.Done() 248 | err = err1 249 | return 250 | } 251 | } 252 | }() 253 | } 254 | wg.Wait() 255 | stmt.Close() 256 | return err 257 | } 258 | 259 | func bmPreparedExecConcurrent1(db *sql.DB, n int) error { 260 | return runPreparedExecConcurrent(db, n, 1) 261 | } 262 | 263 | func bmPreparedExecConcurrent2(db *sql.DB, n int) error { 264 | return runPreparedExecConcurrent(db, n, 2) 265 | } 266 | 267 | func bmPreparedExecConcurrent4(db *sql.DB, n int) error { 268 | return runPreparedExecConcurrent(db, n, 4) 269 | } 270 | 271 | func bmPreparedExecConcurrent8(db *sql.DB, n int) error { 272 | return runPreparedExecConcurrent(db, n, 8) 273 | } 274 | 275 | func bmPreparedExecConcurrent16(db *sql.DB, n int) error { 276 | return runPreparedExecConcurrent(db, n, 16) 277 | } 278 | 279 | func runPreparedQueryConcurrent(db *sql.DB, n int, co int) error { 280 | stmt, err := db.Prepare("SELECT ?, \"foobar\"") 281 | if err != nil { 282 | return err 283 | } 284 | 285 | remain := int64(n) 286 | var wg sync.WaitGroup 287 | wg.Add(co) 288 | 289 | for i := 0; i < co; i++ { 290 | go func(i int) { 291 | var id int 292 | var str string 293 | for { 294 | if atomic.AddInt64(&remain, -1) < 0 { 295 | wg.Done() 296 | return 297 | } 298 | 299 | if err1 := stmt.QueryRow(i).Scan(&id, &str); err1 != nil { 300 | wg.Done() 301 | err = err1 302 | return 303 | } 304 | } 305 | }(i) 306 | } 307 | wg.Wait() 308 | stmt.Close() 309 | return err 310 | } 311 | 312 | func bmPreparedQueryConcurrent1(db *sql.DB, n int) error { 313 | return runPreparedQueryConcurrent(db, n, 1) 314 | } 315 | 316 | func bmPreparedQueryConcurrent2(db *sql.DB, n int) error { 317 | return runPreparedQueryConcurrent(db, n, 2) 318 | } 319 | 320 | func bmPreparedQueryConcurrent4(db *sql.DB, n int) error { 321 | return runPreparedQueryConcurrent(db, n, 4) 322 | } 323 | 324 | func bmPreparedQueryConcurrent8(db *sql.DB, n int) error { 325 | return runPreparedQueryConcurrent(db, n, 8) 326 | } 327 | 328 | func bmPreparedQueryConcurrent16(db *sql.DB, n int) error { 329 | return runPreparedQueryConcurrent(db, n, 16) 330 | } 331 | -------------------------------------------------------------------------------- /java/SQLBenchmark.java: -------------------------------------------------------------------------------- 1 | import java.sql.Connection; 2 | import java.sql.DriverManager; 3 | import java.sql.PreparedStatement; 4 | import java.sql.ResultSet; 5 | import java.sql.SQLException; 6 | import java.sql.Statement; 7 | 8 | /** 9 | * 10 | * @author Julien Schmidt 11 | */ 12 | public class SQLBenchmark { 13 | 14 | private static void printResult(String name, long ms, long bytes, int i) { 15 | System.out.println( 16 | name + ": " + 17 | (ms / 1000.0) + "s \t " + 18 | Math.round(1000.0 * i / ms) + " queries/second \t" 19 | /* Does someone know how to get useable values? 20 | * If yes, please make a pull-request to fix this! */ 21 | //(bytes/i) + " B/query" 22 | ); 23 | } 24 | 25 | /** 26 | * @param args the command line arguments 27 | */ 28 | public static void main(String[] args) { 29 | try { 30 | Class.forName("com.mysql.jdbc.Driver").newInstance(); 31 | } catch (Exception ex) { 32 | System.err.println("Loading MySQL-Driver failed!"); 33 | } 34 | 35 | Connection conn = null; 36 | try { 37 | conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/gotest?user=root&password=root"); 38 | } catch (SQLException ex) { 39 | if(conn != null) { 40 | try { 41 | conn.close(); 42 | } catch(Exception iDontCare) { 43 | } finally { 44 | conn = null; 45 | } 46 | } 47 | System.out.println("SQLException: " + ex.getMessage()); 48 | System.out.println("SQLState: " + ex.getSQLState()); 49 | System.out.println("VendorError: " + ex.getErrorCode()); 50 | System.exit(1); 51 | } 52 | 53 | Statement stmt = null; 54 | ResultSet rs = null; 55 | 56 | Runtime runtime = Runtime.getRuntime(); 57 | 58 | try { 59 | long startTime, endTime; 60 | long startTotalMem; 61 | PreparedStatement pStmt; 62 | 63 | int num; 64 | 65 | stmt = conn.createStatement(); 66 | stmt.setPoolable(true); 67 | 68 | // SimpleExec 69 | startTotalMem = runtime.totalMemory()-runtime.freeMemory(); 70 | startTime = System.currentTimeMillis(); 71 | for(int i = 0; i < 500000; i++) { 72 | stmt.execute("DO 1"); 73 | } 74 | endTime = System.currentTimeMillis(); 75 | SQLBenchmark.printResult( 76 | "SimpleExec", 77 | (endTime-startTime), 78 | (runtime.totalMemory()-runtime.freeMemory()-startTotalMem), 79 | 500000 80 | ); 81 | 82 | // PreparedExec 83 | startTotalMem = runtime.totalMemory()-runtime.freeMemory(); 84 | startTime = System.currentTimeMillis(); 85 | pStmt = conn.prepareStatement("DO 1"); 86 | for(int i = 0; i < 500000; i++) { 87 | pStmt.execute(); 88 | } 89 | pStmt.close(); 90 | endTime = System.currentTimeMillis(); 91 | SQLBenchmark.printResult( 92 | "PreparedExec", 93 | (endTime-startTime), 94 | (runtime.totalMemory()-runtime.freeMemory()-startTotalMem), 95 | 500000 96 | ); 97 | 98 | // SimpleQueryRow 99 | startTotalMem = runtime.totalMemory()-runtime.freeMemory(); 100 | startTime = System.currentTimeMillis(); 101 | for(int i = 0; i < 500000; i++) { 102 | if (stmt.execute("SELECT 1")) { 103 | rs = stmt.getResultSet(); 104 | 105 | if(rs.next()) { 106 | num = rs.getInt(1); 107 | } else { 108 | throw new Exception("No result"); 109 | } 110 | } else { 111 | throw new Exception("No result"); 112 | } 113 | } 114 | endTime = System.currentTimeMillis(); 115 | SQLBenchmark.printResult( 116 | "SimpleQueryRow", 117 | (endTime-startTime), 118 | (runtime.totalMemory()-runtime.freeMemory()-startTotalMem), 119 | 500000 120 | ); 121 | 122 | // PreparedQueryRow 123 | startTotalMem = runtime.totalMemory()-runtime.freeMemory(); 124 | startTime = System.currentTimeMillis(); 125 | pStmt = conn.prepareStatement("SELECT 1"); 126 | for(int i = 0; i < 500000; i++) { 127 | if (pStmt.execute()) { 128 | rs = pStmt.getResultSet(); 129 | 130 | if(rs.next()) { 131 | num = rs.getInt(1); 132 | } else { 133 | throw new Exception("No result"); 134 | } 135 | } else { 136 | throw new Exception("No result"); 137 | } 138 | } 139 | pStmt.close(); 140 | endTime = System.currentTimeMillis(); 141 | SQLBenchmark.printResult( 142 | "PreparedQueryRow", 143 | (endTime-startTime), 144 | (runtime.totalMemory()-runtime.freeMemory()-startTotalMem), 145 | 500000 146 | ); 147 | 148 | // PreparedQueryRowParam 149 | startTotalMem = runtime.totalMemory()-runtime.freeMemory(); 150 | startTime = System.currentTimeMillis(); 151 | pStmt = conn.prepareStatement("SELECT ?"); 152 | for(int i = 0; i < 500000; i++) { 153 | pStmt.setInt(1, i); 154 | if (pStmt.execute()) { 155 | rs = pStmt.getResultSet(); 156 | 157 | if(rs.next()) { 158 | num = rs.getInt(1); 159 | } else { 160 | throw new Exception("No result"); 161 | } 162 | } else { 163 | throw new Exception("No result"); 164 | } 165 | } 166 | pStmt.close(); 167 | endTime = System.currentTimeMillis(); 168 | SQLBenchmark.printResult( 169 | "PreparedQueryRowParam", 170 | (endTime-startTime), 171 | (runtime.totalMemory()-runtime.freeMemory()-startTotalMem), 172 | 500000 173 | ); 174 | 175 | } catch (Exception e) { 176 | System.err.println(e); 177 | } finally { 178 | if (rs != null) { 179 | try { 180 | rs.close(); 181 | } catch (SQLException iDontCare) { 182 | } finally { 183 | rs = null; 184 | } 185 | } 186 | 187 | if (stmt != null) { 188 | try { 189 | stmt.close(); 190 | } catch (SQLException iDontCare) { 191 | } finally { 192 | stmt = null; 193 | } 194 | } 195 | 196 | try { 197 | conn.close(); 198 | } catch(Exception iDontCare) { 199 | } finally { 200 | conn = null; 201 | } 202 | } 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /results/results_2013-02-26.md: -------------------------------------------------------------------------------- 1 | #SQL-Benchmark 2 | 3 | A synthetic benchmark to compare the performance of various sql-drivers for Go's database/sql package 4 | 5 | ## Results 6 | ### Setup 7 | * Intel Core i5-2500K (3.30 GHz), 8 GB RAM 8 | * MySQL 5.1, Windows 7 x64 9 | * Current [Go-MySQL-Driver](https://github.com/go-sql-driver/mysql) and [mymysql](https://github.com/ziutek/mymysql) versions as of February 25, 2013 10 | * Java7 (JDBC) + MySQL Connector/J 5.1.23 for comparision 11 | 12 | ### Notes 13 | * 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. 14 | * 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 ;) 15 | * 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. 16 | * 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). 17 | * The Go results tend to vary much more. Probably this is caused by the garbage collector. 18 | 19 | ### Go tip 20 | * go version devel +646803253bb4 Tue Feb 26 09:51:33 2013 21 | * reverted [changeset ddb9e6365e57](http://code.google.com/p/go/source/detail?r=ddb9e6365e570c2619d88427176a465e8b76b4aa) because of [Issue #4802](http://golang.org/issue/4902) 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 |
BenchmarkGo-MySQL-Drivermymysql godrvJava (JDBC) + MySQL Connector/J 5.1.23
SimpleQuery3923 queries/second2189 queries/second5266 queries/second
PreparedQuery3716 queries/second2505 queries/second6353 queries/second
AutoQueryRow7748 queries/second6038 queries/second -
SimpleQueryRow15075 queries/second6302 queries/second14063 queries/second
PreparedQueryRow15539 queries/second12780 queries/second14327 queries/second
SimpleExec29238 queries/second10890 queries/second24231 queries/second
PreparedExec30384 queries/second28041 queries/second25654 queries/second
73 | 74 | ### Go1.0.3 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 |
BenchmarkGo-MySQL-Drivermymysql godrvJava (JDBC) + MySQL Connector/J 5.1.23
SimpleQuery2789 queries/second1762 queries/second5266 queries/second
PreparedQuery3279 queries/second2015 queries/second6353 queries/second
AutoQueryRow7622 queries/second5446 queries/second -
SimpleQueryRow7783 queries/second5746 queries/second14063 queries/second
PreparedQueryRow15953 queries/second11139 queries/second14327 queries/second
SimpleExec29332 queries/second10531 queries/second24231 queries/second
PreparedExec30626 queries/second26873 queries/second25654 queries/second
125 | 126 | ### Original Logs 127 | #### Go tip 128 | 129 | ``` 130 | ************************************************************* 131 | BENCHMARKING Go-MySQL-Driver [run 1] 132 | ************************************************************* 133 | 134 | ------------------------------------------------------------- 135 | [10000 * Query 100 Rows] 136 | ------------------------------------------------------------- 137 | SimpleQuery: 2.5491458s [ 3923 queries/second ] 138 | PreparedQuery: 2.6911539s [ 3716 queries/second ] 139 | 140 | ------------------------------------------------------------- 141 | [100 * QueryRow] * 1000 142 | ------------------------------------------------------------- 143 | AutoQueryRow: 12.9067382s [ 7748 queries/second ] 144 | SimpleQueryRow: 6.6333794s [ 15075 queries/second ] 145 | PreparedQueryRow: 6.435368s [ 15539 queries/second ] 146 | 147 | ------------------------------------------------------------- 148 | [100000 * Exec] 149 | ------------------------------------------------------------- 150 | SimpleExec: 3.4201956s [ 29238 queries/second ] 151 | PreparedExec: 3.2911882s [ 30384 queries/second ] 152 | 153 | 154 | ************************************************************* 155 | BENCHMARKING mymysql godrv [run 1] 156 | ************************************************************* 157 | 158 | ------------------------------------------------------------- 159 | [10000 * Query 100 Rows] 160 | ------------------------------------------------------------- 161 | SimpleQuery: 4.7472715s [ 2106 queries/second ] 162 | PreparedQuery: 4.0132295s [ 2492 queries/second ] 163 | 164 | ------------------------------------------------------------- 165 | [100 * QueryRow] * 1000 166 | ------------------------------------------------------------- 167 | AutoQueryRow: 17.1259795s [ 5839 queries/second ] 168 | SimpleQueryRow: 16.3869373s [ 6102 queries/second ] 169 | PreparedQueryRow: 8.2984746s [ 12050 queries/second ] 170 | 171 | ------------------------------------------------------------- 172 | [100000 * Exec] 173 | ------------------------------------------------------------- 174 | SimpleExec: 9.5775478s [ 10441 queries/second ] 175 | PreparedExec: 3.635208s [ 27509 queries/second ] 176 | 177 | 178 | ************************************************************* 179 | BENCHMARKING Go-MySQL-Driver [run 2] 180 | ************************************************************* 181 | 182 | ------------------------------------------------------------- 183 | [10000 * Query 100 Rows] 184 | ------------------------------------------------------------- 185 | SimpleQuery: 2.7761588s [ 3602 queries/second ] 186 | PreparedQuery: 2.8571634s [ 3500 queries/second ] 187 | 188 | ------------------------------------------------------------- 189 | [100 * QueryRow] * 1000 190 | ------------------------------------------------------------- 191 | AutoQueryRow: 13.1287509s [ 7617 queries/second ] 192 | SimpleQueryRow: 6.9363968s [ 14417 queries/second ] 193 | PreparedQueryRow: 6.5493746s [ 15269 queries/second ] 194 | 195 | ------------------------------------------------------------- 196 | [100000 * Exec] 197 | ------------------------------------------------------------- 198 | SimpleExec: 3.5402025s [ 28247 queries/second ] 199 | PreparedExec: 3.3021889s [ 30283 queries/second ] 200 | 201 | 202 | ************************************************************* 203 | BENCHMARKING mymysql godrv [run 2] 204 | ************************************************************* 205 | 206 | ------------------------------------------------------------- 207 | [10000 * Query 100 Rows] 208 | ------------------------------------------------------------- 209 | SimpleQuery: 4.5682613s [ 2189 queries/second ] 210 | PreparedQuery: 3.9912283s [ 2505 queries/second ] 211 | 212 | ------------------------------------------------------------- 213 | [100 * QueryRow] * 1000 214 | ------------------------------------------------------------- 215 | AutoQueryRow: 16.5629474s [ 6038 queries/second ] 216 | SimpleQueryRow: 15.8679076s [ 6302 queries/second ] 217 | PreparedQueryRow: 7.8244476s [ 12780 queries/second ] 218 | 219 | ------------------------------------------------------------- 220 | [100000 * Exec] 221 | ------------------------------------------------------------- 222 | SimpleExec: 9.1825252s [ 10890 queries/second ] 223 | PreparedExec: 3.566204s [ 28041 queries/second ] 224 | 225 | 226 | ``` 227 | 228 | 229 | #### Go1.0.3 230 | 231 | ``` 232 | ************************************************************* 233 | BENCHMARKING Go-MySQL-Driver [run 1] 234 | ************************************************************* 235 | 236 | ------------------------------------------------------------- 237 | [10000 * Query 100 Rows] 238 | ------------------------------------------------------------- 239 | SimpleQuery: 3.6292076s [ 2755 queries/second ] 240 | PreparedQuery: 3.1391796s [ 3186 queries/second ] 241 | 242 | ------------------------------------------------------------- 243 | [100 * QueryRow] * 1000 244 | ------------------------------------------------------------- 245 | AutoQueryRow: 13.1207505s [ 7622 queries/second ] 246 | SimpleQueryRow: 12.8477349s [ 7783 queries/second ] 247 | PreparedQueryRow: 6.2683586s [ 15953 queries/second ] 248 | 249 | ------------------------------------------------------------- 250 | [100000 * Exec] 251 | ------------------------------------------------------------- 252 | SimpleExec: 3.409195s [ 29332 queries/second ] 253 | PreparedExec: 3.2651867s [ 30626 queries/second ] 254 | 255 | 256 | ************************************************************* 257 | BENCHMARKING mymysql godrv [run 1] 258 | ************************************************************* 259 | 260 | ------------------------------------------------------------- 261 | [10000 * Query 100 Rows] 262 | ------------------------------------------------------------- 263 | SimpleQuery: 5.7593294s [ 1736 queries/second ] 264 | PreparedQuery: 4.9632839s [ 2015 queries/second ] 265 | 266 | ------------------------------------------------------------- 267 | [100 * QueryRow] * 1000 268 | ------------------------------------------------------------- 269 | AutoQueryRow: 18.9370832s [ 5281 queries/second ] 270 | SimpleQueryRow: 17.6690106s [ 5660 queries/second ] 271 | PreparedQueryRow: 9.2945316s [ 10759 queries/second ] 272 | 273 | ------------------------------------------------------------- 274 | [100000 * Exec] 275 | ------------------------------------------------------------- 276 | SimpleExec: 9.6345511s [ 10379 queries/second ] 277 | PreparedExec: 3.7902168s [ 26384 queries/second ] 278 | 279 | 280 | ************************************************************* 281 | BENCHMARKING Go-MySQL-Driver [run 2] 282 | ************************************************************* 283 | 284 | ------------------------------------------------------------- 285 | [10000 * Query 100 Rows] 286 | ------------------------------------------------------------- 287 | SimpleQuery: 3.585205s [ 2789 queries/second ] 288 | PreparedQuery: 3.0501745s [ 3279 queries/second ] 289 | 290 | ------------------------------------------------------------- 291 | [100 * QueryRow] * 1000 292 | ------------------------------------------------------------- 293 | AutoQueryRow: 13.3307625s [ 7501 queries/second ] 294 | SimpleQueryRow: 13.0667473s [ 7653 queries/second ] 295 | PreparedQueryRow: 6.5433743s [ 15283 queries/second ] 296 | 297 | ------------------------------------------------------------- 298 | [100000 * Exec] 299 | ------------------------------------------------------------- 300 | SimpleExec: 3.4541975s [ 28950 queries/second ] 301 | PreparedExec: 3.3351908s [ 29983 queries/second ] 302 | 303 | 304 | ************************************************************* 305 | BENCHMARKING mymysql godrv [run 2] 306 | ************************************************************* 307 | 308 | ------------------------------------------------------------- 309 | [10000 * Query 100 Rows] 310 | ------------------------------------------------------------- 311 | SimpleQuery: 5.6753246s [ 1762 queries/second ] 312 | PreparedQuery: 4.9732845s [ 2011 queries/second ] 313 | 314 | ------------------------------------------------------------- 315 | [100 * QueryRow] * 1000 316 | ------------------------------------------------------------- 317 | AutoQueryRow: 18.3610502s [ 5446 queries/second ] 318 | SimpleQueryRow: 17.4029953s [ 5746 queries/second ] 319 | PreparedQueryRow: 8.9775135s [ 11139 queries/second ] 320 | 321 | ------------------------------------------------------------- 322 | [100000 * Exec] 323 | ------------------------------------------------------------- 324 | SimpleExec: 9.4955431s [ 10531 queries/second ] 325 | PreparedExec: 3.7212129s [ 26873 queries/second ] 326 | 327 | 328 | ``` 329 | 330 | ### Java 331 | Same machine, Java (JDK7 / 64 bit) + [MySQL Connector/J 5.1.23](http://dev.mysql.com/downloads/connector/j/) 332 | ``` 333 | ------------------------------------------------------------- 334 | [10000 * Query 100 Rows] 335 | ------------------------------------------------------------- 336 | SimpleQuery: 1.899s [ 5266 queries/second ] 337 | PreparedQuery: 1.574s [ 6353 queries/second ] 338 | 339 | ------------------------------------------------------------- 340 | [100 * QueryRow] * 1000 341 | ------------------------------------------------------------- 342 | SimpleQueryRow: 7.111s [ 14063 queries/second ] 343 | PreparedQueryRow: 6.98s [ 14327 queries/second ] 344 | 345 | ------------------------------------------------------------- 346 | [100000 * Exec] 347 | ------------------------------------------------------------- 348 | SimpleExec: 4.127s [ 24231 queries/second ] 349 | PreparedExec: 3.898s [ 25654 queries/second ] 350 | ``` 351 | -------------------------------------------------------------------------------- /results/results_2013-03-02.md: -------------------------------------------------------------------------------- 1 | #SQL-Benchmark 2 | 3 | A synthetic benchmark to compare the performance of various sql-drivers for Go's database/sql package 4 | 5 | ## Results 6 | ### Contributed Results 7 | * [March 19, 2013](results-osx_2013-03-19.md) // OS X 10.8.3 / MySQL 5.6.10 by [Arne Hormann](https://github.com/arnehormann) 8 | * [March 19, 2013](results-linux_2013-03-19.md) // Linux / MySQL 5.5.27 by [Arne Hormann](https://github.com/arnehormann) 9 | 10 | ### Older Results 11 | * [February 26, 2013](results_2013-02-26.md) // Show [Diff to March 02, 2013](https://github.com/Go-SQL-Driver/SQL-Benchmark/commit/52078ce64a397d94b08bc66f5d7acedf13d3364e) 12 | 13 | ### Setup 14 | * Intel Core i5-2500K (3.30 GHz), 8 GB RAM 15 | * MySQL 5.1, Windows 7 x64 16 | * Current [Go-MySQL-Driver](https://github.com/go-sql-driver/mysql) and [mymysql](https://github.com/ziutek/mymysql) versions as of March 02, 2013 17 | * Java7 (JDBC) + MySQL Connector/J 5.1.23 for comparision 18 | 19 | ### Notes 20 | * 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. 21 | * 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 ;) 22 | * 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. 23 | * 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). 24 | * The Go results tend to vary much more. Probably this is caused by the garbage collector. 25 | 26 | ### Go tip 27 | * go version devel +646803253bb4 Tue Feb 26 09:51:33 2013 28 | * reverted [changeset ddb9e6365e57](http://code.google.com/p/go/source/detail?r=ddb9e6365e570c2619d88427176a465e8b76b4aa) because of [Issue #4902](http://golang.org/issue/4902) 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
BenchmarkGo-MySQL-Drivermymysql godrvJava (JDBC) + MySQL Connector/J 5.1.23
SimpleQuery4697 queries/second3111 queries/second5266 queries/second
PreparedQuery5053 queries/second4156 queries/second6353 queries/second
AutoQueryRow7868 queries/second6740 queries/second -
SimpleQueryRow14712 queries/second7053 queries/second14063 queries/second
PreparedQueryRow16436 queries/second14452 queries/second14327 queries/second
SimpleExec29127 queries/second27239 queries/second24231 queries/second
PreparedExec30533 queries/second28784 queries/second25654 queries/second
80 | 81 | ### Go1.0.3 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 |
BenchmarkGo-MySQL-Drivermymysql godrvJava (JDBC) + MySQL Connector/J 5.1.23
SimpleQuery3754 queries/second2888 queries/second5266 queries/second
PreparedQuery5000 queries/second3724 queries/second6353 queries/second
AutoQueryRow7855 queries/second6838 queries/second -
SimpleQueryRow7981 queries/second6992 queries/second14063 queries/second
PreparedQueryRow16490 queries/second13857 queries/second14327 queries/second
SimpleExec29427 queries/second27939 queries/second24231 queries/second
PreparedExec30834 queries/second29170 queries/second25654 queries/second
132 | 133 | ### Original Logs 134 | #### Go tip 135 | 136 | ``` 137 | ************************************************************* 138 | BENCHMARKING Go-MySQL-Driver [run 1] 139 | ************************************************************* 140 | 141 | ------------------------------------------------------------- 142 | [10000 * Query 100 Rows] 143 | ------------------------------------------------------------- 144 | SimpleQuery: 2.1291218s [ 4697 queries/second ] 145 | PreparedQuery: 2.0041147s [ 4990 queries/second ] 146 | 147 | ------------------------------------------------------------- 148 | [100 * QueryRow] * 1000 149 | ------------------------------------------------------------- 150 | AutoQueryRow: 12.709727s [ 7868 queries/second ] 151 | SimpleQueryRow: 6.7973888s [ 14712 queries/second ] 152 | PreparedQueryRow: 6.2203558s [ 16076 queries/second ] 153 | 154 | ------------------------------------------------------------- 155 | [100000 * Exec] 156 | ------------------------------------------------------------- 157 | SimpleExec: 3.4331964s [ 29127 queries/second ] 158 | PreparedExec: 3.2751873s [ 30533 queries/second ] 159 | 160 | 161 | ************************************************************* 162 | BENCHMARKING mymysql godrv [run 1] 163 | ************************************************************* 164 | 165 | ------------------------------------------------------------- 166 | [10000 * Query 100 Rows] 167 | ------------------------------------------------------------- 168 | SimpleQuery: 3.2221843s [ 3103 queries/second ] 169 | PreparedQuery: 2.4981429s [ 4003 queries/second ] 170 | 171 | ------------------------------------------------------------- 172 | [100 * QueryRow] * 1000 173 | ------------------------------------------------------------- 174 | AutoQueryRow: 14.8358486s [ 6740 queries/second ] 175 | SimpleQueryRow: 14.4258251s [ 6932 queries/second ] 176 | PreparedQueryRow: 7.2694158s [ 13756 queries/second ] 177 | 178 | ------------------------------------------------------------- 179 | [100000 * Exec] 180 | ------------------------------------------------------------- 181 | SimpleExec: 3.67121s [ 27239 queries/second ] 182 | PreparedExec: 3.4741987s [ 28784 queries/second ] 183 | 184 | 185 | ************************************************************* 186 | BENCHMARKING Go-MySQL-Driver [run 2] 187 | ************************************************************* 188 | 189 | ------------------------------------------------------------- 190 | [10000 * Query 100 Rows] 191 | ------------------------------------------------------------- 192 | SimpleQuery: 2.1351221s [ 4684 queries/second ] 193 | PreparedQuery: 1.9791132s [ 5053 queries/second ] 194 | 195 | ------------------------------------------------------------- 196 | [100 * QueryRow] * 1000 197 | ------------------------------------------------------------- 198 | AutoQueryRow: 12.8407344s [ 7788 queries/second ] 199 | SimpleQueryRow: 6.8563922s [ 14585 queries/second ] 200 | PreparedQueryRow: 6.084348s [ 16436 queries/second ] 201 | 202 | ------------------------------------------------------------- 203 | [100000 * Exec] 204 | ------------------------------------------------------------- 205 | SimpleExec: 3.4891995s [ 28660 queries/second ] 206 | PreparedExec: 3.3341907s [ 29992 queries/second ] 207 | 208 | 209 | ************************************************************* 210 | BENCHMARKING mymysql godrv [run 2] 211 | ************************************************************* 212 | 213 | ------------------------------------------------------------- 214 | [10000 * Query 100 Rows] 215 | ------------------------------------------------------------- 216 | SimpleQuery: 3.2141838s [ 3111 queries/second ] 217 | PreparedQuery: 2.4061376s [ 4156 queries/second ] 218 | 219 | ------------------------------------------------------------- 220 | [100 * QueryRow] * 1000 221 | ------------------------------------------------------------- 222 | AutoQueryRow: 15.228871s [ 6566 queries/second ] 223 | SimpleQueryRow: 14.178811s [ 7053 queries/second ] 224 | PreparedQueryRow: 6.9193957s [ 14452 queries/second ] 225 | 226 | ------------------------------------------------------------- 227 | [100000 * Exec] 228 | ------------------------------------------------------------- 229 | SimpleExec: 3.6822106s [ 27158 queries/second ] 230 | PreparedExec: 3.5232015s [ 28383 queries/second ] 231 | 232 | 233 | ``` 234 | 235 | 236 | #### Go1.0.3 237 | 238 | ``` 239 | ************************************************************* 240 | BENCHMARKING Go-MySQL-Driver [run 1] 241 | ************************************************************* 242 | 243 | ------------------------------------------------------------- 244 | [10000 * Query 100 Rows] 245 | ------------------------------------------------------------- 246 | SimpleQuery: 2.692154s [ 3714 queries/second ] 247 | PreparedQuery: 2.0001144s [ 5000 queries/second ] 248 | 249 | ------------------------------------------------------------- 250 | [100 * QueryRow] * 1000 251 | ------------------------------------------------------------- 252 | AutoQueryRow: 12.7307282s [ 7855 queries/second ] 253 | SimpleQueryRow: 12.5297167s [ 7981 queries/second ] 254 | PreparedQueryRow: 6.0643468s [ 16490 queries/second ] 255 | 256 | ------------------------------------------------------------- 257 | [100000 * Exec] 258 | ------------------------------------------------------------- 259 | SimpleExec: 3.409195s [ 29332 queries/second ] 260 | PreparedExec: 3.2571863s [ 30701 queries/second ] 261 | 262 | 263 | ************************************************************* 264 | BENCHMARKING mymysql godrv [run 1] 265 | ************************************************************* 266 | 267 | ------------------------------------------------------------- 268 | [10000 * Query 100 Rows] 269 | ------------------------------------------------------------- 270 | SimpleQuery: 3.4911997s [ 2864 queries/second ] 271 | PreparedQuery: 2.8191612s [ 3547 queries/second ] 272 | 273 | ------------------------------------------------------------- 274 | [100 * QueryRow] * 1000 275 | ------------------------------------------------------------- 276 | AutoQueryRow: 14.790846s [ 6761 queries/second ] 277 | SimpleQueryRow: 14.3098185s [ 6988 queries/second ] 278 | PreparedQueryRow: 7.2164128s [ 13857 queries/second ] 279 | 280 | ------------------------------------------------------------- 281 | [100000 * Exec] 282 | ------------------------------------------------------------- 283 | SimpleExec: 3.6492087s [ 27403 queries/second ] 284 | PreparedExec: 3.4471971s [ 29009 queries/second ] 285 | 286 | 287 | ************************************************************* 288 | BENCHMARKING Go-MySQL-Driver [run 2] 289 | ************************************************************* 290 | 291 | ------------------------------------------------------------- 292 | [10000 * Query 100 Rows] 293 | ------------------------------------------------------------- 294 | SimpleQuery: 2.6641524s [ 3754 queries/second ] 295 | PreparedQuery: 2.0211156s [ 4948 queries/second ] 296 | 297 | ------------------------------------------------------------- 298 | [100 * QueryRow] * 1000 299 | ------------------------------------------------------------- 300 | AutoQueryRow: 12.9847427s [ 7701 queries/second ] 301 | SimpleQueryRow: 12.5747192s [ 7952 queries/second ] 302 | PreparedQueryRow: 6.1143498s [ 16355 queries/second ] 303 | 304 | ------------------------------------------------------------- 305 | [100000 * Exec] 306 | ------------------------------------------------------------- 307 | SimpleExec: 3.3981944s [ 29427 queries/second ] 308 | PreparedExec: 3.2431855s [ 30834 queries/second ] 309 | 310 | 311 | ************************************************************* 312 | BENCHMARKING mymysql godrv [run 2] 313 | ************************************************************* 314 | 315 | ------------------------------------------------------------- 316 | [10000 * Query 100 Rows] 317 | ------------------------------------------------------------- 318 | SimpleQuery: 3.4631981s [ 2888 queries/second ] 319 | PreparedQuery: 2.6851535s [ 3724 queries/second ] 320 | 321 | ------------------------------------------------------------- 322 | [100 * QueryRow] * 1000 323 | ------------------------------------------------------------- 324 | AutoQueryRow: 14.6238365s [ 6838 queries/second ] 325 | SimpleQueryRow: 14.302818s [ 6992 queries/second ] 326 | PreparedQueryRow: 7.2354138s [ 13821 queries/second ] 327 | 328 | ------------------------------------------------------------- 329 | [100000 * Exec] 330 | ------------------------------------------------------------- 331 | SimpleExec: 3.5792047s [ 27939 queries/second ] 332 | PreparedExec: 3.4281961s [ 29170 queries/second ] 333 | 334 | 335 | ``` 336 | 337 | ### Java 338 | Same machine, Java (JDK7 / 64 bit) + [MySQL Connector/J 5.1.23](http://dev.mysql.com/downloads/connector/j/) 339 | ``` 340 | ------------------------------------------------------------- 341 | [10000 * Query 100 Rows] 342 | ------------------------------------------------------------- 343 | SimpleQuery: 1.899s [ 5266 queries/second ] 344 | PreparedQuery: 1.574s [ 6353 queries/second ] 345 | 346 | ------------------------------------------------------------- 347 | [100 * QueryRow] * 1000 348 | ------------------------------------------------------------- 349 | SimpleQueryRow: 7.111s [ 14063 queries/second ] 350 | PreparedQueryRow: 6.98s [ 14327 queries/second ] 351 | 352 | ------------------------------------------------------------- 353 | [100000 * Exec] 354 | ------------------------------------------------------------- 355 | SimpleExec: 4.127s [ 24231 queries/second ] 356 | PreparedExec: 3.898s [ 25654 queries/second ] 357 | ``` 358 | -------------------------------------------------------------------------------- /results/results-linux_2013-03-19.md: -------------------------------------------------------------------------------- 1 | ### Setup 2 | * Intel Xeon CPU 3.20GHz, 4 GB RAM 3 | * Linux 64 Bit 4 | * MySQL 5.5.27 5 | * Current [Go-MySQL-Driver](https://github.com/Go-SQL-Driver/MySQL) and [mymysql](https://github.com/ziutek/mymysql) versions as of March 19, 2013 6 | * Java7 (JDBC) + MySQL Connector/J 5.1.24 for comparison 7 | 8 | ### Results for go 1.0.3, Java run 1 and 2 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 |
BenchmarkGo-MySQL-Drivermymysql godrvJava (JDBC) + MySQL Connector/J 5.1.24
SimpleQuery2037 queries/second1631 queries/second3323 queries/second
PreparedQuery2928 queries/second2246 queries/second5195 queries/second
AutoQueryRow3645 queries/second3323 queries/second-
SimpleQueryRow3835 queries/second3401 queries/second11071 queries/second
PreparedQueryRow8803 queries/second8045 queries/second11453 queries/second
SimpleExec10027 queries/second9474 queries/second11455 queries/second
PreparedExec10278 queries/second9831 queries/second11832 queries/second
59 | 60 | ### Results for go tip, Java run 3 and 4 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 |
BenchmarkGo-MySQL-Drivermymysql godrvJava (JDBC) + MySQL Connector/J 5.1.24
SimpleQuery3743 queries/second2683 queries/second3301 queries/second
PreparedQuery4101 queries/second3018 queries/second5198 queries/second
AutoQueryRow4372 queries/second9678* queries/second-
SimpleQueryRow11217 queries/second9738 queries/second11086 queries/second
PreparedQueryRow9849 queries/second8784 queries/second11391 queries/second
SimpleExec12907 queries/second12410 queries/second11429 queries/second
PreparedExec13222 queries/second12696 queries/second11748 queries/second
111 | 112 | `* AutoQueryRow`: mymysql builds a single query string instead of using prepared statements 113 | 114 | ### Original Logs 115 | 116 | #### Go 1.0.3 117 | ``` 118 | $ go version 119 | go version go1.0.3 120 | ``` 121 | 122 | ``` 123 | ************************************************************* 124 | BENCHMARKING Go-MySQL-Driver [run 1] 125 | ************************************************************* 126 | 127 | ------------------------------------------------------------- 128 | [10000 * Query 100 Rows] 129 | ------------------------------------------------------------- 130 | SimpleQuery: 4.90898s [ 2037 queries/second ] 131 | PreparedQuery: 3.415631s [ 2928 queries/second ] 132 | 133 | ------------------------------------------------------------- 134 | [100 * QueryRow] * 1000 135 | ------------------------------------------------------------- 136 | AutoQueryRow: 25.992804s [ 3847 queries/second ] 137 | SimpleQueryRow: 26.018075s [ 3843 queries/second ] 138 | PreparedQueryRow: 11.359661s [ 8803 queries/second ] 139 | 140 | ------------------------------------------------------------- 141 | [100000 * Exec] 142 | ------------------------------------------------------------- 143 | SimpleExec: 9.937693s [ 10063 queries/second ] 144 | PreparedExec: 9.673266s [ 10338 queries/second ] 145 | 146 | 147 | ************************************************************* 148 | BENCHMARKING mymysql godrv [run 1] 149 | ************************************************************* 150 | 151 | ------------------------------------------------------------- 152 | [10000 * Query 100 Rows] 153 | ------------------------------------------------------------- 154 | SimpleQuery: 6.090524s [ 1642 queries/second ] 155 | PreparedQuery: 4.447945s [ 2248 queries/second ] 156 | 157 | ------------------------------------------------------------- 158 | [100 * QueryRow] * 1000 159 | ------------------------------------------------------------- 160 | AutoQueryRow: 30.092542s [ 3323 queries/second ] 161 | SimpleQueryRow: 29.399428s [ 3401 queries/second ] 162 | PreparedQueryRow: 12.43072s [ 8045 queries/second ] 163 | 164 | ------------------------------------------------------------- 165 | [100000 * Exec] 166 | ------------------------------------------------------------- 167 | SimpleExec: 10.555367s [ 9474 queries/second ] 168 | PreparedExec: 10.172413s [ 9831 queries/second ] 169 | 170 | 171 | ************************************************************* 172 | BENCHMARKING Go-MySQL-Driver [run 2] 173 | ************************************************************* 174 | 175 | ------------------------------------------------------------- 176 | [10000 * Query 100 Rows] 177 | ------------------------------------------------------------- 178 | SimpleQuery: 4.721605s [ 2118 queries/second ] 179 | PreparedQuery: 3.251801s [ 3075 queries/second ] 180 | 181 | ------------------------------------------------------------- 182 | [100 * QueryRow] * 1000 183 | ------------------------------------------------------------- 184 | AutoQueryRow: 27.436285s [ 3645 queries/second ] 185 | SimpleQueryRow: 26.077592s [ 3835 queries/second ] 186 | PreparedQueryRow: 11.229181s [ 8905 queries/second ] 187 | 188 | ------------------------------------------------------------- 189 | [100000 * Exec] 190 | ------------------------------------------------------------- 191 | SimpleExec: 9.97262s [ 10027 queries/second ] 192 | PreparedExec: 9.729652s [ 10278 queries/second ] 193 | 194 | 195 | ************************************************************* 196 | BENCHMARKING mymysql godrv [run 2] 197 | ************************************************************* 198 | 199 | ------------------------------------------------------------- 200 | [10000 * Query 100 Rows] 201 | ------------------------------------------------------------- 202 | SimpleQuery: 6.130481s [ 1631 queries/second ] 203 | PreparedQuery: 4.451507s [ 2246 queries/second ] 204 | 205 | ------------------------------------------------------------- 206 | [100 * QueryRow] * 1000 207 | ------------------------------------------------------------- 208 | AutoQueryRow: 28.611437s [ 3495 queries/second ] 209 | SimpleQueryRow: 28.730313s [ 3481 queries/second ] 210 | PreparedQueryRow: 12.427371s [ 8047 queries/second ] 211 | 212 | ------------------------------------------------------------- 213 | [100000 * Exec] 214 | ------------------------------------------------------------- 215 | SimpleExec: 10.319815s [ 9690 queries/second ] 216 | PreparedExec: 10.147441s [ 9855 queries/second ] 217 | ``` 218 | 219 | 220 | #### Go tip 221 | ``` 222 | $ go version 223 | go version devel +786e094255c9 Tue Mar 19 07:08:26 2013 +0100 linux/amd64 224 | ``` 225 | 226 | ``` 227 | ************************************************************* 228 | BENCHMARKING Go-MySQL-Driver [run 1] 229 | ************************************************************* 230 | 231 | ------------------------------------------------------------- 232 | [10000 * Query 100 Rows] 233 | ------------------------------------------------------------- 234 | SimpleQuery: 2.660608864s [ 3759 queries/second ] 235 | PreparedQuery: 2.416900888s [ 4138 queries/second ] 236 | 237 | ------------------------------------------------------------- 238 | [100 * QueryRow] * 1000 239 | ------------------------------------------------------------- 240 | AutoQueryRow: 22.660756965s [ 4413 queries/second ] 241 | SimpleQueryRow: 8.815792086s [ 11343 queries/second ] 242 | PreparedQueryRow: 10.028589997s [ 9971 queries/second ] 243 | 244 | ------------------------------------------------------------- 245 | [100000 * Exec] 246 | ------------------------------------------------------------- 247 | SimpleExec: 7.676686034s [ 13026 queries/second ] 248 | PreparedExec: 7.508063974s [ 13319 queries/second ] 249 | 250 | 251 | ************************************************************* 252 | BENCHMARKING mymysql godrv [run 1] 253 | ************************************************************* 254 | 255 | ------------------------------------------------------------- 256 | [10000 * Query 100 Rows] 257 | ------------------------------------------------------------- 258 | SimpleQuery: 3.724476606s [ 2685 queries/second ] 259 | PreparedQuery: 3.301542098s [ 3029 queries/second ] 260 | 261 | ------------------------------------------------------------- 262 | [100 * QueryRow] * 1000 263 | ------------------------------------------------------------- 264 | AutoQueryRow: 10.320880617s [ 9689 queries/second ] 265 | SimpleQueryRow: 10.252676766s [ 9754 queries/second ] 266 | PreparedQueryRow: 11.309210151s [ 8842 queries/second ] 267 | 268 | ------------------------------------------------------------- 269 | [100000 * Exec] 270 | ------------------------------------------------------------- 271 | SimpleExec: 8.017343577s [ 12473 queries/second ] 272 | PreparedExec: 7.853554703s [ 12733 queries/second ] 273 | 274 | 275 | ************************************************************* 276 | BENCHMARKING Go-MySQL-Driver [run 2] 277 | ************************************************************* 278 | 279 | ------------------------------------------------------------- 280 | [10000 * Query 100 Rows] 281 | ------------------------------------------------------------- 282 | SimpleQuery: 2.671647612s [ 3743 queries/second ] 283 | PreparedQuery: 2.43836213s [ 4101 queries/second ] 284 | 285 | ------------------------------------------------------------- 286 | [100 * QueryRow] * 1000 287 | ------------------------------------------------------------- 288 | AutoQueryRow: 22.872479121s [ 4372 queries/second ] 289 | SimpleQueryRow: 8.914766029s [ 11217 queries/second ] 290 | PreparedQueryRow: 10.153325208s [ 9849 queries/second ] 291 | 292 | ------------------------------------------------------------- 293 | [100000 * Exec] 294 | ------------------------------------------------------------- 295 | SimpleExec: 7.747658594s [ 12907 queries/second ] 296 | PreparedExec: 7.563278955s [ 13222 queries/second ] 297 | 298 | 299 | ************************************************************* 300 | BENCHMARKING mymysql godrv [run 2] 301 | ************************************************************* 302 | 303 | ------------------------------------------------------------- 304 | [10000 * Query 100 Rows] 305 | ------------------------------------------------------------- 306 | SimpleQuery: 3.726763041s [ 2683 queries/second ] 307 | PreparedQuery: 3.312916071s [ 3018 queries/second ] 308 | 309 | ------------------------------------------------------------- 310 | [100 * QueryRow] * 1000 311 | ------------------------------------------------------------- 312 | AutoQueryRow: 10.33306149s [ 9678 queries/second ] 313 | SimpleQueryRow: 10.269378078s [ 9738 queries/second ] 314 | PreparedQueryRow: 11.38467273s [ 8784 queries/second ] 315 | 316 | ------------------------------------------------------------- 317 | [100000 * Exec] 318 | ------------------------------------------------------------- 319 | SimpleExec: 8.058210282s [ 12410 queries/second ] 320 | PreparedExec: 7.876202872s [ 12696 queries/second ] 321 | ``` 322 | 323 | ### Java 324 | ``` 325 | java version "1.7.0_05" 326 | Java(TM) SE Runtime Environment (build 1.7.0_05-b06) 327 | Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode) 328 | ``` 329 | #### Run 1 330 | ``` 331 | ------------------------------------------------------------- 332 | [10000 * Query 100 Rows] 333 | ------------------------------------------------------------- 334 | SimpleQuery: 3.009s [ 3323 queries/second ] 335 | PreparedQuery: 1.921s [ 5206 queries/second ] 336 | 337 | ------------------------------------------------------------- 338 | [100 * QueryRow] * 1000 339 | ------------------------------------------------------------- 340 | SimpleQueryRow: 9.033s [ 11071 queries/second ] 341 | PreparedQueryRow: 8.731s [ 11453 queries/second ] 342 | 343 | ------------------------------------------------------------- 344 | [100000 * Exec] 345 | ------------------------------------------------------------- 346 | SimpleExec: 8.66s [ 11547 queries/second ] 347 | PreparedExec: 8.452s [ 11832 queries/second ] 348 | ``` 349 | 350 | #### Run 2 351 | ``` 352 | ------------------------------------------------------------- 353 | [10000 * Query 100 Rows] 354 | ------------------------------------------------------------- 355 | SimpleQuery: 3.004s [ 3329 queries/second ] 356 | PreparedQuery: 1.925s [ 5195 queries/second ] 357 | 358 | ------------------------------------------------------------- 359 | [100 * QueryRow] * 1000 360 | ------------------------------------------------------------- 361 | SimpleQueryRow: 9.001s [ 11110 queries/second ] 362 | PreparedQueryRow: 8.729s [ 11456 queries/second ] 363 | 364 | ------------------------------------------------------------- 365 | [100000 * Exec] 366 | ------------------------------------------------------------- 367 | SimpleExec: 8.73s [ 11455 queries/second ] 368 | PreparedExec: 8.427s [ 11867 queries/second ] 369 | ``` 370 | 371 | #### Run 3 372 | ``` 373 | ------------------------------------------------------------- 374 | [10000 * Query 100 Rows] 375 | ------------------------------------------------------------- 376 | SimpleQuery: 3.029s [ 3301 queries/second ] 377 | PreparedQuery: 1.921s [ 5206 queries/second ] 378 | 379 | ------------------------------------------------------------- 380 | [100 * QueryRow] * 1000 381 | ------------------------------------------------------------- 382 | SimpleQueryRow: 9.005s [ 11105 queries/second ] 383 | PreparedQueryRow: 8.731s [ 11453 queries/second ] 384 | 385 | ------------------------------------------------------------- 386 | [100000 * Exec] 387 | ------------------------------------------------------------- 388 | SimpleExec: 8.744s [ 11436 queries/second ] 389 | PreparedExec: 8.475s [ 11799 queries/second ] 390 | ``` 391 | 392 | #### Run 4 393 | ``` 394 | ------------------------------------------------------------- 395 | [10000 * Query 100 Rows] 396 | ------------------------------------------------------------- 397 | SimpleQuery: 3.016s [ 3316 queries/second ] 398 | PreparedQuery: 1.924s [ 5198 queries/second ] 399 | 400 | ------------------------------------------------------------- 401 | [100 * QueryRow] * 1000 402 | ------------------------------------------------------------- 403 | SimpleQueryRow: 9.02s [ 11086 queries/second ] 404 | PreparedQueryRow: 8.779s [ 11391 queries/second ] 405 | 406 | ------------------------------------------------------------- 407 | [100000 * Exec] 408 | ------------------------------------------------------------- 409 | SimpleExec: 8.75s [ 11429 queries/second ] 410 | PreparedExec: 8.512s [ 11748 queries/second ] 411 | ``` 412 | -------------------------------------------------------------------------------- /java/mysql-connector-java-5.1.26/COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. 40 | 41 | Also, for each author's protection and ours, we want to make certain 42 | that everyone understands that there is no warranty for this free 43 | software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. 44 | 45 | Finally, any free program is threatened constantly by software 46 | patents. We wish to avoid the danger that redistributors of a free 47 | program will individually obtain patent licenses, in effect making the 48 | program proprietary. To prevent this, we have made it clear that any 49 | patent must be licensed for everyone's free use or not licensed at all. 50 | 51 | The precise terms and conditions for copying, distribution and 52 | modification follow. 53 | 54 | GNU GENERAL PUBLIC LICENSE 55 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 56 | 57 | 0. This License applies to any program or other work which contains 58 | a notice placed by the copyright holder saying it may be distributed 59 | under the terms of this General Public License. The "Program", below, 60 | refers to any such program or work, and a "work based on the Program" 61 | means either the Program or any derivative work under copyright law: 62 | that is to say, a work containing the Program or a portion of it, 63 | either verbatim or with modifications and/or translated into another 64 | language. (Hereinafter, translation is included without limitation in 65 | the term "modification".) Each licensee is addressed as "you". 66 | 67 | Activities other than copying, distribution and modification are not 68 | covered by this License; they are outside its scope. The act of 69 | running the Program is not restricted, and the output from the Program 70 | is covered only if its contents constitute a work based on the 71 | Program (independent of having been made by running the Program). 72 | Whether that is true depends on what the Program does. 73 | 74 | 1. You may copy and distribute verbatim copies of the Program's 75 | source code as you receive it, in any medium, provided that you 76 | conspicuously and appropriately publish on each copy an appropriate 77 | copyright notice and disclaimer of warranty; keep intact all the 78 | notices that refer to this License and to the absence of any warranty; 79 | and give any other recipients of the Program a copy of this License 80 | along with the Program. 81 | 82 | You may charge a fee for the physical act of transferring a copy, and 83 | you may at your option offer warranty protection in exchange for a fee. 84 | 85 | 2. You may modify your copy or copies of the Program or any portion 86 | of it, thus forming a work based on the Program, and copy and 87 | distribute such modifications or work under the terms of Section 1 88 | above, provided that you also meet all of these conditions: 89 | 90 | a) You must cause the modified files to carry prominent notices 91 | stating that you changed the files and the date of any change. 92 | 93 | b) You must cause any work that you distribute or publish, that in 94 | whole or in part contains or is derived from the Program or any 95 | part thereof, to be licensed as a whole at no charge to all third 96 | parties under the terms of this License. 97 | 98 | c) If the modified program normally reads commands interactively 99 | when run, you must cause it, when started running for such 100 | interactive use in the most ordinary way, to print or display an 101 | announcement including an appropriate copyright notice and a 102 | notice that there is no warranty (or else, saying that you provide 103 | a warranty) and that users may redistribute the program under 104 | these conditions, and telling the user how to view a copy of this 105 | License. (Exception: if the Program itself is interactive but 106 | does not normally print such an announcement, your work based on 107 | the Program is not required to print an announcement.) 108 | 109 | These requirements apply to the modified work as a whole. If 110 | identifiable sections of that work are not derived from the Program, 111 | and can be reasonably considered independent and separate works in 112 | themselves, then this License, and its terms, do not apply to those 113 | sections when you distribute them as separate works. But when you 114 | distribute the same sections as part of a whole which is a work based 115 | on the Program, the distribution of the whole must be on the terms of 116 | this License, whose permissions for other licensees extend to the 117 | entire whole, and thus to each and every part regardless of who wrote it. 118 | 119 | Thus, it is not the intent of this section to claim rights or contest 120 | your rights to work written entirely by you; rather, the intent is to 121 | exercise the right to control the distribution of derivative or 122 | collective works based on the Program. 123 | 124 | In addition, mere aggregation of another work not based on the Program 125 | with the Program (or with a work based on the Program) on a volume of 126 | a storage or distribution medium does not bring the other work under 127 | the scope of this License. 128 | 129 | 3. You may copy and distribute the Program (or a work based on it, 130 | under Section 2) in object code or executable form under the terms of 131 | Sections 1 and 2 above provided that you also do one of the following: 132 | 133 | a) Accompany it with the complete corresponding machine-readable 134 | source code, which must be distributed under the terms of Sections 135 | 1 and 2 above on a medium customarily used for software 136 | interchange; or, 137 | 138 | b) Accompany it with a written offer, valid for at least three 139 | years, to give any third party, for a charge no more than your 140 | cost of physically performing source distribution, a complete 141 | machine-readable copy of the corresponding source code, to be 142 | distributed under the terms of Sections 1 and 2 above on a medium 143 | customarily used for software interchange; or, 144 | 145 | c) Accompany it with the information you received as to the offer 146 | to distribute corresponding source code. (This alternative is 147 | allowed only for noncommercial distribution and only if you 148 | received the program in object code or executable form with such 149 | an offer, in accord with Subsection b above.) 150 | 151 | The source code for a work means the preferred form of the work for 152 | making modifications to it. For an executable work, complete source 153 | code means all the source code for all modules it contains, plus any 154 | associated interface definition files, plus the scripts used to 155 | control compilation and installation of the executable. However, as 156 | a special exception, the source code distributed need not include 157 | anything that is normally distributed (in either source or binary 158 | form) with the major components (compiler, kernel, and so on) of the 159 | operating system on which the executable runs, unless that component 160 | itself accompanies the executable. 161 | 162 | If distribution of executable or object code is made by offering 163 | access to copy from a designated place, then offering equivalent 164 | access to copy the source code from the same place counts as 165 | distribution of the source code, even though third parties are not 166 | compelled to copy the source along with the object code. 167 | 168 | 4. You may not copy, modify, sublicense, or distribute the Program 169 | except as expressly provided under this License. Any attempt 170 | otherwise to copy, modify, sublicense or distribute the Program is 171 | void, and will automatically terminate your rights under this License. 172 | However, parties who have received copies, or rights, from you under 173 | this License will not have their licenses terminated so long as such 174 | parties remain in full compliance. 175 | 176 | 5. You are not required to accept this License, since you have not 177 | signed it. However, nothing else grants you permission to modify or 178 | distribute the Program or its derivative works. These actions are 179 | prohibited by law if you do not accept this License. Therefore, by 180 | modifying or distributing the Program (or any work based on the 181 | Program), you indicate your acceptance of this License to do so, and 182 | all its terms and conditions for copying, distributing or modifying 183 | the Program or works based on it. 184 | 185 | 6. Each time you redistribute the Program (or any work based on the 186 | Program), the recipient automatically receives a license from the 187 | original licensor to copy, distribute or modify the Program subject to 188 | these terms and conditions. You may not impose any further 189 | restrictions on the recipients' exercise of the rights granted herein. 190 | You are not responsible for enforcing compliance by third parties to 191 | this License. 192 | 193 | 7. If, as a consequence of a court judgment or allegation of patent 194 | infringement or for any other reason (not limited to patent issues), 195 | conditions are imposed on you (whether by court order, agreement or 196 | otherwise) that contradict the conditions of this License, they do not 197 | excuse you from the conditions of this License. If you cannot 198 | distribute so as to satisfy simultaneously your obligations under this 199 | License and any other pertinent obligations, then as a consequence you 200 | may not distribute the Program at all. For example, if a patent 201 | license would not permit royalty-free redistribution of the Program by 202 | all those who receive copies directly or indirectly through you, then 203 | the only way you could satisfy both it and this License would be to 204 | refrain entirely from distribution of the Program. 205 | 206 | If any portion of this section is held invalid or unenforceable under 207 | any particular circumstance, the balance of the section is intended to 208 | apply and the section as a whole is intended to apply in other 209 | circumstances. 210 | 211 | It is not the purpose of this section to induce you to infringe any 212 | patents or other property right claims or to contest validity of any 213 | such claims; this section has the sole purpose of protecting the 214 | integrity of the free software distribution system, which is 215 | implemented by public license practices. Many people have made 216 | generous contributions to the wide range of software distributed 217 | through that system in reliance on consistent application of that 218 | system; it is up to the author/donor to decide if he or she is willing 219 | to distribute software through any other system and a licensee cannot 220 | impose that choice. 221 | 222 | This section is intended to make thoroughly clear what is believed to 223 | be a consequence of the rest of this License. 224 | 225 | 8. If the distribution and/or use of the Program is restricted in 226 | certain countries either by patents or by copyrighted interfaces, the 227 | original copyright holder who places the Program under this License 228 | may add an explicit geographical distribution limitation excluding 229 | those countries, so that distribution is permitted only in or among 230 | countries not thus excluded. In such case, this License incorporates 231 | the limitation as if written in the body of this License. 232 | 233 | 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 234 | 235 | Each version is given a distinguishing version number. If the Program 236 | specifies a version number of this License which applies to it and 237 | "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 238 | 239 | 10. If you wish to incorporate parts of the Program into other free 240 | programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. 241 | 242 | NO WARRANTY 243 | 244 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 245 | 246 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 247 | 248 | END OF TERMS AND CONDITIONS 249 | 250 | How to Apply These Terms to Your New Programs 251 | 252 | If you develop a new program, and you want it to be of the greatest 253 | possible use to the public, the best way to achieve this is to make it 254 | free software which everyone can redistribute and change under these terms. 255 | 256 | To do so, attach the following notices to the program. It is safest 257 | to attach them to the start of each source file to most effectively 258 | convey the exclusion of warranty; and each file should have at least 259 | the "copyright" line and a pointer to where the full notice is found. 260 | 261 | 263 | Copyright (C) 264 | 265 | This program is free software; you can redistribute it and/or 266 | modify it under the terms of the GNU General Public License as 267 | published by the Free Software Foundation; either version 268 | 2 of the License, or (at your option) any later version. 269 | 270 | This program is distributed in the hope that it will be useful, 271 | but WITHOUT ANY WARRANTY; without even the implied warranty of 272 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 273 | GNU General Public License for more details. 274 | 275 | You should have received a copy of the GNU General Public License 276 | along with this program; if not, write to the Free Software 277 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 278 | 02110-1301 USA. 279 | 280 | Also add information on how to contact you by electronic and paper mail. 281 | 282 | If the program is interactive, make it output a short notice like this 283 | when it starts in an interactive mode: 284 | 285 | Gnomovision version 69, Copyright (C) year name of author 286 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details 287 | type 'show w'. This is free software, and you are welcome 288 | to redistribute it under certain conditions; type 'show c' 289 | for details. 290 | 291 | The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 292 | 'show c'; they could even be mouse-clicks or menu items--whatever 293 | suits your program. 294 | 295 | You should also get your employer (if you work as a programmer) or your 296 | school, if any, to sign a "copyright disclaimer" for the program, if 297 | necessary. Here is a sample; alter the names: 298 | 299 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 300 | program 'Gnomovision' (which makes passes at compilers) written 301 | by James Hacker. 302 | 303 | , 1 April 1989 304 | Ty Coon, President of Vice 305 | 306 | This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use 307 | the GNU Lesser General Public License instead of this License. 308 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SQL-Benchmark 2 | 3 | A synthetic benchmark to compare the performance of various sql-drivers for Go's database/sql package 4 | 5 | ## Results (2013-11-02) 6 | ### Older Results 7 | * [March 02, 2013](results/results_2013-03-02.md) 8 | * [February 26, 2013](results/results_2013-02-26.md) 9 | 10 | ### Contributed Results 11 | * [March 19, 2013](results/results-osx_2013-03-19.md) // OS X 10.8.3 / MySQL 5.6.10 by [Arne Hormann](https://github.com/arnehormann) 12 | * [March 19, 2013](results/results-linux_2013-03-19.md) // Linux / MySQL 5.5.27 by [Arne Hormann](https://github.com/arnehormann) 13 | 14 | 15 | ### Setup 16 | * Intel Core i5-2500K (4x 3.30 GHz), 8 GB RAM 17 | * MySQL 5.5.34 18 | * Ubuntu 13.10 x64 (Linux) 19 | * Go 1.2rc2 linux/amd64 20 | * [Go-MySQL-Driver v1.1 and v1.0.2](https://github.com/go-sql-driver/mysql) and [MyMySQL v1.5.3](https://github.com/ziutek/mymysql) 21 | 22 | #### MySQL 23 | * fresh & clean install via `apt-get install mysql-server` 24 | * server version: 5.5.34-0ubuntu0.13.10.1 25 | * connected via Unix Domain Socket (`/var/run/mysqld/mysqld.sock`) 26 | * additional config: 27 | 28 | ``` 29 | thread_cache_size = 16 30 | query_cache_limit = 2M 31 | query_cache_size = 128M 32 | ``` 33 | 34 | #### Linux 35 | * CPU frequency governor set to 'performance' 36 | 37 | ### Notes 38 | * We did a complete rewrite of the benchmark suite for this round. The results are not comparable to previous rounds. 39 | * The results should now be much more accurate and vary less. 40 | * The benchmark suite now includes concurrent tests. These are probably the most interesting tests. 41 | * The memory footprint (per query) is now also measured. 42 | * Before each test the Garbage Collector is manually run to eliminate influence of garbage from previous tests. 43 | * The benchmarks are designed to minimize response latency from the server. We try to compare driver performance here and not to benchmark the MySQL Server ;) 44 | * The memory footprint includes allocations by the database/sql package. In fact, for Go-MySQL-Driver 1.1 this is the large part, as you can see [in this memory profile](http://files.julienschmidt.com/public/go/sql-benchmark/mysql.PreparedQueryConcurrent4.mem.svg). The `mysql-rows.(*mysqlRows).Columns` block will hopefully eliminated after the Go 1.2 release [with this patch](https://codereview.appspot.com/17580043/). 45 | 46 | 47 | ``` 48 | $ go run main.go benchmarks.go 49 | Warming up mymysql godrv... 50 | Warming up Go-MySQL-Driver 1.0... 51 | Warming up Go-MySQL-Driver 1.1... 52 | 53 | Run Benchmarks... 54 | 55 | SimpleExec 250000 iterations 56 | mymysql godrv 57 | 3.844984027s 65020 queries/sec 7 allocs/query 351 B/query 58 | 3.832080666s 65239 queries/sec 7 allocs/query 351 B/query 59 | 3.817775996s 65483 queries/sec 7 allocs/query 351 B/query 60 | -- avg 65247 qps; median 65239 qps 61 | Go-MySQL-Driver 1.0 62 | 3.602866751s 69389 queries/sec 4 allocs/query 113 B/query 63 | 3.599880038s 69447 queries/sec 4 allocs/query 113 B/query 64 | 3.591707362s 69605 queries/sec 4 allocs/query 113 B/query 65 | -- avg 69480 qps; median 69447 qps 66 | Go-MySQL-Driver 1.1 67 | 3.569295906s 70042 queries/sec 3 allocs/query 97 B/query 68 | 3.578053109s 69870 queries/sec 3 allocs/query 97 B/query 69 | 3.572950976s 69970 queries/sec 3 allocs/query 97 B/query 70 | -- avg 69961 qps; median 69970 qps 71 | 72 | PreparedExec 250000 iterations 73 | mymysql godrv 74 | 3.68239709s 67891 queries/sec 8 allocs/query 392 B/query 75 | 3.685228641s 67838 queries/sec 8 allocs/query 392 B/query 76 | 3.690438516s 67743 queries/sec 8 allocs/query 392 B/query 77 | -- avg 67824 qps; median 67838 qps 78 | Go-MySQL-Driver 1.0 79 | 3.46375733s 72176 queries/sec 6 allocs/query 167 B/query 80 | 3.463701957s 72177 queries/sec 6 allocs/query 167 B/query 81 | 3.465739159s 72135 queries/sec 6 allocs/query 167 B/query 82 | -- avg 72163 qps; median 72176 qps 83 | Go-MySQL-Driver 1.1 84 | 3.418759203s 73126 queries/sec 5 allocs/query 149 B/query 85 | 3.418744609s 73126 queries/sec 5 allocs/query 149 B/query 86 | 3.428505491s 72918 queries/sec 5 allocs/query 149 B/query 87 | -- avg 73057 qps; median 73126 qps 88 | 89 | SimpleQueryRow 250000 iterations 90 | mymysql godrv 91 | 5.802717679s 43083 queries/sec 26 allocs/query 1177 B/query 92 | 5.803354897s 43079 queries/sec 26 allocs/query 1177 B/query 93 | 5.800961587s 43096 queries/sec 26 allocs/query 1177 B/query 94 | -- avg 43086 qps; median 43083 qps 95 | Go-MySQL-Driver 1.0 96 | 5.063697563s 49371 queries/sec 13 allocs/query 395 B/query 97 | 5.056738087s 49439 queries/sec 13 allocs/query 395 B/query 98 | 5.068211838s 49327 queries/sec 13 allocs/query 395 B/query 99 | -- avg 49379 qps; median 49371 qps 100 | Go-MySQL-Driver 1.1 101 | 4.985966338s 50141 queries/sec 12 allocs/query 363 B/query 102 | 4.942562121s 50581 queries/sec 12 allocs/query 363 B/query 103 | 4.935405828s 50654 queries/sec 12 allocs/query 363 B/query 104 | -- avg 50458 qps; median 50581 qps 105 | 106 | PreparedQueryRow 250000 iterations 107 | mymysql godrv 108 | 6.245600097s 40028 queries/sec 29 allocs/query 1227 B/query 109 | 6.256448195s 39959 queries/sec 29 allocs/query 1226 B/query 110 | 6.238429435s 40074 queries/sec 29 allocs/query 1227 B/query 111 | -- avg 40020 qps; median 40028 qps 112 | Go-MySQL-Driver 1.0 113 | 5.351447088s 46716 queries/sec 17 allocs/query 457 B/query 114 | 5.340188319s 46815 queries/sec 17 allocs/query 457 B/query 115 | 5.341302407s 46805 queries/sec 17 allocs/query 457 B/query 116 | -- avg 46779 qps; median 46805 qps 117 | Go-MySQL-Driver 1.1 118 | 5.119802775s 48830 queries/sec 14 allocs/query 382 B/query 119 | 5.100032785s 49019 queries/sec 14 allocs/query 382 B/query 120 | 5.098174033s 49037 queries/sec 14 allocs/query 382 B/query 121 | -- avg 48962 qps; median 49019 qps 122 | 123 | PreparedQueryRowParam 250000 iterations 124 | mymysql godrv 125 | 6.878633952s 36344 queries/sec 32 allocs/query 1263 B/query 126 | 6.9165302s 36145 queries/sec 32 allocs/query 1263 B/query 127 | 6.888402455s 36293 queries/sec 32 allocs/query 1263 B/query 128 | -- avg 36261 qps; median 36293 qps 129 | Go-MySQL-Driver 1.0 130 | 5.598532572s 44655 queries/sec 21 allocs/query 540 B/query 131 | 5.591264361s 44713 queries/sec 21 allocs/query 540 B/query 132 | 5.680375421s 44011 queries/sec 21 allocs/query 540 B/query 133 | -- avg 44459 qps; median 44655 qps 134 | Go-MySQL-Driver 1.1 135 | 5.455894144s 45822 queries/sec 15 allocs/query 400 B/query 136 | 5.461734165s 45773 queries/sec 15 allocs/query 400 B/query 137 | 5.470208259s 45702 queries/sec 15 allocs/query 400 B/query 138 | -- avg 45766 qps; median 45773 qps 139 | 140 | EchoMixed5 250000 iterations 141 | mymysql godrv 142 | 8.773040358s 28496 queries/sec 58 allocs/query 2406 B/query 143 | 8.596984382s 29080 queries/sec 58 allocs/query 2406 B/query 144 | 8.657759663s 28876 queries/sec 58 allocs/query 2406 B/query 145 | -- avg 28817 qps; median 28876 qps 146 | Go-MySQL-Driver 1.0 147 | 6.823789206s 36637 queries/sec 32 allocs/query 1093 B/query 148 | 6.829033082s 36608 queries/sec 32 allocs/query 1092 B/query 149 | 6.825584568s 36627 queries/sec 32 allocs/query 1092 B/query 150 | -- avg 36624 qps; median 36627 qps 151 | Go-MySQL-Driver 1.1 152 | 6.212412594s 40242 queries/sec 17 allocs/query 644 B/query 153 | 6.201953199s 40310 queries/sec 17 allocs/query 644 B/query 154 | 6.227740014s 40143 queries/sec 17 allocs/query 644 B/query 155 | -- avg 40232 qps; median 40242 qps 156 | 157 | SelectLargeString 50000 iterations 158 | mymysql godrv 159 | 3.710482335s 13475 queries/sec 26 allocs/query 21688 B/query 160 | 3.72813078s 13412 queries/sec 26 allocs/query 21688 B/query 161 | 3.71555593s 13457 queries/sec 26 allocs/query 21688 B/query 162 | -- avg 13448 qps; median 13457 qps 163 | Go-MySQL-Driver 1.0 164 | 3.382473045s 14782 queries/sec 13 allocs/query 10656 B/query 165 | 3.38769337s 14759 queries/sec 13 allocs/query 10656 B/query 166 | 3.366275121s 14853 queries/sec 13 allocs/query 10656 B/query 167 | -- avg 14798 qps; median 14782 qps 168 | Go-MySQL-Driver 1.1 169 | 3.273157066s 15276 queries/sec 12 allocs/query 10608 B/query 170 | 3.279537597s 15246 queries/sec 12 allocs/query 10608 B/query 171 | 3.282647996s 15232 queries/sec 12 allocs/query 10608 B/query 172 | -- avg 15251 qps; median 15246 qps 173 | 174 | SelectPreparedLargeString 50000 iterations 175 | mymysql godrv 176 | 3.729359051s 13407 queries/sec 31 allocs/query 21752 B/query 177 | 3.709282036s 13480 queries/sec 31 allocs/query 21752 B/query 178 | 3.718004082s 13448 queries/sec 31 allocs/query 21752 B/query 179 | -- avg 13445 qps; median 13448 qps 180 | Go-MySQL-Driver 1.0 181 | 3.30230472s 15141 queries/sec 18 allocs/query 10728 B/query 182 | 3.287424383s 15209 queries/sec 18 allocs/query 10728 B/query 183 | 3.290013005s 15198 queries/sec 18 allocs/query 10728 B/query 184 | -- avg 15183 qps; median 15198 qps 185 | Go-MySQL-Driver 1.1 186 | 3.24534887s 15407 queries/sec 15 allocs/query 10632 B/query 187 | 3.243725426s 15414 queries/sec 15 allocs/query 10632 B/query 188 | 3.242123356s 15422 queries/sec 15 allocs/query 10632 B/query 189 | -- avg 15414 qps; median 15414 qps 190 | 191 | SelectLargeBytes 50000 iterations 192 | mymysql godrv 193 | 3.758672532s 13303 queries/sec 26 allocs/query 21688 B/query 194 | 3.736869351s 13380 queries/sec 26 allocs/query 21688 B/query 195 | 3.824912123s 13072 queries/sec 26 allocs/query 21688 B/query 196 | -- avg 13252 qps; median 13303 qps 197 | Go-MySQL-Driver 1.0 198 | 3.288067334s 15207 queries/sec 13 allocs/query 10656 B/query 199 | 3.289624359s 15199 queries/sec 13 allocs/query 10656 B/query 200 | 3.28935065s 15201 queries/sec 13 allocs/query 10656 B/query 201 | -- avg 15202 qps; median 15201 qps 202 | Go-MySQL-Driver 1.1 203 | 3.268010834s 15300 queries/sec 12 allocs/query 10608 B/query 204 | 3.266943391s 15305 queries/sec 12 allocs/query 10608 B/query 205 | 3.272072635s 15281 queries/sec 12 allocs/query 10608 B/query 206 | -- avg 15295 qps; median 15300 qps 207 | 208 | SelectPreparedLargeBytes 50000 iterations 209 | mymysql godrv 210 | 3.704054898s 13499 queries/sec 31 allocs/query 21752 B/query 211 | 3.707255824s 13487 queries/sec 31 allocs/query 21752 B/query 212 | 3.700564381s 13511 queries/sec 31 allocs/query 21752 B/query 213 | -- avg 13499 qps; median 13499 qps 214 | Go-MySQL-Driver 1.0 215 | 3.293667657s 15181 queries/sec 18 allocs/query 10728 B/query 216 | 3.281278474s 15238 queries/sec 18 allocs/query 10728 B/query 217 | 3.284310328s 15224 queries/sec 18 allocs/query 10728 B/query 218 | -- avg 15214 qps; median 15224 qps 219 | Go-MySQL-Driver 1.1 220 | 3.242004446s 15423 queries/sec 15 allocs/query 10632 B/query 221 | 3.250628059s 15382 queries/sec 15 allocs/query 10632 B/query 222 | 3.241874523s 15423 queries/sec 15 allocs/query 10632 B/query 223 | -- avg 15409 qps; median 15423 qps 224 | 225 | SelectLargeRaw 50000 iterations 226 | mymysql godrv 227 | 3.495386785s 14305 queries/sec 24 allocs/query 11419 B/query 228 | 3.487362519s 14337 queries/sec 24 allocs/query 11419 B/query 229 | 3.487310296s 14338 queries/sec 24 allocs/query 11419 B/query 230 | -- avg 14327 qps; median 14337 qps 231 | Go-MySQL-Driver 1.0 232 | 3.085953618s 16202 queries/sec 11 allocs/query 397 B/query 233 | 3.07629808s 16253 queries/sec 11 allocs/query 397 B/query 234 | 3.078047696s 16244 queries/sec 11 allocs/query 397 B/query 235 | -- avg 16233 qps; median 16244 qps 236 | Go-MySQL-Driver 1.1 237 | 3.056899867s 16356 queries/sec 10 allocs/query 348 B/query 238 | 3.059649175s 16342 queries/sec 10 allocs/query 348 B/query 239 | 3.059414835s 16343 queries/sec 10 allocs/query 348 B/query 240 | -- avg 16347 qps; median 16343 qps 241 | 242 | SelectPreparedLargeRaw 50000 iterations 243 | mymysql godrv 244 | 3.485924755s 14343 queries/sec 29 allocs/query 11483 B/query 245 | 3.486648758s 14340 queries/sec 29 allocs/query 11483 B/query 246 | 3.493145476s 14314 queries/sec 29 allocs/query 11483 B/query 247 | -- avg 14333 qps; median 14340 qps 248 | Go-MySQL-Driver 1.0 249 | 3.079810302s 16235 queries/sec 16 allocs/query 473 B/query 250 | 3.075175601s 16259 queries/sec 16 allocs/query 472 B/query 251 | 3.080132071s 16233 queries/sec 16 allocs/query 473 B/query 252 | -- avg 16242 qps; median 16235 qps 253 | Go-MySQL-Driver 1.1 254 | 3.034226559s 16479 queries/sec 13 allocs/query 374 B/query 255 | 3.035156325s 16474 queries/sec 13 allocs/query 373 B/query 256 | 3.035375902s 16472 queries/sec 13 allocs/query 373 B/query 257 | -- avg 16475 qps; median 16474 qps 258 | 259 | PreparedExecConcurrent1 500000 iterations 260 | mymysql godrv 261 | 7.412726791s 67452 queries/sec 8 allocs/query 392 B/query 262 | 7.595283865s 65830 queries/sec 8 allocs/query 392 B/query 263 | 7.582002016s 65946 queries/sec 8 allocs/query 392 B/query 264 | -- avg 66409 qps; median 65946 qps 265 | Go-MySQL-Driver 1.0 266 | 6.921190296s 72242 queries/sec 6 allocs/query 167 B/query 267 | 6.898444843s 72480 queries/sec 6 allocs/query 166 B/query 268 | 6.899012692s 72474 queries/sec 6 allocs/query 166 B/query 269 | -- avg 72399 qps; median 72474 qps 270 | Go-MySQL-Driver 1.1 271 | 6.842107045s 73077 queries/sec 5 allocs/query 149 B/query 272 | 6.825865048s 73251 queries/sec 5 allocs/query 149 B/query 273 | 6.831175178s 73194 queries/sec 5 allocs/query 149 B/query 274 | -- avg 73174 qps; median 73194 qps 275 | 276 | PreparedExecConcurrent2 500000 iterations 277 | mymysql godrv 278 | 3.44565992s 145110 queries/sec 8 allocs/query 392 B/query 279 | 3.505009461s 142653 queries/sec 8 allocs/query 392 B/query 280 | 3.446869762s 145059 queries/sec 8 allocs/query 392 B/query 281 | -- avg 144274 qps; median 145059 qps 282 | Go-MySQL-Driver 1.0 283 | 2.90463481s 172139 queries/sec 6 allocs/query 167 B/query 284 | 2.899396938s 172450 queries/sec 6 allocs/query 166 B/query 285 | 2.90158597s 172320 queries/sec 6 allocs/query 166 B/query 286 | -- avg 172303 qps; median 172320 qps 287 | Go-MySQL-Driver 1.1 288 | 2.819298666s 177349 queries/sec 5 allocs/query 149 B/query 289 | 2.828106403s 176797 queries/sec 5 allocs/query 149 B/query 290 | 2.82974316s 176694 queries/sec 5 allocs/query 149 B/query 291 | -- avg 176947 qps; median 176797 qps 292 | 293 | PreparedExecConcurrent4 500000 iterations 294 | mymysql godrv 295 | 3.42759382s 145875 queries/sec 8 allocs/query 392 B/query 296 | 3.434183403s 145595 queries/sec 8 allocs/query 392 B/query 297 | 3.422888817s 146075 queries/sec 8 allocs/query 392 B/query 298 | -- avg 145848 qps; median 145875 qps 299 | Go-MySQL-Driver 1.0 300 | 2.955758093s 169161 queries/sec 6 allocs/query 167 B/query 301 | 2.956442816s 169122 queries/sec 6 allocs/query 167 B/query 302 | 2.956962873s 169092 queries/sec 6 allocs/query 167 B/query 303 | -- avg 169125 qps; median 169122 qps 304 | Go-MySQL-Driver 1.1 305 | 2.902781851s 172249 queries/sec 5 allocs/query 149 B/query 306 | 2.893675059s 172791 queries/sec 5 allocs/query 149 B/query 307 | 2.881353501s 173530 queries/sec 5 allocs/query 149 B/query 308 | -- avg 172856 qps; median 172791 qps 309 | 310 | PreparedExecConcurrent8 500000 iterations 311 | mymysql godrv 312 | 3.500235814s 142848 queries/sec 8 allocs/query 392 B/query 313 | 3.507999161s 142531 queries/sec 8 allocs/query 392 B/query 314 | 3.497887883s 142943 queries/sec 8 allocs/query 392 B/query 315 | -- avg 142774 qps; median 142848 qps 316 | Go-MySQL-Driver 1.0 317 | 3.026177405s 165225 queries/sec 6 allocs/query 167 B/query 318 | 3.026883385s 165186 queries/sec 6 allocs/query 167 B/query 319 | 3.020821566s 165518 queries/sec 6 allocs/query 167 B/query 320 | -- avg 165310 qps; median 165225 qps 321 | Go-MySQL-Driver 1.1 322 | 2.954903265s 169210 queries/sec 5 allocs/query 150 B/query 323 | 2.965571144s 168602 queries/sec 5 allocs/query 150 B/query 324 | 2.96929521s 168390 queries/sec 5 allocs/query 150 B/query 325 | -- avg 168734 qps; median 168602 qps 326 | 327 | PreparedExecConcurrent16 500000 iterations 328 | mymysql godrv 329 | 3.722864558s 134305 queries/sec 8 allocs/query 393 B/query 330 | 3.701155651s 135093 queries/sec 8 allocs/query 393 B/query 331 | 3.708896696s 134811 queries/sec 8 allocs/query 393 B/query 332 | -- avg 134736 qps; median 134811 qps 333 | Go-MySQL-Driver 1.0 334 | 3.211510336s 155690 queries/sec 6 allocs/query 167 B/query 335 | 3.204158577s 156047 queries/sec 6 allocs/query 167 B/query 336 | 3.189459753s 156766 queries/sec 6 allocs/query 167 B/query 337 | -- avg 156168 qps; median 156047 qps 338 | Go-MySQL-Driver 1.1 339 | 3.128369303s 159828 queries/sec 5 allocs/query 150 B/query 340 | 3.11130211s 160704 queries/sec 5 allocs/query 150 B/query 341 | 3.139291582s 159272 queries/sec 5 allocs/query 150 B/query 342 | -- avg 159935 qps; median 159828 qps 343 | 344 | PreparedQueryConcurrent1 500000 iterations 345 | mymysql godrv 346 | 14.533103278s 34404 queries/sec 39 allocs/query 1555 B/query 347 | 14.340936029s 34865 queries/sec 39 allocs/query 1555 B/query 348 | 14.507614095s 34465 queries/sec 39 allocs/query 1555 B/query 349 | -- avg 34578 qps; median 34465 qps 350 | Go-MySQL-Driver 1.0 351 | 11.62010633s 43029 queries/sec 24 allocs/query 645 B/query 352 | 11.615208271s 43047 queries/sec 24 allocs/query 645 B/query 353 | 11.656044242s 42896 queries/sec 24 allocs/query 645 B/query 354 | -- avg 42991 qps; median 43029 qps 355 | Go-MySQL-Driver 1.1 356 | 10.998830961s 45459 queries/sec 17 allocs/query 476 B/query 357 | 11.014426678s 45395 queries/sec 17 allocs/query 476 B/query 358 | 10.979119615s 45541 queries/sec 17 allocs/query 476 B/query 359 | -- avg 45465 qps; median 45459 qps 360 | 361 | PreparedQueryConcurrent2 500000 iterations 362 | mymysql godrv 363 | 7.831652593s 63843 queries/sec 39 allocs/query 1553 B/query 364 | 7.842288669s 63757 queries/sec 39 allocs/query 1553 B/query 365 | 7.797480045s 64123 queries/sec 39 allocs/query 1553 B/query 366 | -- avg 63908 qps; median 63843 qps 367 | Go-MySQL-Driver 1.0 368 | 5.278819724s 94718 queries/sec 24 allocs/query 645 B/query 369 | 5.291427353s 94492 queries/sec 24 allocs/query 645 B/query 370 | 5.278954458s 94716 queries/sec 24 allocs/query 645 B/query 371 | -- avg 94642 qps; median 94716 qps 372 | Go-MySQL-Driver 1.1 373 | 4.830366589s 103512 queries/sec 17 allocs/query 476 B/query 374 | 4.831139401s 103495 queries/sec 17 allocs/query 476 B/query 375 | 4.834301429s 103428 queries/sec 17 allocs/query 476 B/query 376 | -- avg 103478 qps; median 103495 qps 377 | 378 | PreparedQueryConcurrent4 500000 iterations 379 | mymysql godrv 380 | 7.951862714s 62878 queries/sec 39 allocs/query 1552 B/query 381 | 7.935456591s 63008 queries/sec 39 allocs/query 1553 B/query 382 | 8.00026767s 62498 queries/sec 39 allocs/query 1553 B/query 383 | -- avg 62795 qps; median 62878 qps 384 | Go-MySQL-Driver 1.0 385 | 5.378643813s 92960 queries/sec 24 allocs/query 644 B/query 386 | 5.332978832s 93756 queries/sec 24 allocs/query 644 B/query 387 | 5.360460591s 93276 queries/sec 24 allocs/query 644 B/query 388 | -- avg 93331 qps; median 93276 qps 389 | Go-MySQL-Driver 1.1 390 | 4.926703513s 101488 queries/sec 17 allocs/query 476 B/query 391 | 4.937515591s 101266 queries/sec 17 allocs/query 476 B/query 392 | 4.915720468s 101714 queries/sec 17 allocs/query 476 B/query 393 | -- avg 101489 qps; median 101488 qps 394 | 395 | PreparedQueryConcurrent8 500000 iterations 396 | mymysql godrv 397 | 7.971771249s 62721 queries/sec 39 allocs/query 1554 B/query 398 | 8.008622996s 62433 queries/sec 39 allocs/query 1554 B/query 399 | 8.016234752s 62373 queries/sec 39 allocs/query 1553 B/query 400 | -- avg 62509 qps; median 62433 qps 401 | Go-MySQL-Driver 1.0 402 | 5.409094898s 92437 queries/sec 24 allocs/query 643 B/query 403 | 5.407859645s 92458 queries/sec 24 allocs/query 643 B/query 404 | 5.427255858s 92128 queries/sec 24 allocs/query 643 B/query 405 | -- avg 92341 qps; median 92437 qps 406 | Go-MySQL-Driver 1.1 407 | 4.9584675s 100838 queries/sec 17 allocs/query 476 B/query 408 | 4.977183317s 100458 queries/sec 17 allocs/query 475 B/query 409 | 4.957529888s 100857 queries/sec 17 allocs/query 476 B/query 410 | -- avg 100718 qps; median 100838 qps 411 | 412 | PreparedQueryConcurrent16 500000 iterations 413 | mymysql godrv 414 | 8.11024536s 61650 queries/sec 39 allocs/query 1551 B/query 415 | 8.04783136s 62129 queries/sec 39 allocs/query 1551 B/query 416 | 8.105189303s 61689 queries/sec 39 allocs/query 1551 B/query 417 | -- avg 61823 qps; median 61689 qps 418 | Go-MySQL-Driver 1.0 419 | 5.643842747s 88592 queries/sec 24 allocs/query 643 B/query 420 | 5.629226543s 88822 queries/sec 24 allocs/query 642 B/query 421 | 5.642114369s 88619 queries/sec 24 allocs/query 643 B/query 422 | -- avg 88678 qps; median 88619 qps 423 | Go-MySQL-Driver 1.1 424 | 5.166585448s 96776 queries/sec 17 allocs/query 475 B/query 425 | 5.138424004s 97306 queries/sec 17 allocs/query 475 B/query 426 | 5.156050123s 96973 queries/sec 17 allocs/query 475 B/query 427 | -- avg 97018 qps; median 96973 qps 428 | 429 | Finished... Total running time: 16m20.053874375s 430 | 431 | ``` 432 | -------------------------------------------------------------------------------- /results/results-osx_2013-03-19.md: -------------------------------------------------------------------------------- 1 | ### Setup 2 | * Intel Core i7 (2.20 GHz), 16 GB RAM 3 | * OS X 10.8.3 (12D78); full disk encryption enabled 4 | * MySQL 5.6.10 Source distribution (`brew install mysql` without configuration changes) 5 | * Current [Go-MySQL-Driver](https://github.com/Go-SQL-Driver/MySQL) and [mymysql](https://github.com/ziutek/mymysql) versions as of March 19, 2013 6 | * Java7 (JDBC) + MySQL Connector/J 5.1.24 for comparison 7 | 8 | ### Results for go 1.0.3 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 |
BenchmarkGo-MySQL-Drivermymysql godrvJava (JDBC) + MySQL Connector/J 5.1.24
SimpleQuery2873 queries/second2407 queries/second4088 queries/second
PreparedQuery3843 queries/second3004 queries/second3369 queries/second
AutoQueryRow4795 queries/second4623 queries/second- queries/second
SimpleQueryRow4932 queries/second4800 queries/second8463 queries/second
PreparedQueryRow8544 queries/second8714 queries/second5200 queries/second
SimpleExec14332 queries/second14808 queries/second15620 queries/second
PreparedExec15118 queries/second15780 queries/second15454 queries/second
59 | 60 | ### Results for go tip 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 |
BenchmarkGo-MySQL-Drivermymysql godrvJava (JDBC) + MySQL Connector/J 5.1.24
SimpleQuery3983 queries/second3303 queries/second4088 queries/second
PreparedQuery4655 queries/second3758 queries/second3369 queries/second
AutoQueryRow5755 queries/second8526* queries/second- queries/second
SimpleQueryRow8585 queries/second8571 queries/second8463 queries/second
PreparedQueryRow9652 queries/second9166 queries/second5200 queries/second
SimpleExec20784 queries/second20050 queries/second15620 queries/second
PreparedExec23588 queries/second22753 queries/second15454 queries/second
111 | 112 | `* AutoQueryRow`: mymysql builds a single query string instead of using prepared statements 113 | 114 | ### Original Logs 115 | #### Go 1.0.3 116 | ``` 117 | $ go version 118 | go version go1.0.3 119 | ``` 120 | ##### Run 1 121 | ``` 122 | ************************************************************* 123 | BENCHMARKING Go-MySQL-Driver [run 1] 124 | ************************************************************* 125 | 126 | ------------------------------------------------------------- 127 | [10000 * Query 100 Rows] 128 | ------------------------------------------------------------- 129 | SimpleQuery: 3.413593s [ 2929 queries/second ] 130 | PreparedQuery: 2.593549s [ 3856 queries/second ] 131 | 132 | ------------------------------------------------------------- 133 | [100 * QueryRow] * 1000 134 | ------------------------------------------------------------- 135 | AutoQueryRow: 20.42619s [ 4896 queries/second ] 136 | SimpleQueryRow: 19.975014s [ 5006 queries/second ] 137 | PreparedQueryRow: 11.704284s [ 8544 queries/second ] 138 | 139 | ------------------------------------------------------------- 140 | [100000 * Exec] 141 | ------------------------------------------------------------- 142 | SimpleExec: 6.977532s [ 14332 queries/second ] 143 | PreparedExec: 6.614706s [ 15118 queries/second ] 144 | 145 | 146 | ************************************************************* 147 | BENCHMARKING mymysql godrv [run 1] 148 | ************************************************************* 149 | 150 | ------------------------------------------------------------- 151 | [10000 * Query 100 Rows] 152 | ------------------------------------------------------------- 153 | SimpleQuery: 4.154453s [ 2407 queries/second ] 154 | PreparedQuery: 3.328669s [ 3004 queries/second ] 155 | 156 | ------------------------------------------------------------- 157 | [100 * QueryRow] * 1000 158 | ------------------------------------------------------------- 159 | AutoQueryRow: 21.632837s [ 4623 queries/second ] 160 | SimpleQueryRow: 20.809298s [ 4806 queries/second ] 161 | PreparedQueryRow: 11.323829s [ 8831 queries/second ] 162 | 163 | ------------------------------------------------------------- 164 | [100000 * Exec] 165 | ------------------------------------------------------------- 166 | SimpleExec: 6.736055s [ 14845 queries/second ] 167 | PreparedExec: 6.290393s [ 15897 queries/second ] 168 | 169 | 170 | ************************************************************* 171 | BENCHMARKING Go-MySQL-Driver [run 2] 172 | ************************************************************* 173 | 174 | ------------------------------------------------------------- 175 | [10000 * Query 100 Rows] 176 | ------------------------------------------------------------- 177 | SimpleQuery: 3.437407s [ 2909 queries/second ] 178 | PreparedQuery: 2.562842s [ 3902 queries/second ] 179 | 180 | ------------------------------------------------------------- 181 | [100 * QueryRow] * 1000 182 | ------------------------------------------------------------- 183 | AutoQueryRow: 20.436384s [ 4893 queries/second ] 184 | SimpleQueryRow: 20.08296s [ 4979 queries/second ] 185 | PreparedQueryRow: 10.953022s [ 9130 queries/second ] 186 | 187 | ------------------------------------------------------------- 188 | [100000 * Exec] 189 | ------------------------------------------------------------- 190 | SimpleExec: 6.738728s [ 14840 queries/second ] 191 | PreparedExec: 6.263373s [ 15966 queries/second ] 192 | 193 | 194 | ************************************************************* 195 | BENCHMARKING mymysql godrv [run 2] 196 | ************************************************************* 197 | 198 | ------------------------------------------------------------- 199 | [10000 * Query 100 Rows] 200 | ------------------------------------------------------------- 201 | SimpleQuery: 4.121502s [ 2426 queries/second ] 202 | PreparedQuery: 3.289298s [ 3040 queries/second ] 203 | 204 | ------------------------------------------------------------- 205 | [100 * QueryRow] * 1000 206 | ------------------------------------------------------------- 207 | AutoQueryRow: 21.343546s [ 4685 queries/second ] 208 | SimpleQueryRow: 20.832256s [ 4800 queries/second ] 209 | PreparedQueryRow: 11.37943s [ 8788 queries/second ] 210 | 211 | ------------------------------------------------------------- 212 | [100000 * Exec] 213 | ------------------------------------------------------------- 214 | SimpleExec: 6.673795s [ 14984 queries/second ] 215 | PreparedExec: 6.299963s [ 15873 queries/second ] 216 | ``` 217 | ##### Run 2 218 | ``` 219 | ************************************************************* 220 | BENCHMARKING Go-MySQL-Driver [run 1] 221 | ************************************************************* 222 | 223 | ------------------------------------------------------------- 224 | [10000 * Query 100 Rows] 225 | ------------------------------------------------------------- 226 | SimpleQuery: 3.480331s [ 2873 queries/second ] 227 | PreparedQuery: 2.578976s [ 3878 queries/second ] 228 | 229 | ------------------------------------------------------------- 230 | [100 * QueryRow] * 1000 231 | ------------------------------------------------------------- 232 | AutoQueryRow: 20.853913s [ 4795 queries/second ] 233 | SimpleQueryRow: 20.276176s [ 4932 queries/second ] 234 | PreparedQueryRow: 10.959359s [ 9125 queries/second ] 235 | 236 | ------------------------------------------------------------- 237 | [100000 * Exec] 238 | ------------------------------------------------------------- 239 | SimpleExec: 6.664772s [ 15004 queries/second ] 240 | PreparedExec: 6.208022s [ 16108 queries/second ] 241 | 242 | 243 | ************************************************************* 244 | BENCHMARKING mymysql godrv [run 1] 245 | ************************************************************* 246 | 247 | ------------------------------------------------------------- 248 | [10000 * Query 100 Rows] 249 | ------------------------------------------------------------- 250 | SimpleQuery: 4.125382s [ 2424 queries/second ] 251 | PreparedQuery: 3.29141s [ 3038 queries/second ] 252 | 253 | ------------------------------------------------------------- 254 | [100 * QueryRow] * 1000 255 | ------------------------------------------------------------- 256 | AutoQueryRow: 21.116172s [ 4736 queries/second ] 257 | SimpleQueryRow: 20.764883s [ 4816 queries/second ] 258 | PreparedQueryRow: 11.40949s [ 8765 queries/second ] 259 | 260 | ------------------------------------------------------------- 261 | [100000 * Exec] 262 | ------------------------------------------------------------- 263 | SimpleExec: 6.653944s [ 15029 queries/second ] 264 | PreparedExec: 6.260656s [ 15973 queries/second ] 265 | 266 | 267 | ************************************************************* 268 | BENCHMARKING Go-MySQL-Driver [run 2] 269 | ************************************************************* 270 | 271 | ------------------------------------------------------------- 272 | [10000 * Query 100 Rows] 273 | ------------------------------------------------------------- 274 | SimpleQuery: 3.450241s [ 2898 queries/second ] 275 | PreparedQuery: 2.60198s [ 3843 queries/second ] 276 | 277 | ------------------------------------------------------------- 278 | [100 * QueryRow] * 1000 279 | ------------------------------------------------------------- 280 | AutoQueryRow: 20.501758s [ 4878 queries/second ] 281 | SimpleQueryRow: 20.113424s [ 4972 queries/second ] 282 | PreparedQueryRow: 10.811276s [ 9250 queries/second ] 283 | 284 | ------------------------------------------------------------- 285 | [100000 * Exec] 286 | ------------------------------------------------------------- 287 | SimpleExec: 6.598204s [ 15156 queries/second ] 288 | PreparedExec: 6.202888s [ 16122 queries/second ] 289 | 290 | 291 | ************************************************************* 292 | BENCHMARKING mymysql godrv [run 2] 293 | ************************************************************* 294 | 295 | ------------------------------------------------------------- 296 | [10000 * Query 100 Rows] 297 | ------------------------------------------------------------- 298 | SimpleQuery: 4.111154s [ 2432 queries/second ] 299 | PreparedQuery: 3.316876s [ 3015 queries/second ] 300 | 301 | ------------------------------------------------------------- 302 | [100 * QueryRow] * 1000 303 | ------------------------------------------------------------- 304 | AutoQueryRow: 21.104781s [ 4738 queries/second ] 305 | SimpleQueryRow: 20.834429s [ 4800 queries/second ] 306 | PreparedQueryRow: 11.475476s [ 8714 queries/second ] 307 | 308 | ------------------------------------------------------------- 309 | [100000 * Exec] 310 | ------------------------------------------------------------- 311 | SimpleExec: 6.752991s [ 14808 queries/second ] 312 | PreparedExec: 6.337248s [ 15780 queries/second ] 313 | ``` 314 | 315 | #### Go tip 316 | ``` 317 | $ go version 318 | go version devel +786e094255c9 Tue Mar 19 07:08:26 2013 +0100 darwin/amd64 319 | ``` 320 | 321 | ##### Run 1 322 | ``` 323 | ************************************************************* 324 | BENCHMARKING Go-MySQL-Driver [run 1] 325 | ************************************************************* 326 | 327 | ------------------------------------------------------------- 328 | [10000 * Query 100 Rows] 329 | ------------------------------------------------------------- 330 | SimpleQuery: 2.510925006s [ 3983 queries/second ] 331 | PreparedQuery: 2.14814344s [ 4655 queries/second ] 332 | 333 | ------------------------------------------------------------- 334 | [100 * QueryRow] * 1000 335 | ------------------------------------------------------------- 336 | AutoQueryRow: 17.376778601s [ 5755 queries/second ] 337 | SimpleQueryRow: 11.327457312s [ 8828 queries/second ] 338 | PreparedQueryRow: 10.301616676s [ 9707 queries/second ] 339 | 340 | ------------------------------------------------------------- 341 | [100000 * Exec] 342 | ------------------------------------------------------------- 343 | SimpleExec: 4.638879971s [ 21557 queries/second ] 344 | PreparedExec: 4.178864187s [ 23930 queries/second ] 345 | 346 | 347 | ************************************************************* 348 | BENCHMARKING mymysql godrv [run 1] 349 | ************************************************************* 350 | 351 | ------------------------------------------------------------- 352 | [10000 * Query 100 Rows] 353 | ------------------------------------------------------------- 354 | SimpleQuery: 3.020216718s [ 3311 queries/second ] 355 | PreparedQuery: 2.660903352s [ 3758 queries/second ] 356 | 357 | ------------------------------------------------------------- 358 | [100 * QueryRow] * 1000 359 | ------------------------------------------------------------- 360 | AutoQueryRow: 11.575896249s [ 8639 queries/second ] 361 | SimpleQueryRow: 11.574478322s [ 8640 queries/second ] 362 | PreparedQueryRow: 10.824283133s [ 9238 queries/second ] 363 | 364 | ------------------------------------------------------------- 365 | [100000 * Exec] 366 | ------------------------------------------------------------- 367 | SimpleExec: 4.867722732s [ 20543 queries/second ] 368 | PreparedExec: 4.341147858s [ 23035 queries/second ] 369 | 370 | 371 | ************************************************************* 372 | BENCHMARKING Go-MySQL-Driver [run 2] 373 | ************************************************************* 374 | 375 | ------------------------------------------------------------- 376 | [10000 * Query 100 Rows] 377 | ------------------------------------------------------------- 378 | SimpleQuery: 2.50137433s [ 3998 queries/second ] 379 | PreparedQuery: 2.146637653s [ 4658 queries/second ] 380 | 381 | ------------------------------------------------------------- 382 | [100 * QueryRow] * 1000 383 | ------------------------------------------------------------- 384 | AutoQueryRow: 17.357114312s [ 5761 queries/second ] 385 | SimpleQueryRow: 11.647742719s [ 8585 queries/second ] 386 | PreparedQueryRow: 10.360052005s [ 9652 queries/second ] 387 | 388 | ------------------------------------------------------------- 389 | [100000 * Exec] 390 | ------------------------------------------------------------- 391 | SimpleExec: 4.695827143s [ 21296 queries/second ] 392 | PreparedExec: 4.177790515s [ 23936 queries/second ] 393 | 394 | 395 | ************************************************************* 396 | BENCHMARKING mymysql godrv [run 2] 397 | ************************************************************* 398 | 399 | ------------------------------------------------------------- 400 | [10000 * Query 100 Rows] 401 | ------------------------------------------------------------- 402 | SimpleQuery: 2.991561306s [ 3343 queries/second ] 403 | PreparedQuery: 2.643930236s [ 3782 queries/second ] 404 | 405 | ------------------------------------------------------------- 406 | [100 * QueryRow] * 1000 407 | ------------------------------------------------------------- 408 | AutoQueryRow: 11.573065959s [ 8641 queries/second ] 409 | SimpleQueryRow: 11.557347126s [ 8653 queries/second ] 410 | PreparedQueryRow: 10.780680308s [ 9276 queries/second ] 411 | 412 | ------------------------------------------------------------- 413 | [100000 * Exec] 414 | ------------------------------------------------------------- 415 | SimpleExec: 4.955322367s [ 20180 queries/second ] 416 | PreparedExec: 4.35608785s [ 22956 queries/second ] 417 | ``` 418 | 419 | ##### Run 2 420 | ``` 421 | ************************************************************* 422 | BENCHMARKING Go-MySQL-Driver [run 1] 423 | ************************************************************* 424 | 425 | ------------------------------------------------------------- 426 | [10000 * Query 100 Rows] 427 | ------------------------------------------------------------- 428 | SimpleQuery: 2.492747789s [ 4012 queries/second ] 429 | PreparedQuery: 2.140412159s [ 4672 queries/second ] 430 | 431 | ------------------------------------------------------------- 432 | [100 * QueryRow] * 1000 433 | ------------------------------------------------------------- 434 | AutoQueryRow: 17.099773537s [ 5848 queries/second ] 435 | SimpleQueryRow: 11.079477674s [ 9026 queries/second ] 436 | PreparedQueryRow: 10.330586657s [ 9680 queries/second ] 437 | 438 | ------------------------------------------------------------- 439 | [100000 * Exec] 440 | ------------------------------------------------------------- 441 | SimpleExec: 4.615779532s [ 21665 queries/second ] 442 | PreparedExec: 4.14832651s [ 24106 queries/second ] 443 | 444 | 445 | ************************************************************* 446 | BENCHMARKING mymysql godrv [run 1] 447 | ************************************************************* 448 | 449 | ------------------------------------------------------------- 450 | [10000 * Query 100 Rows] 451 | ------------------------------------------------------------- 452 | SimpleQuery: 3.027637513s [ 3303 queries/second ] 453 | PreparedQuery: 2.652219341s [ 3770 queries/second ] 454 | 455 | ------------------------------------------------------------- 456 | [100 * QueryRow] * 1000 457 | ------------------------------------------------------------- 458 | AutoQueryRow: 11.568385456s [ 8644 queries/second ] 459 | SimpleQueryRow: 11.533978356s [ 8670 queries/second ] 460 | PreparedQueryRow: 10.774763586s [ 9281 queries/second ] 461 | 462 | ------------------------------------------------------------- 463 | [100000 * Exec] 464 | ------------------------------------------------------------- 465 | SimpleExec: 4.779220431s [ 20924 queries/second ] 466 | PreparedExec: 4.321005243s [ 23143 queries/second ] 467 | 468 | 469 | ************************************************************* 470 | BENCHMARKING Go-MySQL-Driver [run 2] 471 | ************************************************************* 472 | 473 | ------------------------------------------------------------- 474 | [10000 * Query 100 Rows] 475 | ------------------------------------------------------------- 476 | SimpleQuery: 2.508798034s [ 3986 queries/second ] 477 | PreparedQuery: 2.141992203s [ 4669 queries/second ] 478 | 479 | ------------------------------------------------------------- 480 | [100 * QueryRow] * 1000 481 | ------------------------------------------------------------- 482 | AutoQueryRow: 17.281003539s [ 5787 queries/second ] 483 | SimpleQueryRow: 11.285806624s [ 8861 queries/second ] 484 | PreparedQueryRow: 10.311076985s [ 9698 queries/second ] 485 | 486 | ------------------------------------------------------------- 487 | [100000 * Exec] 488 | ------------------------------------------------------------- 489 | SimpleExec: 4.811444584s [ 20784 queries/second ] 490 | PreparedExec: 4.239370382s [ 23588 queries/second ] 491 | 492 | 493 | ************************************************************* 494 | BENCHMARKING mymysql godrv [run 2] 495 | ************************************************************* 496 | 497 | ------------------------------------------------------------- 498 | [10000 * Query 100 Rows] 499 | ------------------------------------------------------------- 500 | SimpleQuery: 3.006637533s [ 3326 queries/second ] 501 | PreparedQuery: 2.654193854s [ 3768 queries/second ] 502 | 503 | ------------------------------------------------------------- 504 | [100 * QueryRow] * 1000 505 | ------------------------------------------------------------- 506 | AutoQueryRow: 11.72828808s [ 8526 queries/second ] 507 | SimpleQueryRow: 11.667093527s [ 8571 queries/second ] 508 | PreparedQueryRow: 10.90937567s [ 9166 queries/second ] 509 | 510 | ------------------------------------------------------------- 511 | [100000 * Exec] 512 | ------------------------------------------------------------- 513 | SimpleExec: 4.987597721s [ 20050 queries/second ] 514 | PreparedExec: 4.395009337s [ 22753 queries/second ] 515 | ``` 516 | 517 | ### Java 518 | ``` 519 | $ java - version 520 | java version "1.7.0_15" 521 | Java(TM) SE Runtime Environment (build 1.7.0_15-b03) 522 | Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode) 523 | ``` 524 | 525 | ##### Run 1 526 | ``` 527 | ------------------------------------------------------------- 528 | [10000 * Query 100 Rows] 529 | ------------------------------------------------------------- 530 | SimpleQuery: 2.43s [ 4115 queries/second ] 531 | PreparedQuery: 2.968s [ 3369 queries/second ] 532 | 533 | ------------------------------------------------------------- 534 | [100 * QueryRow] * 1000 535 | ------------------------------------------------------------- 536 | SimpleQueryRow: 11.6s [ 8621 queries/second ] 537 | PreparedQueryRow: 19.185s [ 5212 queries/second ] 538 | 539 | ------------------------------------------------------------- 540 | [100000 * Exec] 541 | ------------------------------------------------------------- 542 | SimpleExec: 6.402s [ 15620 queries/second ] 543 | PreparedExec: 6.471s [ 15454 queries/second ] 544 | ``` 545 | 546 | ##### Run 2 547 | ``` 548 | ------------------------------------------------------------- 549 | [10000 * Query 100 Rows] 550 | ------------------------------------------------------------- 551 | SimpleQuery: 2.446s [ 4088 queries/second ] 552 | PreparedQuery: 2.914s [ 3432 queries/second ] 553 | 554 | ------------------------------------------------------------- 555 | [100 * QueryRow] * 1000 556 | ------------------------------------------------------------- 557 | SimpleQueryRow: 11.816s [ 8463 queries/second ] 558 | PreparedQueryRow: 19.201s [ 5208 queries/second ] 559 | 560 | ------------------------------------------------------------- 561 | [100000 * Exec] 562 | ------------------------------------------------------------- 563 | SimpleExec: 6.362s [ 15718 queries/second ] 564 | PreparedExec: 6.21s [ 16103 queries/second ] 565 | ``` 566 | 567 | ##### Run 3 568 | ``` 569 | ------------------------------------------------------------- 570 | [10000 * Query 100 Rows] 571 | ------------------------------------------------------------- 572 | SimpleQuery: 2.435s [ 4107 queries/second ] 573 | PreparedQuery: 2.931s [ 3412 queries/second ] 574 | 575 | ------------------------------------------------------------- 576 | [100 * QueryRow] * 1000 577 | ------------------------------------------------------------- 578 | SimpleQueryRow: 11.708s [ 8541 queries/second ] 579 | PreparedQueryRow: 19.161s [ 5219 queries/second ] 580 | 581 | ------------------------------------------------------------- 582 | [100000 * Exec] 583 | ------------------------------------------------------------- 584 | SimpleExec: 6.355s [ 15736 queries/second ] 585 | PreparedExec: 6.235s [ 16038 queries/second ] 586 | ``` 587 | 588 | ##### Run 4 589 | ``` 590 | ------------------------------------------------------------- 591 | [10000 * Query 100 Rows] 592 | ------------------------------------------------------------- 593 | SimpleQuery: 2.424s [ 4125 queries/second ] 594 | PreparedQuery: 2.899s [ 3449 queries/second ] 595 | 596 | ------------------------------------------------------------- 597 | [100 * QueryRow] * 1000 598 | ------------------------------------------------------------- 599 | SimpleQueryRow: 11.757s [ 8506 queries/second ] 600 | PreparedQueryRow: 19.232s [ 5200 queries/second ] 601 | 602 | ------------------------------------------------------------- 603 | [100000 * Exec] 604 | ------------------------------------------------------------- 605 | SimpleExec: 6.398s [ 15630 queries/second ] 606 | PreparedExec: 6.378s [ 15679 queries/second ] 607 | ``` 608 | --------------------------------------------------------------------------------