pgBench is a simple program for running benchmark tests on PostgreSQL. It runs the same sequence of SQL commands over and over, possibly in multiple concurrent database sessions, and then calculates the average transaction rate (transactions per second).


The following features are supported by the crunchy-pgbench container:

  • Kubernetes and OpenShift secrets
  • Custom mounted transaction files (see below)
  • Configurable benchmarking options


The crunchy-pgbench Docker image contains the following packages (versions vary depending on PostgreSQL version):

  • pgBench (12.5, 11.10, 10.15, 9.6.20 and 9.5.24)
  • CentOS7 - publicly available
  • UBI7 - customers only

Environment Variables


Name Default Description
PG_DATABASE None Set this value to the database which pgBench should use
PG_HOSTNAME None Set this value to the hostname of the PostgreSQL primary to benchmark
PG_USERNAME None Set this value to specify the username used to run the benchmark
PG_PASSWORD None Set this value to specify the password of the user to run the benchmark.


Name Default Description
PGBENCH_BENCHMARK_OPTS none Set this value to specify custom benchmark parameters to pass to pgBench.
PGBENCH_CLIENTS 1 Set this value to the number of clients to use for the benchmark.
PGBENCH_INIT_OPTS none Set this value to specify custom initialization parameters for pgBench.
PGBENCH_JOBS 1 Set this value to the number of worker threads to be used by pgBench.
PGBENCH_SCALE 1 Set this value to multiply the number of rows generated by the scale factor. For example, 100 will create 10,000,000 rows in the pgbench_accounts table
PGBENCH_TRANSACTIONS 1 Set this value to configure the number of transactions each client runs
PG_PORT 5432 Set this value to specify the port of the PostgreSQL host.
CRUNCHY_DEBUG FALSE Set this to true to enable debugging in logs. Note: this mode can reveal secrets in logs.
For a list of advanced options for configuring the `PGBENCH_BENCHMARK_OPTS` variable, see the official documentation:


Name Description
/pgconf Volume used to store custom transaction files mounted to the container.

Custom Configuration

The following configuration files can be mounted to the /pgconf volume in the crunchy-pgbench container to customize the runtime:

Name Description
transactions.sql Custom transaction script to use for creating custom pgBench tests.