Skip to content

Commit 79cddb1

Browse files
committed
pgbench: Add long options for all existing short options.
Fabien Coelho, reviewed by Fabrízio de Royes Mello, with some further changes by me
1 parent a03ae56 commit 79cddb1

File tree

2 files changed

+84
-39
lines changed

2 files changed

+84
-39
lines changed

contrib/pgbench/pgbench.c

+60-39
Original file line numberDiff line numberDiff line change
@@ -329,48 +329,45 @@ usage(void)
329329
"Usage:\n"
330330
" %s [OPTION]... [DBNAME]\n"
331331
"\nInitialization options:\n"
332-
" -i invokes initialization mode\n"
333-
" -F NUM fill factor\n"
334-
" -n do not run VACUUM after initialization\n"
335-
" -q quiet logging (one message each 5 seconds)\n"
336-
" -s NUM scaling factor\n"
337-
" --foreign-keys\n"
338-
" create foreign key constraints between tables\n"
332+
" -i, --initialize invokes initialization mode\n"
333+
" -F, --fillfactor=NUM set fill factor\n"
334+
" -n, --no-vacuum do not run VACUUM after initialization\n"
335+
" -q, --quiet quiet logging (one message each 5 seconds)\n"
336+
" -s NUM, --scale NUM scaling factor\n"
337+
" --foreign-keys create foreign key constraints between tables\n"
339338
" --index-tablespace=TABLESPACE\n"
340-
" create indexes in the specified tablespace\n"
341-
" --tablespace=TABLESPACE\n"
342-
" create tables in the specified tablespace\n"
343-
" --unlogged-tables\n"
344-
" create tables as unlogged tables\n"
339+
" create indexes in the specified tablespace\n"
340+
" --tablespace=TABLESPACE create tables in the specified tablespace\n"
341+
" --unlogged-tables create tables as unlogged tables\n"
345342
"\nBenchmarking options:\n"
346-
" -c NUM number of concurrent database clients (default: 1)\n"
347-
" -C establish new connection for each transaction\n"
348-
" -D VARNAME=VALUE\n"
349-
" define variable for use by custom script\n"
350-
" -f FILENAME read transaction script from FILENAME\n"
351-
" -j NUM number of threads (default: 1)\n"
352-
" -l write transaction times to log file\n"
353-
" -M simple|extended|prepared\n"
354-
" protocol for submitting queries to server (default: simple)\n"
355-
" -n do not run VACUUM before tests\n"
356-
" -N do not update tables \"pgbench_tellers\" and \"pgbench_branches\"\n"
357-
" -r report average latency per command\n"
358-
" -s NUM report this scale factor in output\n"
359-
" -S perform SELECT-only transactions\n"
360-
" -t NUM number of transactions each client runs (default: 10)\n"
361-
" -T NUM duration of benchmark test in seconds\n"
362-
" -v vacuum all four standard tables before tests\n"
363-
" --aggregate-interval=NUM\n"
364-
" aggregate data over NUM seconds\n"
365-
" --sampling-rate=NUM\n"
366-
" fraction of transactions to log (e.g. 0.01 for 1%% sample)\n"
343+
" -c, --client=NUM number of concurrent database clients (default: 1)\n"
344+
" -C, --connect establish new connection for each transaction\n"
345+
" -D, --define=VARNAME=VALUE\n"
346+
" define variable for use by custom script\n"
347+
" -f, --file=FILENAME read transaction script from FILENAME\n"
348+
" -j, --jobs=NUM number of threads (default: 1)\n"
349+
" -l, --log write transaction times to log file\n"
350+
" -M, --protocol=simple|extended|prepared\n"
351+
" protocol for submitting queries "
352+
"(default: simple)\n"
353+
" -n, --no-vacuum do not run VACUUM before tests\n"
354+
" -N, --skip-some-updates skip updates of pgbench_tellers and pgbench_branches\n"
355+
" -r, --report-latencies report average latency per command\n"
356+
" -s, --scale=NUM report this scale factor in output\n"
357+
" -S, --select-only perform SELECT-only transactions\n"
358+
" -t, --transactions number of transactions each client runs "
359+
"(default: 10)\n"
360+
" -T, --time=NUM duration of benchmark test in seconds\n"
361+
" -v, --vacuum-all vacuum all four standard tables before tests\n"
362+
" --aggregate-interval=NUM aggregate data over NUM seconds\n"
363+
" --sampling-rate=NUM fraction of transactions to log (e.g. 0.01 for 1%%)\n"
367364
"\nCommon options:\n"
368-
" -d print debugging output\n"
369-
" -h HOSTNAME database server host or socket directory\n"
370-
" -p PORT database server port number\n"
371-
" -U USERNAME connect as specified database user\n"
372-
" -V, --version output version information, then exit\n"
373-
" -?, --help show this help, then exit\n"
365+
" -d, --debug print debugging output\n"
366+
" -h, --host=HOSTNAME database server host or socket directory\n"
367+
" -p, --port=PORT database server port number\n"
368+
" -U, --username=USERNAME connect as specified database user\n"
369+
" -V, --version output version information, then exit\n"
370+
" -?, --help show this help, then exit\n"
374371
"\n"
375372
"Report bugs to <pgsql-bugs@postgresql.org>.\n",
376373
progname, progname);
@@ -2109,6 +2106,30 @@ int
21092106
main(int argc, char **argv)
21102107
{
21112108
static struct option long_options[] = {
2109+
/* systematic long/short named options*/
2110+
{"client", required_argument, NULL, 'c'},
2111+
{"connect", no_argument, NULL, 'C'},
2112+
{"debug", no_argument, NULL, 'd'},
2113+
{"define", required_argument, NULL, 'D'},
2114+
{"file", required_argument, NULL, 'f'},
2115+
{"fillfactor", required_argument, NULL, 'F'},
2116+
{"host", required_argument, NULL, 'h'},
2117+
{"initialize", no_argument, NULL, 'i'},
2118+
{"jobs", required_argument, NULL, 'j'},
2119+
{"log", no_argument, NULL, 'l'},
2120+
{"no-vacuum", no_argument, NULL, 'n'},
2121+
{"port", required_argument, NULL, 'p'},
2122+
{"protocol", required_argument, NULL, 'M'},
2123+
{"quiet", no_argument, NULL, 'q'},
2124+
{"report-latencies", no_argument, NULL, 'r'},
2125+
{"scale", required_argument, NULL, 's'},
2126+
{"select-only", no_argument, NULL, 'S'},
2127+
{"skip-some-updates", no_argument, NULL, 'N'},
2128+
{"time", required_argument, NULL, 'T'},
2129+
{"transactions", required_argument, NULL, 't'},
2130+
{"username", required_argument, NULL, 'U'},
2131+
{"vacuum-all", no_argument, NULL, 'v'},
2132+
/* long-named only options */
21122133
{"foreign-keys", no_argument, &foreign_keys, 1},
21132134
{"index-tablespace", required_argument, NULL, 3},
21142135
{"tablespace", required_argument, NULL, 2},

doc/src/sgml/pgbench.sgml

+24
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
150150

151151
<varlistentry>
152152
<term><option>-i</option></term>
153+
<term><option>--initialize</option></term>
153154
<listitem>
154155
<para>
155156
Required to invoke initialization mode.
@@ -159,6 +160,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
159160

160161
<varlistentry>
161162
<term><option>-F</option> <replaceable>fillfactor</></term>
163+
<term><option>--fillfactor=</option><replaceable>fillfactor</></term>
162164
<listitem>
163165
<para>
164166
Create the <structname>pgbench_accounts</>,
@@ -171,6 +173,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
171173

172174
<varlistentry>
173175
<term><option>-n</option></term>
176+
<term><option>--no-vacuum</option></term>
174177
<listitem>
175178
<para>
176179
Perform no vacuuming after initialization.
@@ -180,6 +183,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
180183

181184
<varlistentry>
182185
<term><option>-q</option></term>
186+
<term><option>--quiet</option></term>
183187
<listitem>
184188
<para>
185189
Switch logging to quiet mode, producing only one progress message per 5
@@ -191,6 +195,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
191195

192196
<varlistentry>
193197
<term><option>-s</option> <replaceable>scale_factor</></term>
198+
<term><option>--scale=</option><replaceable>scale_factor</></term>
194199
<listitem>
195200
<para>
196201
Multiply the number of rows generated by the scale factor.
@@ -259,6 +264,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
259264

260265
<varlistentry>
261266
<term><option>-c</option> <replaceable>clients</></term>
267+
<term><option>--client=</option><replaceable>clients</></term>
262268
<listitem>
263269
<para>
264270
Number of clients simulated, that is, number of concurrent database
@@ -269,6 +275,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
269275

270276
<varlistentry>
271277
<term><option>-C</option></term>
278+
<term><option>--connect</option></term>
272279
<listitem>
273280
<para>
274281
Establish a new connection for each transaction, rather than
@@ -280,6 +287,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
280287

281288
<varlistentry>
282289
<term><option>-d</option></term>
290+
<term><option>--debug</option></term>
283291
<listitem>
284292
<para>
285293
Print debugging output.
@@ -289,6 +297,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
289297

290298
<varlistentry>
291299
<term><option>-D</option> <replaceable>varname</><literal>=</><replaceable>value</></term>
300+
<term><option>--define=</option><replaceable>varname</><literal>=</><replaceable>value</></term>
292301
<listitem>
293302
<para>
294303
Define a variable for use by a custom script (see below).
@@ -299,6 +308,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
299308

300309
<varlistentry>
301310
<term><option>-f</option> <replaceable>filename</></term>
311+
<term><option>--file=</option><replaceable>filename</></term>
302312
<listitem>
303313
<para>
304314
Read transaction script from <replaceable>filename</>.
@@ -311,6 +321,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
311321

312322
<varlistentry>
313323
<term><option>-j</option> <replaceable>threads</></term>
324+
<term><option>--jobs=</option><replaceable>threads</></term>
314325
<listitem>
315326
<para>
316327
Number of worker threads within <application>pgbench</application>.
@@ -324,6 +335,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
324335

325336
<varlistentry>
326337
<term><option>-l</option></term>
338+
<term><option>--log</option></term>
327339
<listitem>
328340
<para>
329341
Write the time taken by each transaction to a log file.
@@ -334,6 +346,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
334346

335347
<varlistentry>
336348
<term><option>-M</option> <replaceable>querymode</></term>
349+
<term><option>--protocol=</option><replaceable>querymode</></term>
337350
<listitem>
338351
<para>
339352
Protocol to use for submitting queries to the server:
@@ -356,6 +369,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
356369

357370
<varlistentry>
358371
<term><option>-n</option></term>
372+
<term><option>--no-vacuum</option></term>
359373
<listitem>
360374
<para>
361375
Perform no vacuuming before running the test.
@@ -370,6 +384,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
370384

371385
<varlistentry>
372386
<term><option>-N</option></term>
387+
<term><option>--skip-some-updates</option></term>
373388
<listitem>
374389
<para>
375390
Do not update <structname>pgbench_tellers</> and
@@ -382,6 +397,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
382397

383398
<varlistentry>
384399
<term><option>-r</option></term>
400+
<term><option>--report-latencies</option></term>
385401
<listitem>
386402
<para>
387403
Report the average per-statement latency (execution time from the
@@ -393,6 +409,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
393409

394410
<varlistentry>
395411
<term><option>-s</option> <replaceable>scale_factor</></term>
412+
<term><option>--scale=</option><replaceable>scale_factor</></term>
396413
<listitem>
397414
<para>
398415
Report the specified scale factor in <application>pgbench</>'s
@@ -407,6 +424,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
407424

408425
<varlistentry>
409426
<term><option>-S</option></term>
427+
<term><option>--select-only</option></term>
410428
<listitem>
411429
<para>
412430
Perform select-only transactions instead of TPC-B-like test.
@@ -416,6 +434,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
416434

417435
<varlistentry>
418436
<term><option>-t</option> <replaceable>transactions</></term>
437+
<term><option>--transactions=</option><replaceable>transactions</></term>
419438
<listitem>
420439
<para>
421440
Number of transactions each client runs. Default is 10.
@@ -425,6 +444,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
425444

426445
<varlistentry>
427446
<term><option>-T</option> <replaceable>seconds</></term>
447+
<term><option>--time=</option><replaceable>seconds</></term>
428448
<listitem>
429449
<para>
430450
Run the test for this many seconds, rather than a fixed number of
@@ -436,6 +456,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
436456

437457
<varlistentry>
438458
<term><option>-v</option></term>
459+
<term><option>--vacuum-all</option></term>
439460
<listitem>
440461
<para>
441462
Vacuum all four standard tables before running the test.
@@ -495,6 +516,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
495516

496517
<varlistentry>
497518
<term><option>-h</option> <replaceable>hostname</></term>
519+
<term><option>--host=</option><replaceable>hostname</></term>
498520
<listitem>
499521
<para>
500522
The database server's host name
@@ -504,6 +526,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
504526

505527
<varlistentry>
506528
<term><option>-p</option> <replaceable>port</></term>
529+
<term><option>--port=</option><replaceable>port</></term>
507530
<listitem>
508531
<para>
509532
The database server's port number
@@ -513,6 +536,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
513536

514537
<varlistentry>
515538
<term><option>-U</option> <replaceable>login</></term>
539+
<term><option>--username=</option><replaceable>login</></term>
516540
<listitem>
517541
<para>
518542
The user name to connect as

0 commit comments

Comments
 (0)