+
+
+
+ Set the filename prefix for the transaction log file created by
+
+
+
+
+
With the ,
pgbench> writes the time taken by each transaction
to a log file. The log file will be named
- pgbench_log.nnn>, where
-
nnn> is the PID of the pgbench process.
- If the
- threads, each will have its own log file. The first worker will use the
- same name for its log file as in the standard single worker case.
+ prefix>.nnn>,
+ where prefix> defaults to pgbench_log>, and
+ nnn> is the PID of the
+
pgbench process. If the
+ creating multiple worker threads, each will have its own log file. The first worker will
+ use the same name for its log file as in the standard single worker case.
The additional log files for the other workers will be named
- pgbench_log.nnn>.mmm>,
+ pgbench_log>.nnn>.mmm>,
where mmm> is a sequential number for each worker starting
- with 1.
+ with 1. The prefix can be changed by using the
+ option.
char *pgport = "";
char *login = NULL;
char *dbName;
+char *logfile_prefix = NULL;
const char *progname;
#define WSEP '@' /* weight separator */
" --aggregate-interval=NUM aggregate data over NUM seconds\n"
" --progress-timestamp use Unix epoch timestamps for progress\n"
" --sampling-rate=NUM fraction of transactions to log (e.g., 0.01 for 1%%)\n"
+ " --log-prefix=PREFIX prefix for transaction time log file\n"
+ " (default: \"pgbench_log\")\n"
"\nCommon options:\n"
" -d, --debug print debugging output\n"
" -h, --host=HOSTNAME database server host or socket directory\n"
{"sampling-rate", required_argument, NULL, 4},
{"aggregate-interval", required_argument, NULL, 5},
{"progress-timestamp", no_argument, NULL, 6},
+ {"log-prefix", required_argument, NULL, 7},
{NULL, 0, NULL, 0}
};
progress_timestamp = true;
benchmarking_option_set = true;
break;
+ case 7:
+ benchmarking_option_set = true;
+ logfile_prefix = pg_strdup(optarg);
+ break;
default:
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
exit(1);
}
+ if (!use_log && logfile_prefix)
+ {
+ fprintf(stderr, "log file prefix (--log-prefix) is allowed only when logging transactions (-l)\n");
+ exit(1);
+ }
+
if (duration > 0 && agg_interval > duration)
{
fprintf(stderr, "number of seconds for aggregation (%d) must not be higher than test duration (%d)\n", agg_interval, duration);
if (use_log)
{
char logpath[64];
+ char *prefix = logfile_prefix ? logfile_prefix : "pgbench_log";
if (thread->tid == 0)
- snprintf(logpath, sizeof(logpath), "pgbench_log.%d", main_pid);
+ snprintf(logpath, sizeof(logpath), "%s.%d", prefix, main_pid);
else
- snprintf(logpath, sizeof(logpath), "pgbench_log.%d.%d", main_pid, thread->tid);
+ snprintf(logpath, sizeof(logpath), "%s.%d.%d", prefix, main_pid, thread->tid);
+
thread->logfile = fopen(logpath, "w");
if (thread->logfile == NULL)