Forrest logo
tool overview
On this page you find all important commands for the CLI tool pgbench. If the command you are looking for is missing please ask our AI.

pgbench

pgbench is a command line tool that is used to benchmark the performance of PostgreSQL database servers. It allows users to simulate database workloads and measure the performance and scalability of the database system.

It uses a combination of client-server architecture, creating multiple threads that act as clients, and can be used to generate a wide range of transactional workloads to stress-test the database.

With pgbench, users can create custom scripts that simulate real-world database operations such as inserts, updates, and selects. These scripts are written using SQL commands and can be parameterized to mimic various scenarios.

The tool provides various options and parameters to configure the benchmarking process, including the number of threads, transaction rate, duration, and scaling factor. This allows users to mimic different types of workloads and stress conditions to measure the performance of the database.

By running pgbench, users can obtain crucial information such as transactions per second, latency, and various database statistics like I/O operations, locks, and buffer cache hits. This information helps in identifying performance bottlenecks and optimizing the database system.

Pgbench offers features like warm-up mode, where it executes a certain number of transactions before starting the actual benchmark, allowing the database to reach a steady state. It also includes support for multiple database connections and concurrent clients, allowing for realistic workload simulation.

The tool also supports report generation in various formats, including plain text, HTML, and CSV, making it easier to analyze and present the benchmarking results.

Pgbench is included as a part of the PostgreSQL database distribution and is available on various platforms, including Linux, macOS, and Windows. It is widely used by database administrators, developers, and performance engineers to evaluate and optimize PostgreSQL database performance.

List of commands for pgbench:

  • pgbench:tldr:79286 pgbench: Initialize a database with a scale factor of 50 times the default size.
    $ pgbench --initialize --scale=${50} ${database_name}
    try on your machine
    explain this command
  • pgbench:tldr:cfc33 pgbench: Benchmark a database with 10 clients, 2 worker threads, and 10,000 transactions per client.
    $ pgbench --client=${10} --jobs=${2} --transactions=${10000} ${database_name}
    try on your machine
    explain this command
tool overview