[PATCH] pgbench log file headers - Mailing list pgsql-hackers

From Adam Hendel
Subject [PATCH] pgbench log file headers
Date
Msg-id CABfuTggpE-A5pvif9Zv++c4Jn3iu_7ccJ23Pm+8r+CKRBUMg_Q@mail.gmail.com
Whole thread Raw
Responses Re: [PATCH] pgbench log file headers
Re: [PATCH] pgbench log file headers
List pgsql-hackers

Hello Hackers!

Currently, pgbench will log individual transactions to a logfile when the `--log` parameter flag is provided. The logfile, however, does not include column header. It has become a fairly standard expectation of users to have column headers present in flat files. Without the header in the pgbench log files, new users must navigate to the docs and piece together the column headers themselves. Most industry leading frameworks have tooling built in to read column headers though, for example python/pandas read_csv().

We can improve the experience for users by adding column headers to pgbench logfiles with an optional command line flag, `--log-header`. This will keep the API backwards compatible by making users opt-in to the column headers. It follows the existing pattern of having conditional flags in pgbench’s API; the `--log` option would have both –log-prefix and –log-header if this work is accepted.

The implementation considers the column headers only when the `--log-header` flag is present. The values for the columns are taken directly from the “Per-Transaction Logging” section in https://www.postgresql.org/docs/current/pgbench.html and takes into account the conditional columns `schedule_lag` and `retries`.


Below is an example of what that logfile will look like:


pgbench  postgres://postgres:postgres@localhost:5432/postgres --log --log-header

client_id transaction_no time script_no time_epoch time_us

0 1 1863 0 1699555588 791102

0 2 706 0 1699555588 791812


If the interface and overall approach makes sense, I will work on adding documentation and tests for this too.

Respectfully,

Adam Hendel


Attachment

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: COPY TO (FREEZE)?
Next
From: Robert Haas
Date:
Subject: Re: Bug: RLS policy FOR SELECT is used to check new rows