All Projects → sj14 → Dbbench

sj14 / Dbbench

Licence: mit
🏋️ dbbench is a simple database benchmarking tool which supports several databases and own scripts

Programming Languages

31211 projects - #10 most used programming language
3204 projects

Projects that are alternatives of or similar to Dbbench

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB (Preview)
Stars: ✭ 18,168 (+34838.46%)
Mutual labels:  database, mysql, postgresql, mariadb, sqlite, mssql
Linq to database provider.
Stars: ✭ 2,211 (+4151.92%)
Mutual labels:  database, mysql, postgresql, sqlite, mariadb, mssql
Database migration tool for .NET and .NET Core projects. Inspired by Flyway.
Stars: ✭ 477 (+817.31%)
Mutual labels:  database, mysql, postgresql, sqlite, cassandra, mariadb
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+14730.77%)
Mutual labels:  hacktoberfest, database, mysql, sqlite, cassandra, mariadb
phpMyFAQ - Open Source FAQ web application for PHP and MySQL, PostgreSQL and other databases
Stars: ✭ 494 (+850%)
Mutual labels:  database, mysql, postgresql, sqlite, mariadb, mssql
Open-Source Data Platform 🐰 — Directus wraps any SQL database with a real-time GraphQL+REST API and an intuitive app for non-technical users.
Stars: ✭ 13,190 (+25265.38%)
Mutual labels:  database, mysql, postgresql, sqlite, mssql
Rom Sql
SQL support for rom-rb
Stars: ✭ 169 (+225%)
Mutual labels:  mysql, postgresql, sqlite, mariadb, mssql
A lightweight client for managing MariaDB, MySQL, SQL Server, PostgreSQL and SQLite, written in Delphi
Stars: ✭ 2,864 (+5407.69%)
Mutual labels:  mysql, postgresql, sqlite, mariadb, mssql
MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Stars: ✭ 498 (+857.69%)
Mutual labels:  database, mysql, postgresql, sqlite, mariadb
Directus is a real-time API and App dashboard for managing SQL database content. 🐰
Stars: ✭ 111 (+113.46%)
Mutual labels:  database, mysql, postgresql, sqlite, mssql
An easy-to-use and promise-based multi SQL dialects ORM tool for Node.js
Stars: ✭ 25,422 (+48788.46%)
Mutual labels:  mysql, postgresql, sqlite, mariadb, mssql
ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Stars: ✭ 26,559 (+50975%)
Mutual labels:  database, mysql, postgresql, sqlite, mariadb
Database migrations. CLI and Golang library.
Stars: ✭ 2,315 (+4351.92%)
Mutual labels:  database, mysql, sqlite, cassandra, mariadb
Migrate to PostgreSQL in a single command!
Stars: ✭ 3,754 (+7119.23%)
Mutual labels:  database, mysql, postgresql, sqlite, mssql
🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, SQLite, and MSSQL.
Stars: ✭ 5,039 (+9590.38%)
Mutual labels:  mysql, postgresql, sqlite, mariadb, mssql
Go Sqlbuilder
A flexible and powerful SQL string builder library plus a zero-config ORM.
Stars: ✭ 539 (+936.54%)
Mutual labels:  database, mysql, postgresql, sqlite
Beekeeper Studio
Modern and easy to use SQL client for MySQL, Postgres, SQLite, SQL Server, and more. Linux, MacOS, and Windows.
Stars: ✭ 8,053 (+15386.54%)
Mutual labels:  database, mysql, postgresql, sqlite
Easy-to-use PDO wrapper for PHP projects.
Stars: ✭ 624 (+1100%)
Mutual labels:  database, mysql, postgresql, sqlite
Database management in a single PHP file
Stars: ✭ 4,999 (+9513.46%)
Mutual labels:  database, mysql, postgresql, sqlite
Database firewall written in Go
Stars: ✭ 620 (+1092.31%)
Mutual labels:  database, mysql, postgresql, mariadb


Action Go Report Card Coverage Status

Table of Contents


dbbench is a simple tool to benchmark or stress test databases. You can use the simple built-in benchmarks or run your own queries.

Attention: This tool comes with no warranty. Don't run it on production databases.


$ dbbench postgres --user postgres --pass example --iter 100000
inserts 6.199670776s    61996   ns/op
updates 7.74049898s     77404   ns/op
selects 2.911541197s    29115   ns/op
deletes 5.999572479s    59995   ns/op
total: 22.85141994s


Precompiled Binaries

