PostgreSQL Database Driver Benchmarks
I welcome pull requests that will:
Improve existing implementations (without sacrificing readability)
or
Add implementations for the following languages: Python, Lua, Nim, Java, Kotlin, Swift, Javascript, Shell
You will need the following on your system to be able to run the tests:
- postgresql
- clang
- go
- crystal
- ruby
- libpq in system include path
- run the install script
crystal run scripts/install.cr
- seed the database
# You may need to configure script to use your default psql username
psql -d test -a -f scripts/seed.sql
- now you can build, run, and summarize the results
crystal run scripts/build.cr
crystal run scripts/run.cr
crystal run scripts/summary.cr
- Using github.com/postgres/postgres - libPQ
- Using github.com/lib/pq
- Using github.com/jackc/pgx via native interface and connection pool
- Using github.com/will/crystal-pg
- Using github.com/abidon/crystal-pq
- Using github.com/abidon/libpq.cr
- Using github.com/ged/ruby-pg
Feedback is welcome in the issues. Feel free to leave comments or concerns.
- See CAVEATS.md
This research is strictly concerned with database performance and not web server performance.
Therefore the benchmarks will only measure the time it takes between submitting a query and receiving a valid response.
All implementations should be structured as follows to ensure comparisons remain as fair as possible:
- binary/script should use connection pool if possible to manage connections to the database.
- all benchmark queries should be read into string variables before any benchmarks begin
- benchmark queries should be executed several times each to measure cumulative effects and reduce effect of outlier runs
- binary/script should track all response times of each benchmark and print them on exit to std_out
- T1 - delete from contacts where name like 'a test %' (1000 record delete with wildcard search)
- T2 - select name, age from contacts order by age desc (1 select retrieving 1000 records into local variables)
- T3 - insert into contacts values ($1, $2) (1000 individual inserts using execution parameters)
- T4 - select name, age from contacts order by age asc (1 select retrieving 2000 records into local variables)
- T5 - select name, age from contacts where age = $1 (1000 individual selects using execution parameters)
- T6 - select name, age from contacts where age = $1 (1000 concurrent selects using execution parameters)
- T7 - select id, f_id, f_bool, f_string, CAST(f_decimal as double precision) As f_decimal, f_date, f_time from example_records (1000000 record select with multiple data types)
- T8 - select f_id from example_records where f_bool = 't' (1 select with condition returning 500087 ints and then summing with integrity check)