Commit 7bafffea authored by Alvaro Herrera's avatar Alvaro Herrera

pgbench: Allow changing weights for scripts

Previously, all scripts had the same probability of being chosen when
multiple of them were specified via -b, -f, -N, -S.  With this commit,
-b and -f now search for an "@" in the script name and use the integer
found after it as the drawing probability for that script.

(One disadvantage is that if you have script whose names contain @, you
are now forced to specify "@1" at the end; otherwise the name's @ is
confused with a weight separator.  We don't expect many pgbench script
with @ in their names in the wild, so this shouldn't be too serious a
problem.)

While at it, rework the interface between addScript, process_file,
process_builtin, and findBuiltin.  It had gotten a bit out of hand with
recent commits.

Author: Fabien Coelho
Reviewed-By: Andres Freund, Robert Haas, Álvaro Herrera, Michaël Paquier
Discussion: http://www.postgresql.org/message-id/alpine.DEB.2.10.1603160721240.1666@sto
parent b46d9beb
...@@ -262,11 +262,13 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</> ...@@ -262,11 +262,13 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term><option>-b</> <replaceable>scriptname</></term> <term><option>-b</> <replaceable>scriptname[@weight]</></term>
<term><option>--builtin</> <replaceable>scriptname</></term> <term><option>--builtin</>=<replaceable>scriptname[@weight]</></term>
<listitem> <listitem>
<para> <para>
Add the specified builtin script to the list of executed scripts. Add the specified builtin script to the list of executed scripts.
An optional integer weight after <literal>@</> allows to adjust the
probability of drawing the script. If not specified, it is set to 1.
Available builtin scripts are: <literal>tpcb-like</>, Available builtin scripts are: <literal>tpcb-like</>,
<literal>simple-update</> and <literal>select-only</>. <literal>simple-update</> and <literal>select-only</>.
Unambiguous prefixes of builtin names are accepted. Unambiguous prefixes of builtin names are accepted.
...@@ -322,12 +324,14 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</> ...@@ -322,12 +324,14 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><option>-f</> <replaceable>filename</></term> <term><option>-f</> <replaceable>filename[@weight]</></term>
<term><option>--file=</><replaceable>filename</></term> <term><option>--file=</><replaceable>filename[@weight]</></term>
<listitem> <listitem>
<para> <para>
Add a transaction script read from <replaceable>filename</> to Add a transaction script read from <replaceable>filename</> to
the list of executed scripts. the list of executed scripts.
An optional integer weight after <literal>@</> allows to adjust the
probability of drawing the test.
See below for details. See below for details.
</para> </para>
</listitem> </listitem>
...@@ -687,9 +691,13 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</> ...@@ -687,9 +691,13 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
<title>What is the <quote>Transaction</> Actually Performed in <application>pgbench</application>?</title> <title>What is the <quote>Transaction</> Actually Performed in <application>pgbench</application>?</title>
<para> <para>
Pgbench executes test scripts chosen randomly from a specified list. <application>pgbench</> executes test scripts chosen randomly
from a specified list.
They include built-in scripts with <option>-b</> and They include built-in scripts with <option>-b</> and
user-provided custom scripts with <option>-f</>. user-provided custom scripts with <option>-f</>.
Each script may be given a relative weight specified after a
<literal>@</> so as to change its drawing probability.
The default weight is <literal>1</>.
</para> </para>
<para> <para>
...@@ -1194,12 +1202,11 @@ number of clients: 10 ...@@ -1194,12 +1202,11 @@ number of clients: 10
number of threads: 1 number of threads: 1
number of transactions per client: 1000 number of transactions per client: 1000
number of transactions actually processed: 10000/10000 number of transactions actually processed: 10000/10000
latency average = 15.844 ms
latency stddev = 2.715 ms
tps = 618.764555 (including connections establishing) tps = 618.764555 (including connections establishing)
tps = 622.977698 (excluding connections establishing) tps = 622.977698 (excluding connections establishing)
SQL script 1: &lt;builtin: TPC-B (sort of)&gt; script statistics:
- 10000 transactions (100.0% of total, tps = 618.764555)
- latency average = 15.844 ms
- latency stddev = 2.715 ms
- statement latencies in milliseconds: - statement latencies in milliseconds:
0.004386 \set nbranches 1 * :scale 0.004386 \set nbranches 1 * :scale
0.001343 \set ntellers 10 * :scale 0.001343 \set ntellers 10 * :scale
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment