Skip to content

Commit 591c504

Browse files
committed
Allow running just selected steps of pgbench's initialization sequence.
This feature caters to specialized use-cases such as running the normal pgbench scenario with nonstandard indexes, or inserting other actions between steps of the initialization sequence. The normal sequence of initialization actions is broken down into half a dozen steps which can be executed in a user-specified order, to the extent to which that's sensible. The actions themselves aren't changed, except to make them more robust against nonstandard uses: * all four tables are now dropped in one DROP command, to reduce assumptions about what foreign key relationships exist; * all four tables are now truncated at the start of the data load step, for consistency; * the foreign key creation commands now specify constraint names, to prevent accidentally creating duplicate constraints by executing the 'f' step twice. Make some cosmetic adjustments in the messages emitted by pgbench so that it's clear which steps are getting run, and so that the messages agree with the documented names of the steps. In passing, fix failure to enforce that the -v option is used only in benchmarking mode. Masahiko Sawada, reviewed by Fabien Coelho, editorialized a bit by me Discussion: https://postgr.es/m/CAD21AoCsz0ZzfCFcxYZ+PUdpkDd5VsCSG0Pre_-K1EgokCDFYA@mail.gmail.com
1 parent 44ae64c commit 591c504

File tree

4 files changed

+364
-114
lines changed

4 files changed

+364
-114
lines changed

doc/src/sgml/ref/pgbench.sgml

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
134134
<title>Options</title>
135135

136136
<para>
137-
The following is divided into three subsections: Different options are used
138-
during database initialization and while running benchmarks, some options
139-
are useful in both cases.
137+
The following is divided into three subsections. Different options are
138+
used during database initialization and while running benchmarks, but some
139+
options are useful in both cases.
140140
</para>
141141

142142
<refsect2 id="pgbench-init-options">
@@ -158,6 +158,79 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
158158
</listitem>
159159
</varlistentry>
160160

161+
<varlistentry>
162+
<term><option>-I <replaceable>init_steps</replaceable></option></term>
163+
<term><option>--init-steps=<replaceable>init_steps</replaceable></option></term>
164+
<listitem>
165+
<para>
166+
Perform just a selected set of the normal initialization steps.
167+
<replaceable>init_steps</replaceable> specifies the
168+
initialization steps to be performed, using one character per step.
169+
Each step is invoked in the specified order.
170+
The default is <literal>dtgvp</literal>.
171+
The available steps are:
172+
173+
<variablelist>
174+
<varlistentry>
175+
<term><literal>d</literal> (Drop)</term>
176+
<listitem>
177+
<para>
178+
Drop any existing <application>pgbench</application> tables.
179+
</para>
180+
</listitem>
181+
</varlistentry>
182+
<varlistentry>
183+
<term><literal>t</literal> (create Tables)</term>
184+
<listitem>
185+
<para>
186+
Create the tables used by the
187+
standard <application>pgbench</application> scenario, namely
188+
<structname>pgbench_accounts</structname>,
189+
<structname>pgbench_branches</structname>,
190+
<structname>pgbench_history</structname>, and
191+
<structname>pgbench_tellers</structname>.
192+
</para>
193+
</listitem>
194+
</varlistentry>
195+
<varlistentry>
196+
<term><literal>g</literal> (Generate data)</term>
197+
<listitem>
198+
<para>
199+
Generate data and load it into the standard tables,
200+
replacing any data already present.
201+
</para>
202+
</listitem>
203+
</varlistentry>
204+
<varlistentry>
205+
<term><literal>v</literal> (Vacuum)</term>
206+
<listitem>
207+
<para>
208+
Invoke <command>VACUUM</command> on the standard tables.
209+
</para>
210+
</listitem>
211+
</varlistentry>
212+
<varlistentry>
213+
<term><literal>p</literal> (create Primary keys)</term>
214+
<listitem>
215+
<para>
216+
Create primary key indexes on the standard tables.
217+
</para>
218+
</listitem>
219+
</varlistentry>
220+
<varlistentry>
221+
<term><literal>f</literal> (create Foreign keys)</term>
222+
<listitem>
223+
<para>
224+
Create foreign key constraints between the standard tables.
225+
(Note that this step is not performed by default.)
226+
</para>
227+
</listitem>
228+
</varlistentry>
229+
</variablelist>
230+
</para>
231+
</listitem>
232+
</varlistentry>
233+
161234
<varlistentry>
162235
<term><option>-F</option> <replaceable>fillfactor</replaceable></term>
163236
<term><option>--fillfactor=</option><replaceable>fillfactor</replaceable></term>
@@ -176,7 +249,9 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
176249
<term><option>--no-vacuum</option></term>
177250
<listitem>
178251
<para>
179-
Perform no vacuuming after initialization.
252+
Perform no vacuuming during initialization.
253+
(This option suppresses the <literal>v</literal> initialization step,
254+
even if it was specified in <option>-I</option>.)
180255
</para>
181256
</listitem>
182257
</varlistentry>
@@ -215,6 +290,8 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
215290
<listitem>
216291
<para>
217292
Create foreign key constraints between the standard tables.
293+
(This option adds the <literal>f</literal> step to the initialization
294+
step sequence, if it is not already present.)
218295
</para>
219296
</listitem>
220297
</varlistentry>

0 commit comments

Comments
 (0)