Re: Flush some statistics within running transactions

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Subject: Re: Flush some statistics within running transactions
Date: 2026-01-22 17:23:29
Message-ID: CAA5RZ0vbL8fw4h7JQEuLE5JqLqVbG+7oBKkM_4eONMe=yJ=Veg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> 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?

--
Sami Imseih
Amazon Web Services (AWS)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2026-01-22 17:31:01 Re: Fix rounding method used to compute huge pages
Previous Message Ashutosh Bapat 2026-01-22 17:22:08 Remove PG_MMAP_FLAGS