Home Explore Blog CI



postgresql

34th chunk of `doc/src/sgml/ref/pgbench.sgml`
e4f6990580f94c79730d2b9014a5e8b965eaf6a4da5b423b0000000100000fae
 <application>pgbench</application>
   collects the following statistics for each statement:
   <itemizedlist>
     <listitem>
       <para>
         <literal>latency</literal> &mdash; elapsed transaction time for each
         statement. <application>pgbench</application> reports an average value
         of all successful runs of the statement.
       </para>
     </listitem>
     <listitem>
       <para>
         The number of failures in this statement. See
         <xref linkend="failures-and-retries"/> for more information.
       </para>
     </listitem>
     <listitem>
       <para>
         The number of retries after a serialization or a deadlock error in this
         statement. See <xref linkend="failures-and-retries"/> for more information.
       </para>
     </listitem>
   </itemizedlist>
  </para>

  <para>
   The report displays retry statistics only if the <option>--max-tries</option>
   option is not equal to 1.
  </para>

  <para>
   All values are computed for each statement executed by every client and are
   reported after the benchmark has finished.
  </para>

  <para>
   For the default script, the output will look similar to this:
<screen>
starting vacuum...end.
transaction type: &lt;builtin: TPC-B (sort of)&gt;
scaling factor: 1
query mode: simple
number of clients: 10
number of threads: 1
maximum number of tries: 1
number of transactions per client: 1000
number of transactions actually processed: 10000/10000
number of failed transactions: 0 (0.000%)
number of transactions above the 50.0 ms latency limit: 1311/10000 (13.110 %)
latency average = 28.488 ms
latency stddev = 21.009 ms
initial connection time = 69.068 ms
tps = 346.224794 (without initial connection time)
statement latencies in milliseconds and failures:
   0.012  0  \set aid random(1, 100000 * :scale)
   0.002  0  \set bid random(1, 1 * :scale)
   0.002  0  \set tid random(1, 10 * :scale)
   0.002  0  \set delta random(-5000, 5000)
   0.319  0  BEGIN;
   0.834  0  UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
   0.641  0  SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
  11.126  0  UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
  12.961  0  UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
   0.634  0  INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
   1.957  0  END;
</screen>

   Another example of output for the default script using serializable default
   transaction isolation level (<command>PGOPTIONS='-c
   default_transaction_isolation=serializable' pgbench ...</command>):
<screen>
starting vacuum...end.
transaction type: &lt;builtin: TPC-B (sort of)&gt;
scaling factor: 1
query mode: simple
number of clients: 10
number of threads: 1
maximum number of tries: 10
number of transactions per client: 1000
number of transactions actually processed: 6317/10000
number of failed transactions: 3683 (36.830%)
number of transactions retried: 7667 (76.670%)
total number of retries: 45339
number of transactions above the 50.0 ms latency limit: 106/6317 (1.678 %)
latency average = 17.016 ms
latency stddev = 13.283 ms
initial connection time = 45.017 ms
tps = 186.792667 (without initial connection time)
statement latencies in milliseconds, failures and retries:
  0.006     0      0  \set aid random(1, 100000 * :scale)
  0.001     0      0  \set bid random(1, 1 * :scale)
  0.001     0      0  \set tid random(1, 10 * :scale)
  0.001     0      0  \set delta random(-5000, 5000)
  0.385     0      0  BEGIN;
  0.773     0      1  UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
  0.624     0      0  SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
  1.098   320   3762  UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
  0.582  3363  41576  UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
  0.465     0      0  INSERT INTO pgbench_history

Title: pgbench Per-Statement Report and Examples
Summary
This passage details the per-statement report generated by pgbench, focusing on latency, failures, and retries for each statement executed by every client after the benchmark. It provides example output for the default script with standard settings, illustrating transaction type, scaling factor, query mode, client and thread count, transaction numbers, and key metrics like latency, TPS, and statement latencies. A second example shows the output using serializable default transaction isolation, highlighting the impact on retries and failures, specifically with retries in the account, teller, and branch update statements.