Git Product home page Git Product logo

go_db_bench's Introduction

Go Database Benchmark

This tests the performance of pgx native, pgx through database/sql, pq through database/sql, [go-pg](github.com/go- pg/pg), and theoretical maximum PostgreSQL performance. It always uses prepared statements.

Configuration

go_db_bench reads its configuration from the environment:
POSTGRES_SERVICE_HOST - defaults to empty
POSTGRES_SERVICE_PORT - 5432
PGPASSWORD - defaults to empty string
PGDATABASE - defaults to go_db_bench

Core Benchmarks

go_db_bench includes tests selecting one value, one row, and multiple rows.

Example execution:

// Setup minkube and have postgresql pod running
$kubectl apply -f minikube/
$export POSTGRES_SERVICE_HOST=192.168.99.100  
$export POSTGRES_SERVICE_PORT=30032   
$make test

HTTP Benchmarks

go_db_bench includes a simple HTTP server that serves JSON directly from PostgreSQL. This allows testing the performance of database drivers in a more real-world environment.

Example execution:

go build && PGHOST=/private/tmp ./go_db_bench

It exposes the following endpoints:

  • /people/pgx-native - pgx through its native interface
  • /people/pgx-stdlib - pgx through database/sql
  • /people/pq - pq through database/sql

Start the server and use your favorite HTTP load tester to benchmark (I recommend siege or overload).

Theoretical Max PostgreSQL Performance

This benchmark includes a minimum PostgreSQL driver sufficient to establish a connection and prepare statements. Query execution is benchmarked by sending a []byte filled with the query command and reading until the ready for query message is received. This should be the theoretical best performance a Go PostgreSQL driver could achieve.

Caveat: The returned data is not checked or parsed. It is only read until the ready for query message is received. If an error occurs it may not be apparent which could cause the timing to be misleading.

go_db_bench's People

Contributors

chenxi-vmware avatar hashrocketeer avatar jackc avatar vmihailenco avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.