pgbench is a core utility which runs benchmarking tests on PostgreSQL.
pgbench consists of a single binary file which is usually installed into the same location as other PostgreSQL binaries such as
pgbench can be installed from source by a simple "
make && make install" from the contrib/pgbench directory, or depending on operating system may be available as a separate package or part of a package containing other contrib modules.
pgbench provides a default set of sample data and tests (loosely based on TPC-B), however customised script files can also be used.
- PostgreSQL 14
- PostgreSQL 13
--partition-methodadded (commit b1c1aa53)
Gto generate data on the server side, rather than have it generated by the client (commit a386942b)
--show-scriptoption added to dump contents of built-in scripts (commit 5823677a)
\gsetbut able to store all results from combined SQL queries into separate variables (commit 9d8ef988)
- PostgreSQL 9.5
- PostgreSQL 7.0
The default tests provided with
pgbench require the installation of a set of sample tables and data into the target database; this is done with:
pgbench -i [
pgbench again without the -i option will cause a basic test to be executed, e.g.:
postgres:~$ pgbench -U postgres testdb starting vacuum...end. transaction type: TPC-B (sort of) scaling factor: 1 query mode: simple number of clients: 1 number of threads: 1 number of transactions per client: 10 number of transactions actually processed: 10/10 tps = 108.049703 (including connections establishing) tps = 110.750557 (excluding connections establishing)
The default options do not provide particularly useful output; the most useful options for tuning
-c(number of clients)
-t(number of transactions)