Goal: observe I/O by backend/object/context with timing that lasts for the workload.
A SET inside one psql -c would end with that connection. Here ALTER SYSTEM enables track_io_timing and the separate WAL setting, reloads, then checks both in a fresh client. This is a cluster-wide lab change, restored at the end. Timing adds measurement overhead; small operations may still round to zero. -P null=NULL prints unsupported I/O fields as the word NULL rather than a blank.
All hints run at the Linux shell. psql -c executes quoted SQL and exits; each command uses a new connection. -U postgres explicitly selects the administrative SQL role, and -v ON_ERROR_STOP=1 stops on SQL errors. The monitoring tables are separate provided fixtures, not the baked business datasets.
Goal: verify the I/O reset’s timestamp instead of demanding an all-zero live cluster.
Store the request time, then reset shared I/O statistics. pg_stat_io aggregates the whole cluster by backend type, object, and context, not by table or individual statement. The next query can itself add activity. Expect reset_recorded=true; active_rows may be zero or positive. NULL means that operation is unsupported for that row, not zero work.
Goal: observe relation extension and WAL writes during a controlled insert window.
Insert 10,000 rows with 100-character payloads: expect INSERT 0 10000, 10,000 rows, and 1,000,000 logical payload bytes. Read normal-context relation and WAL counts, bytes, and times, then verify both activity flags. Counts aggregate other client activity too; this view cannot attribute every operation to this table or one SQL statement. WAL timing uses its own enabled setting, and NULL fields are not comparable to zero.
Goal: distinguish the kind of operation from the kind of backend.
Manually vacuum the fixture, whose autovacuum is disabled for this controlled comparison. Read normal and vacuum contexts. Expect positive vacuum reads or hits under client backend; the backend is your client because you ran VACUUM manually. Automatic cleanup would use autovacuum worker and may use other contexts too; that comparison is explained, not run in this lesson.
Goal: prove a new statistics window did not remove the inserted rows.
Store a new request time and reset the cluster I/O counters again. Inspect reset_recorded and current active rows, then count the fixture: it still contains 10,000 rows. Background work and these clients can immediately add new counters, so neither an empty view nor a guaranteed nonzero count is required for a successful reset.
Goal: remove the cluster-wide timing shortcut after observing the workload.
Reset both ALTER SYSTEM overrides, request reload, and verify this image’s defaults are off in a new client. Restore the fixture’s normal autovacuum setting. The measured data remains; resetting configuration/statistics is different from deleting it.