Hi Shihao,
On 19/09/2026 05:07, shihao zhong wrote:
> Hi Bernd,
>
> Thanks for testing.
>
> > blks_read differs exactly by 3 and blks_hit by 7
>
> I can reproduce this, and it does not need a restart. pg_stat_reset()
> clears the database entry and pg_stat_reset_shared() clears the tablespace
> entry. If more than a second passes between them, the backend flushes its
> pending counts in the gap, and the entry that was reset first keeps them.
> Swapping the two resets flips the sign. With both resets in one statement
> the numbers always match.
>
Yes, this explains it.
> > there is some skew in blk_read_time and blk_write_time
>
> Part of it was the second clock read. v7 reuses the time that
> pgstat_count_io_op_time() already computed.
>
>
> > one test still checks for >= 0
>
> Fixed.
>
I like this: Having the test being strictly bigger and comparing to
beforehand values makes much sense to me.
> v7 attached.
>
> Thanks,
> Shihao
>
>
>
Best
Bernd