Re: pg_stat_io for the startup process - Mailing list pgsql-hackers

From Andres Freund
Subject Re: pg_stat_io for the startup process
Date
Msg-id 20230508214643.5sqygke5ptxd2cqy@awork3.anarazel.de
Whole thread Raw
In response to Re: pg_stat_io for the startup process  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Responses Re: pg_stat_io for the startup process
List pgsql-hackers
Hi,

On 2023-04-26 18:47:14 +0900, Kyotaro Horiguchi wrote:
> I see four issues here.
> 
> 1. The current database stats omits buffer fetches that don't
>   originate from a relation.
> 
> In this case pgstat_relation can't work since recovery isn't conscious
> of relids.  We might be able to resolve relfilenode into a relid, but
> it may not be that simple. Fortunately we already count fetches and
> hits process-wide using pgBufferUsage, so we can use this for database
> stats.

I don't think we need to do anything about that for 16 - they aren't updated
at process end either.

I think the fix here is to do the architectural change of maintaining most
stats keyed by relfilenode as we've discussed in some other threads. Then we
also can have relation level write stats etc.


> 2. Even if we wanted to report stats for the startup process,
>   pgstat_report_stats wouldn't permit it since transaction-end
>   timestamp doesn't advance.
> 
> I'm not certain if it's the correct approach, but perhaps we could use
> GetCurrentTimestamp() instead of GetCurrentTransactionStopTimestamp()
> specifically for the startup process.

What about using GetCurrentTimestamp() when force == true? That'd make sense
for other users as well, I think?


> 3. When should we call pgstat_report_stats on the startup process?
> 
> During recovery, I think we can call pgstat_report_stats() (or a
> subset of it) right before invoking WaitLatch and at segment
> boundaries.

I've pondered that as well. But I don't think it's great - it's not exactly
intuitive that stats reporting gets far less common if you use a 1GB
wal_segment_size.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Melanie Plageman
Date:
Subject: Re: pg_stat_io for the startup process
Next
From: Tom Lane
Date:
Subject: Re: Order changes in PG16 since ICU introduction