Re: Flush some statistics within running transactions - Mailing list pgsql-hackers

From Bertrand Drouvot
Subject Re: Flush some statistics within running transactions
Date
Msg-id aXcZODT8H3AfdccG@ip-10-97-1-34.eu-west-3.compute.internal
Whole thread Raw
In response to Re: Flush some statistics within running transactions  (Sami Imseih <samimseih@gmail.com>)
Responses Re: Flush some statistics within running transactions
List pgsql-hackers
Hi,

On Thu, Jan 22, 2026 at 11:23:29AM -0600, Sami Imseih wrote:
> > For example, pgstat_update_dbstats() updates some of them: xact_commit, xact_rollback,
> > blk_read_time, blk_write_time, session_time, active_time and idle_in_transaction_time
> > but only at transaction boundaries. Indeed, pgstat_update_dbstats() is only called
> > during pgstat_report_stat() and not during pgstat_report_anytime_stat().
> >
> > I think that we could:
> >
> > 1. Update the doc as you suggest
> 
> I am thinking the _time related fields are OK to be non-anytime
> fields, since they
> have overhead and also they can be actively monitored from pg_stat_activity
> if someone really needs real time information.
> 
> The other session related counters don't need need special consideration.
> 
> parallel counters are anytime.
> 
> So, the documentation can mention the _time related fields that are flushed
> only at their appropriate times.
> 
> Maybe something general like this:
> 
> "Some statistics are updated while a transaction is in progress.
> Statistics that either do
> not depend on transactions or require transactional consistency are
> updated only
> when the transaction ends. Statistics that require transactional consistency
> include xact_commit, xact_rollback, tup_inserted, tup_updated, and tup_deleted."
> 
> What do you think?

Thanks! 

That sounds good, maybe just change the first sentence to something like:

"
Some statistics are updated while a transaction is in progress (this includes
blks_read, blks_hit, tup_returned and tup_fetched).
"

Thoughts?

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com



pgsql-hackers by date:

Previous
From: Antonin Houska
Date:
Subject: Re: Adding REPACK [concurrently]
Next
From: Michael Paquier
Date:
Subject: Re: Extended Statistics set/restore/clear functions.