diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c new file mode 100644 index 1303217..22a97f7 *** a/contrib/pgbench/pgbench.c --- b/contrib/pgbench/pgbench.c *************** double sample_rate = 0.0; *** 142,147 **** --- 142,148 ---- char *tablespace = NULL; char *index_tablespace = NULL; + char *startup = NULL; /* * end of configurable parameters *********************************************************************/ *************** usage(void) *** 343,349 **** " --unlogged-tables\n" " create tables as unlogged tables\n" "\nBenchmarking options:\n" ! " -c NUM number of concurrent database clients (default: 1)\n" " -C establish new connection for each transaction\n" " -D VARNAME=VALUE\n" " define variable for use by custom script\n" --- 344,350 ---- " --unlogged-tables\n" " create tables as unlogged tables\n" "\nBenchmarking options:\n" ! " -c NUM number of concurrent database clients (default: 1)\n" " -C establish new connection for each transaction\n" " -D VARNAME=VALUE\n" " define variable for use by custom script\n" *************** usage(void) *** 357,369 **** " -r report average latency per command\n" " -s NUM report this scale factor in output\n" " -S perform SELECT-only transactions\n" ! " -t NUM number of transactions each client runs (default: 10)\n" " -T NUM duration of benchmark test in seconds\n" " -v vacuum all four standard tables before tests\n" " --aggregate-interval=NUM\n" " aggregate data over NUM seconds\n" " --sampling-rate=NUM\n" " fraction of transactions to log (e.g. 0.01 for 1%% sample)\n" "\nCommon options:\n" " -d print debugging output\n" " -h HOSTNAME database server host or socket directory\n" --- 358,372 ---- " -r report average latency per command\n" " -s NUM report this scale factor in output\n" " -S perform SELECT-only transactions\n" ! " -t NUM number of transactions each client runs (default: 10)\n" " -T NUM duration of benchmark test in seconds\n" " -v vacuum all four standard tables before tests\n" " --aggregate-interval=NUM\n" " aggregate data over NUM seconds\n" " --sampling-rate=NUM\n" " fraction of transactions to log (e.g. 0.01 for 1%% sample)\n" + " --startup=COMMAND\n" + " Run COMMAND upon creating each benchmarking connection\n" "\nCommon options:\n" " -d print debugging output\n" " -h HOSTNAME database server host or socket directory\n" *************** executeStatement(PGconn *con, const char *** 469,475 **** res = PQexec(con, sql); if (PQresultStatus(res) != PGRES_COMMAND_OK) { ! fprintf(stderr, "%s", PQerrorMessage(con)); exit(1); } PQclear(res); --- 472,478 ---- res = PQexec(con, sql); if (PQresultStatus(res) != PGRES_COMMAND_OK) { ! fprintf(stderr, "Command failed with %s", PQerrorMessage(con)); exit(1); } PQclear(res); *************** doConnect(void) *** 542,547 **** --- 545,562 ---- return conn; } + /* set up a connection to the backend intended for benchmarking */ + static PGconn * + doBenchMarkConnect(void) + { + PGconn * conn; + conn = doConnect(); + if (startup != NULL) { + executeStatement(conn, startup); + } + return conn; + } + /* throw away response from backend */ static void discard_response(CState *state) *************** top: *** 1104,1110 **** end; INSTR_TIME_SET_CURRENT(start); ! if ((st->con = doConnect()) == NULL) { fprintf(stderr, "Client %d aborted in establishing connection.\n", st->id); return clientDone(st, false); --- 1119,1125 ---- end; INSTR_TIME_SET_CURRENT(start); ! if ((st->con = doBenchMarkConnect()) == NULL) { fprintf(stderr, "Client %d aborted in establishing connection.\n", st->id); return clientDone(st, false); *************** main(int argc, char **argv) *** 2115,2120 **** --- 2130,2136 ---- {"unlogged-tables", no_argument, &unlogged_tables, 1}, {"sampling-rate", required_argument, NULL, 4}, {"aggregate-interval", required_argument, NULL, 5}, + {"startup", required_argument, NULL, 6}, {NULL, 0, NULL, 0} }; *************** main(int argc, char **argv) *** 2366,2371 **** --- 2382,2390 ---- } #endif break; + case 6: /* startup COMMAND */ + startup = pg_strdup(optarg); + break; default: fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); *************** threadRun(void *arg) *** 2742,2748 **** /* make connections to the database */ for (i = 0; i < nstate; i++) { ! if ((state[i].con = doConnect()) == NULL) goto done; } } --- 2761,2767 ---- /* make connections to the database */ for (i = 0; i < nstate; i++) { ! if ((state[i].con = doBenchMarkConnect()) == NULL) goto done; } } diff --git a/doc/src/sgml/pgbench.sgml b/doc/src/sgml/pgbench.sgml new file mode 100644 index 8775606..ff15864 *** a/doc/src/sgml/pgbench.sgml --- b/doc/src/sgml/pgbench.sgml *************** pgbench options< *** 479,484 **** --- 479,499 ---- + + + + + Execute the COMMAND upon the establishment + of each connection intended for receipt of benchmarking queries. + + + For example --startup="set synchronous_commit=off" will cause benchmarking + to be done without fsyncing the WAL for every transaction, regardless of the default + server settings. + + + +