Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8bea3d2

Browse files
committed
pgbench: improve multi-script support
Previously, it was possible to specify one or several custom scripts to run, or only one of the builtin scripts. With this patch it is also possible to specify to run the builtin scripts multiple times, using the new -b option. Also, unify the code for both cases; this eases future pgbench improvements. Author: Fabien Coelho Review: Michaël Paquier, Álvaro Herrera
1 parent 5b3cc1a commit 8bea3d2

File tree

2 files changed

+253
-154
lines changed

2 files changed

+253
-154
lines changed

doc/src/sgml/ref/pgbench.sgml

+50-24
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
Typical output from <application>pgbench</application> looks like:
4949

5050
<screen>
51-
transaction type: TPC-B (sort of)
51+
transaction type: &lt;builtin: TPC-B (sort of)&gt;
5252
scaling factor: 10
5353
query mode: simple
5454
number of clients: 10
@@ -261,6 +261,20 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
261261
benchmarking arguments:
262262

263263
<variablelist>
264+
<varlistentry>
265+
<term><option>-b</> <replaceable>scriptname</></term>
266+
<term><option>--builtin</> <replaceable>scriptname</></term>
267+
<listitem>
268+
<para>
269+
Add the specified builtin script to the list of executed scripts.
270+
Available builtin scripts are: <literal>tpcb-like</>,
271+
<literal>simple-update</> and <literal>select-only</>.
272+
With special name <literal>list</>, show the list of builtin scripts
273+
and exit immediately.
274+
</para>
275+
</listitem>
276+
</varlistentry>
277+
264278

265279
<varlistentry>
266280
<term><option>-c</option> <replaceable>clients</></term>
@@ -307,14 +321,13 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
307321
</varlistentry>
308322

309323
<varlistentry>
310-
<term><option>-f</option> <replaceable>filename</></term>
311-
<term><option>--file=</option><replaceable>filename</></term>
324+
<term><option>-f</> <replaceable>filename</></term>
325+
<term><option>--file=</><replaceable>filename</></term>
312326
<listitem>
313327
<para>
314-
Read transaction script from <replaceable>filename</>.
328+
Add a transaction script read from <replaceable>filename</> to
329+
the list of executed scripts.
315330
See below for details.
316-
<option>-N</option>, <option>-S</option>, and <option>-f</option>
317-
are mutually exclusive.
318331
</para>
319332
</listitem>
320333
</varlistentry>
@@ -404,10 +417,8 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
404417
<term><option>--skip-some-updates</option></term>
405418
<listitem>
406419
<para>
407-
Do not update <structname>pgbench_tellers</> and
408-
<structname>pgbench_branches</>.
409-
This will avoid update contention on these tables, but
410-
it makes the test case even less like TPC-B.
420+
Run builtin simple-update script.
421+
Shorthand for <option>-b simple-update</>.
411422
</para>
412423
</listitem>
413424
</varlistentry>
@@ -512,9 +523,9 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
512523
Report the specified scale factor in <application>pgbench</>'s
513524
output. With the built-in tests, this is not necessary; the
514525
correct scale factor will be detected by counting the number of
515-
rows in the <structname>pgbench_branches</> table. However, when testing
516-
custom benchmarks (<option>-f</> option), the scale factor
517-
will be reported as 1 unless this option is used.
526+
rows in the <structname>pgbench_branches</> table.
527+
However, when testing only custom benchmarks (<option>-f</> option),
528+
the scale factor will be reported as 1 unless this option is used.
518529
</para>
519530
</listitem>
520531
</varlistentry>
@@ -524,7 +535,8 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
524535
<term><option>--select-only</option></term>
525536
<listitem>
526537
<para>
527-
Perform select-only transactions instead of TPC-B-like test.
538+
Run built-in select-only script.
539+
Shorthand for <option>-b select-only</>.
528540
</para>
529541
</listitem>
530542
</varlistentry>
@@ -674,7 +686,17 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
674686
<title>What is the <quote>Transaction</> Actually Performed in <application>pgbench</application>?</title>
675687

676688
<para>
677-
The default transaction script issues seven commands per transaction:
689+
Pgbench executes test scripts chosen randomly from a specified list.
690+
They include built-in scripts with <option>-b</> and
691+
user-provided custom scripts with <option>-f</>.
692+
</para>
693+
694+
<para>
695+
The default builtin transaction script (also invoked with <option>-b tpcb-like</>)
696+
issues seven commands per transaction over randomly chosen <literal>aid</>,
697+
<literal>tid</>, <literal>bid</> and <literal>balance</>.
698+
The scenario is inspired by the TPC-B benchmark, but is not actually TPC-B,
699+
hence the name.
678700
</para>
679701

680702
<orderedlist>
@@ -688,9 +710,15 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
688710
</orderedlist>
689711

690712
<para>
691-
If you specify <option>-N</>, steps 4 and 5 aren't included in the
692-
transaction. If you specify <option>-S</>, only the <command>SELECT</> is
693-
issued.
713+
If you select the <literal>simple-update</> builtin (also <option>-N</>),
714+
steps 4 and 5 aren't included in the transaction.
715+
This will avoid update contention on these tables, but
716+
it makes the test case even less like TPC-B.
717+
</para>
718+
719+
<para>
720+
If you select the <literal>select-only</> builtin (also <option>-S</>),
721+
only the <command>SELECT</> is issued.
694722
</para>
695723
</refsect2>
696724

@@ -702,10 +730,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
702730
benchmark scenarios by replacing the default transaction script
703731
(described above) with a transaction script read from a file
704732
(<option>-f</option> option). In this case a <quote>transaction</>
705-
counts as one execution of a script file. You can even specify
706-
multiple scripts (multiple <option>-f</option> options), in which
707-
case a random one of the scripts is chosen each time a client session
708-
starts a new transaction.
733+
counts as one execution of a script file.
709734
</para>
710735

711736
<para>
@@ -1103,7 +1128,7 @@ END;
11031128
For the default script, the output will look similar to this:
11041129
<screen>
11051130
starting vacuum...end.
1106-
transaction type: TPC-B (sort of)
1131+
transaction type: &lt;builtin: TPC-B (sort of)&gt;
11071132
scaling factor: 1
11081133
query mode: simple
11091134
number of clients: 10
@@ -1112,7 +1137,8 @@ number of transactions per client: 1000
11121137
number of transactions actually processed: 10000/10000
11131138
tps = 618.764555 (including connections establishing)
11141139
tps = 622.977698 (excluding connections establishing)
1115-
statement latencies in milliseconds:
1140+
SQL script 1: &lt;builtin: TPC-B (sort of)&gt;
1141+
- statement latencies in milliseconds:
11161142
0.004386 \set nbranches 1 * :scale
11171143
0.001343 \set ntellers 10 * :scale
11181144
0.001212 \set naccounts 100000 * :scale

0 commit comments

Comments
 (0)