Binaries are available for all major platforms. See the releases page. Unfortunately, cgo is disabled for these builds, which means there is no SQLite support (#1).


Using the Homebrew package manager for macOS:

brew install sj14/tap/dbbench


It's also possible to install the current development snapshot with go get (not recommended):

go get -u

Supported Databases / Driver

Databases Driver
Cassandra and compatible databases (e.g. ScyllaDB)
MS SQL and compatible databases (no built-in benchmarks yet)
MySQL and compatible databases (e.g. MariaDB and TiDB)
PostgreSQL and compatible databases (e.g. CockroachDB)
SQLite3 and compatible databases


Available subcommands:
        Use 'subcommand --help' for all flags of the specified command.
Generic flags for all subcommands:
      --clean            only cleanup benchmark data, e.g. after a crash
      --iter int         how many iterations should be run (default 1000)
      --noclean          keep benchmark data
      --noinit           do not initialize database and tables, e.g. when only running own script
      --run string       only run the specified benchmarks, e.g. "inserts deletes" (default "all")
      --script string    custom sql file to execute
      --sleep duration   how long to pause after each single benchmark (valid units: ns, us, ms, s, m, h)
      --threads int      max. number of green threads (iter >= threads > 0) (default 25)
      --version          print version information

Custom Scripts

You can run your own SQL statements with the --script flag. You can use the auto-generate tables. Beware the file size as it will be completely loaded into memory.

The script must contain valid SQL statements for your database.

There are some built-in variables and functions which can be used in the script. It's using the golang template engine which uses the delimiters {{ and }}. Functions are executed with the call command and arguments are passed after the function name.

Benchmark Settings

A new benchmark is created with the \benchmark keyword, followed by either once or loop. Optional parameters can be added afterwards in the same line.

The the usage description and the example subsection for more information.

Usage Description
\benchmark once Execute the following statements (lines) only once (e.g. to create and delete tables).
\benchmark loop Default mode. Execute the following statements (lines) in a loop. Executes them one after another and then starts a new iteration. Add another \benchmark loop to start another benchmark of statements.
\name insert Set a custom name for the DB statement(s), which will be output instead the line numbers (insert is an examplay name).

Statement Substitutions

Usage Description
{{.Iter}} The iteration counter. Will return 1 when \benchmark once.
{{call .Seed 42}} godoc (42 is an examplary seed)
{{call .RandInt63}} godoc
{{call .RandInt63n 9999}} godoc (9999 is an examplary upper limit)
{{call .RandFloat32}} godoc
{{call .RandFloat64}} godoc
{{call .RandExpFloat64}} godoc
{{call .RandNormFloat64}} godoc


Exemplary sqlite_bench.sql file:

-- Create table
\benchmark once \name init
CREATE TABLE dbbench_simple (id INT PRIMARY KEY, balance DECIMAL);

-- How long takes an insert and delete?
\benchmark loop \name single
INSERT INTO dbbench_simple (id, balance) VALUES({{.Iter}}, {{call .RandInt63}});
DELETE FROM dbbench_simple WHERE id = {{.Iter}}; 

-- How long takes it in a single transaction?
\benchmark loop \name batch
INSERT INTO dbbench_simple (id, balance) VALUES({{.Iter}}, {{call .RandInt63}});
DELETE FROM dbbench_simple WHERE id = {{.Iter}}; 

-- Delete table
\benchmark once \name clean
DROP TABLE dbbench_simple;

In this script, we create and delete the table manually, thus we will pass the --noinit and --noclean flag, which would otherwise create this default table for us:

dbbench sqlite --script scripts/sqlite_bench.sql --iter 5000 --noinit --noclean


(once) init:    3.404784ms      3404784 ns/op
(loop) single:  10.568390874s   2113678 ns/op
(loop) batch:   5.739021596s    1147804 ns/op
(once) clean:   1.065703ms      1065703 ns/op
total: 16.312319959s


Error message

failed to insert: UNIQUE constraint failed:

Description The previous data wasn't removed (e.g. because the benchmark was canceled). Try to run the same command again, but with the --clean flag attached, which will remove the old data. Then run the original command again.

Error message

failed to create table: Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub

Currently, the released binary builds don't contain SQLite support. You have to compile dbbench manually, either from the particular release source code (recommended) or from the current master branch (not recommended).


Below are some examples how to run different databases and the equivalent call of dbbench for testing/developing.


docker run --name dbbench-cassandra -p 9042:9042 -d cassandra:latest
dbbench cassandra


# port 8080 is the webinterface (optional)
docker run --name dbbench-cockroach -d -p 26257:26257 -p 8080:8080 cockroachdb/cockroach:latest start --insecure
dbbench cockroach

Microsoft SQL Server

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d microsoft/mssql-server-linux
dbbench mssql -user sa -pass 'yourStrong(!)Password'


docker run --name dbbench-mariadb -p 3306:3306 -d -e MYSQL_ROOT_PASSWORD=root mariadb
dbbench mariadb


docker run --name dbbench-mysql -p 3306:3306 -d -e MYSQL_ROOT_PASSWORD=root mysql
dbbench mysql


docker run --name dbbench-postgres -p 5432:5432 -d postgres
dbbench postgres --user postgres --pass example


docker run --name dbbench-scylla -p 9042:9042 -d scylladb/scylla
dbbench scylla


dbbench sqlite


git clone
cd tidb-docker-compose && docker-compose pull
docker-compose up -d
dbbench tidb --pass '' --port 4000


Thanks to the authors of Go and those of the directly and indirectly used libraries, especially the driver developers. It wouldn't be possible without all your work.

This tool was highly inspired by the snippet from user Fale and the tool pgbench. Later, also inspired by MemSQL's dbbench which had the name and a similar idea before.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].