Track IO times in pg_stat_io

Melanie Plageman <melanieplageman@gmail.com>

From: Melanie Plageman <melanieplageman@gmail.com>
To: Pg Hackers <pgsql-hackers@postgresql.org>
Cc: Maciek Sakrejda <m.sakrejda@gmail.com>, Justin Pryzby <pryzby@telsasoft.com>, smilingsamay@gmail.com, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, Lukas Fittl <lukas@fittl.com>, Magnus Hagander <magnus@hagander.net>, Andres Freund <andres@anarazel.de>, Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: 2023-02-26T16:03:43Z
Lists: pgsql-hackers

Attachments

Hi,

As suggested in [1], the attached patch adds IO times to pg_stat_io;

I added docs but haven't added any tests. The timings will only be
non-zero when track_io_timing is on, and I only see tests with track IO
timing on in explain.sql and the IO timings I added to pg_stat_io would
not be visible there.

I didn't split it up into two patches (one with the changes to track IO
timing and 1 with the view additions and docs), because I figured the
overall diff is pretty small.

There is one minor question (in the code as a TODO) which is whether or
not it is worth cross-checking that IO counts and times are either both
zero or neither zero in the validation function
pgstat_bktype_io_stats_valid().

- Melanie

[1] https://www.postgresql.org/message-id/20230209050319.chyyup4vtq4jzobq%40awork3.anarazel.de

Commits

  1. Improve IO accounting for temp relation writes