Add missing stats_reset column to pg_stat_database_conflicts view

Started by shihao zhongabout 6 hours ago3 messages
Jump to latest
#1shihao zhong
zhong950419@gmail.com

Hi hackers,

Currently, pg_stat_database and pg_stat_database_conflicts are
decoupled into two separate views. However, there is an inconsistency:
pg_stat_database_conflicts is missing the stats_reset column.

Implementation wise, both views expose data from PgStat_StatDBEntry
and share the same reset lifecycle when pg_stat_reset() is called.

For now, users monitoring recovery conflicts have to get the reset
time from pg_stat_database. I would like these two views to be purely
decoupled to avoid such confusion.

The attached patch adds pg_stat_get_db_stat_reset_time() to fix this
inconsistency.

Please let me know your thoughts.

Thanks,
Shihao

Attachments:

pg_stat_database_conflict.patchapplication/octet-stream; name=pg_stat_database_conflict.patchDownload+4-2
#2Sami Imseih
samimseih@gmail.com
In reply to: shihao zhong (#1)
Re: Add missing stats_reset column to pg_stat_database_conflicts view

The attached patch adds pg_stat_get_db_stat_reset_time() to fix this
inconsistency.

Please let me know your thoughts.

This view was introduced 15 years ago, and surprisingly this is the
first complaint about this. I am also not very surprised.

I also noticed that pg_statio_all_sequences does not have a reset
column. We should fix this one also. What do you think?

With regards to your attached patch, it's missing the doc changes.
but also the patch does not apply.

--
Sami Imseih
Amazon Web Services (AWS)

#3Fujii Masao
masao.fujii@gmail.com
In reply to: Sami Imseih (#2)
Re: Add missing stats_reset column to pg_stat_database_conflicts view

On Tue, Mar 10, 2026 at 8:33 AM Sami Imseih <samimseih@gmail.com> wrote:

The attached patch adds pg_stat_get_db_stat_reset_time() to fix this
inconsistency.

Please let me know your thoughts.

This view was introduced 15 years ago, and surprisingly this is the
first complaint about this. I am also not very surprised.

I also noticed that pg_statio_all_sequences does not have a reset
column. We should fix this one also. What do you think?

+1

Also it might be better to update the docs together so that the description of
pg_stat_reset_single_table_counters mentions sequences in addition to
tables and indexes.

Regards,

--
Fujii Masao