[PATCH] pgbench log file headers

From: Adam Hendel <adam(at)tembo(dot)io>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: [PATCH] pgbench log file headers
Date: 2023-11-13 17:55:07
Message-ID: CABfuTggpE-A5pvif9Zv++c4Jn3iu_7ccJ23Pm+8r+CKRBUMg_Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)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 Content-Type Size
v1-0001-Adds-log-header-flag-to-pgbench-which-adds-column.patch application/octet-stream 4.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2023-11-13 17:57:31 Re: Bug: RLS policy FOR SELECT is used to check new rows
Previous Message Bruce Momjian 2023-11-13 17:53:27 Re: COPY TO (FREEZE)?