Skip to content
davarsPublic

About

Comparison of Go libraries for working with PostgreSQL

Resources

Stars

6 stars

Watchers

1 watching

Forks

Repository files navigation

dbeval

Comparison of Go libraries for working with PostgreSQL

Runs benchmarks on the same "typical" database workflow implemented in various ways.

Leaderboard: each implementation's time relative to the fastest

results.md and its chart are regenerated by the Benchmarks workflow whenever the code or its dependencies change on main. It runs on a shared GitHub-hosted runner, so compare implementations within one run rather than absolute numbers across runs.

Each implementation aims to be idiomatic for its library and to use the features that make it fastest for the workload: single-statement (or COPY) bulk inserts, the library's statement caching, and the fastest driver it supports.

⚠️ Warning: calls DROP DATABASE on local postgres instance! ⚠️

# Run tests
go test ./...

# Run benchmarks and write the report
go test -run '^$' -bench . -benchmem -count 6 . | tee bench.txt
go run ./internal/benchreport -svg results.svg bench.txt > results.md

# Reset if cleanup was not performed by previous run
psql postgres -c 'DROP DATABASE dbeval_db'

Style Note

Don't copy the check function to your own code! More often than not you want to return errors to your caller, with optional context from your error site. When you get ready to show the error to your user, either print it out or display it, optionally translating into an understandable error message. I'm using panics here to simplify the test harness. The DB manipulation implementations then conform to that. This is not a typical use-case so it's not likely to be the best approach for your problem.

Implementated

PRs Welcome

About

Comparison of Go libraries for working with PostgreSQL

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

⌂ 换网址