Add missing stats_reset column to pg_stat_database_conflicts view

shihao zhong <zhong950419@gmail.com>

From: shihao zhong <zhong950419@gmail.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2026-03-09T22:11:33Z
Lists: pgsql-hackers

Attachments

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

Commits

  1. Simplify redundant current_database() subqueries in stats.sql regression test

  2. Add stats_reset column to pg_stat_database_conflicts.