liveBook · Manning

Pgbench

As explained in PostgreSQL Mistakes and How to Avoid Them

pgbench is a PostgreSQL benchmarking tool that runs concurrent database transaction workloads and reports performance results.

pgbench benchmarks PostgreSQL by driving concurrent transaction workloads and reporting throughput, latency, failures, and connection time. Run it from another host so the benchmark does not compete with the database server for resources. section 6.2

Testing memory tuning without guessing

A five-minute run with 100 clients produced 1,082 TPS. Increasing shared_buffers to 12GB and work_mem to 2GB slightly reduced throughput to 1,063 TPS, showing that larger settings are not automatically faster. Raising max_connections to 1,000 caused the test to hang under load; the Linux OOM killer then terminated a PostgreSQL process. Treat pgbench results as evidence for controlled tuning, not as justification for indiscriminately increasing memory or connection limits.

How PostgreSQL Mistakes and How to Avoid Them covers it

How deep it goes
Runs five-minute comparisons and stress tests, then connects degraded output to memory pressure and process termination.
Examples
Uses 100-client baseline, memory-tuning rerun, and 1,000-client stress-test commands with TPS, latency, and kernel-log output.
What it assumes
Assumes a restored PostgreSQL database and adjustable server configuration settings.
What you can do after
Diagnoses configuration effects and memory failures by comparing pgbench metrics with PostgreSQL and kernel output.
How it connects
Ties benchmarking to shared_buffers, work_mem, max_connections, PostgreSQL memory allocation, and the Linux OOM killer.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of PostgreSQL Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.