{"id":13764171,"url":"https://github.com/tyler-smith/golang-sql-benchmark","last_synced_at":"2025-05-10T18:31:12.931Z","repository":{"id":21131118,"uuid":"24432061","full_name":"tyler-smith/golang-sql-benchmark","owner":"tyler-smith","description":"A benchmarking shootout of various db/SQL utilities for Go","archived":false,"fork":false,"pushed_at":"2022-03-21T09:12:16.000Z","size":352,"stargazers_count":65,"open_issues_count":2,"forks_count":14,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-12T20:36:07.843Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tyler-smith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-24T20:47:26.000Z","updated_at":"2023-10-27T19:50:24.000Z","dependencies_parsed_at":"2022-08-26T23:21:26.298Z","dependency_job_id":null,"html_url":"https://github.com/tyler-smith/golang-sql-benchmark","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyler-smith%2Fgolang-sql-benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyler-smith%2Fgolang-sql-benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyler-smith%2Fgolang-sql-benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyler-smith%2Fgolang-sql-benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tyler-smith","download_url":"https://codeload.github.com/tyler-smith/golang-sql-benchmark/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253463473,"owners_count":21912834,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T15:01:17.550Z","updated_at":"2025-05-10T18:31:12.303Z","avatar_url":"https://github.com/tyler-smith.png","language":"Go","funding_links":[],"categories":["Benchmarks","基准","基准点","Twitter"],"sub_categories":["Other Software","其他软件"],"readme":"golang-db-sql-benchmark\n====================\n\nA collection of benchmarks for popular Go database/SQL utilities\n\n# Libraries under test\n\n*  [database/sql](https://golang.org/pkg/database/sql/) + [go-sql-driver/mysql](https://github.com/go-sql-driver/mysql)\n*  [gocraft/dbr](https://github.com/gocraft/dbr)\n*  [Gorp](https://github.com/coopernurse/gorp)\n*  [Sqlx](https://github.com/jmoiron/sqlx)\n*  [Squirrel](https://github.com/lann/squirrel)\n\n# database/sql SQL Execution Benchmarks:\n\n* **BenchmarkPreparedStatementsNone** - Runs simple queries without query arguments, so database/sql doesn't need to create a prepared statement\n* **BenchmarkPreparedStatementsThrowaway** - Runs queries with query arguments. database/sql must create and then throwaway a prepared statement each time\n* **BenchmarkPreparedStatementsSingle** - Runs queries with query arguments, but creates and reuses the a single prepared statement\n\n\n# Dbr/Sqlx/Gorp SQL Execution Benchmarks:\nEach library under test has the same set of benchmarks, just replace `Dbr` in the examples with `Sqlx` or `Gorp`.\nEach one is run with varying number of rows, N.\n\n* **BenchmarkDbrSelectIntsN** - Select rows of integers into []int64's\n* **BenchmarkDbrSelectAllN** - Select rows into structs using no query arguments\n* **BenchmarkDbrSelectAllWithArgsN** - Select rows into structs using query arguments\n\n# Dbr/Squrrel SQL Building Benchamrks\nTest building (but not executing) various SQL statements\n\n* **BenchmarkBuilderDbrSimple** - Simple SQL query with dbr\n* **BenchmarkBuilderDbrComplex** - Complex SQL query with dbr\n* **BenchmarkBuilderSquirrelSimple** - Simple SQL query with squirrel\n* **BenchmarkBuilderSquirrelComplex** - Complex SQL query with squirrel\n\n# Output\n\n`godep go test -bench=. -benchmem 2\u003e/dev/null | column -t` on @tyler-smith's 2.6 GHz i7 Macbook Pro:\n\n```\nBenchmarkPreparedStatementsNone       100000       23137     ns/op  612      B/op  20     allocs/op\nBenchmarkPreparedStatementsThrowaway  20000        94086     ns/op  795      B/op  25     allocs/op\nBenchmarkPreparedStatementsSingle     50000        33426     ns/op  652      B/op  23     allocs/op\n\nBenchmarkDbrSelectInts1               100000       30098     ns/op  1198     B/op  22     allocs/op\nBenchmarkDbrSelectInts100             20000        94477     ns/op  11645    B/op  426    allocs/op\nBenchmarkDbrSelectInts1000            5000         627958    ns/op  100574   B/op  4041   allocs/op\nBenchmarkDbrSelectInts10000           500          6207828   ns/op  1297929  B/op  40177  allocs/op\nBenchmarkDbrSelectAll1                50000        35468     ns/op  1876     B/op  60     allocs/op\nBenchmarkDbrSelectAll100              10000        157510    ns/op  29256    B/op  863    allocs/op\nBenchmarkDbrSelectAll1000             2000         1436856   ns/op  272365   B/op  8078   allocs/op\nBenchmarkDbrSelectAll10000            100          12927094  ns/op  2979829  B/op  80171  allocs/op\nBenchmarkDbrSelectAllWithArgs1        50000        38959     ns/op  2590     B/op  72     allocs/op\nBenchmarkDbrSelectAllWithArgs100      10000        162227    ns/op  29970    B/op  875    allocs/op\nBenchmarkDbrSelectAllWithArgs1000     2000         1227154   ns/op  273765   B/op  8093   allocs/op\nBenchmarkDbrSelectAllWithArgs10000    100          13342026  ns/op  3000164  B/op  80284  allocs/op\n\nBenchmarkSqlxSelectInts1              20000        86128     ns/op  628      B/op  22     allocs/op\nBenchmarkSqlxSelectInts100            10000        203886    ns/op  9480     B/op  426    allocs/op\nBenchmarkSqlxSelectInts1000           2000         1289621   ns/op  83799    B/op  4038   allocs/op\nBenchmarkSqlxSelectInts10000          100          15156243  ns/op  1134724  B/op  40139  allocs/op\nBenchmarkSqlxSelectAll1               50000        32373     ns/op  959      B/op  25     allocs/op\nBenchmarkSqlxSelectAll100             10000        177965    ns/op  28366    B/op  828    allocs/op\nBenchmarkSqlxSelectAll1000            1000         1634705   ns/op  271352   B/op  8042   allocs/op\nBenchmarkSqlxSelectAll10000           100          17483420  ns/op  2989883  B/op  80191  allocs/op\nBenchmarkSqlxSelectAllWithArgs1       10000        140460    ns/op  1228     B/op  30     allocs/op\nBenchmarkSqlxSelectAllWithArgs100     10000        250621    ns/op  23682    B/op  634    allocs/op\nBenchmarkSqlxSelectAllWithArgs1000    2000         1548073   ns/op  229879   B/op  6049   allocs/op\nBenchmarkSqlxSelectAllWithArgs10000   100          15441239  ns/op  2587009  B/op  60190  allocs/op\n\nBenchmarkGorpSelectInts1              10000        134277    ns/op  432      B/op  15     allocs/op\nBenchmarkGorpSelectAll1               50000        44086     ns/op  1983     B/op  75     allocs/op\nBenchmarkGorpSelectAll100             10000        232527    ns/op  34258    B/op  978    allocs/op\nBenchmarkGorpSelectAll1000            1000         1563675   ns/op  321846   B/op  9100   allocs/op\nBenchmarkGorpSelectAll10000           100          16451807  ns/op  3472508  B/op  90250  allocs/op\nBenchmarkGorpSelectAllWithArgs1       10000        131738    ns/op  2306     B/op  80     allocs/op\nBenchmarkGorpSelectAllWithArgs100     10000        265323    ns/op  29948    B/op  785    allocs/op\nBenchmarkGorpSelectAllWithArgs1000    2000         1423747   ns/op  279838   B/op  7103   allocs/op\nBenchmarkGorpSelectAllWithArgs10000   100          14538568  ns/op  3072519  B/op  70263  allocs/op\n\nBenchmarkBuilderDbrSimple             1000000      1699      ns/op  866      B/op  13     allocs/op\nBenchmarkBuilderDbrComplex            500000       6193      ns/op  2190     B/op  37     allocs/op\n\nBenchmarkBuilderSquirrelSimple        200000       8981      ns/op  2780     B/op  51     allocs/op\nBenchmarkBuilderSquirrelComplex       50000        44721     ns/op  11707    B/op  259    allocs/op\n```\n\n# Run yourself\n\n* Use the `godep` tool or manually install all libraries under test\n* Create db: `mysql -e \"create database golang_sql_benchmarks;\"`\n* Create schema: `mysql golang_sql_benchmarks \u003c structure.sql`\n* Run: `godep go test -bench=. -benchmem`\n* You can set the MySQL DSN to use by setting the GOLANG_SQL_BENCHMARKS_DSN env var (defaults to root@unix(/var/run/mysqld/mysqld.sock)/golang_sql_benchmarks)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyler-smith%2Fgolang-sql-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyler-smith%2Fgolang-sql-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyler-smith%2Fgolang-sql-benchmark/lists"}