mirror of
https://github.com/postgres/postgres.git
synced 2026-03-23 02:43:22 -04:00
Add stats_reset column to pg_stat_database_conflicts.
This commit adds a stats_reset column to pg_stat_database_conflicts, allowing users to see when the statistics in this view were last reset. This makes the view consistent with pg_stat_database and other statistics views. Catalog version bumped. Author: Shihao Zhong <zhong950419@gmail.com> Reviewed-by: Sami Imseih <samimseih@gmail.com> Reviewed-by: Kirill Reshke <reshkekirill@gmail.com> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/CAGRkXqS98OebEWjax99_LVAECsxCB8i=BfsdAL34i-5QHfwyOQ@mail.gmail.com
This commit is contained in:
parent
2e1dcf8c54
commit
723619eaa3
6 changed files with 38 additions and 7 deletions
|
|
@ -4036,6 +4036,15 @@ description | Waiting for a newly initialized WAL file to reach durable storage
|
|||
on the primary
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
<structfield>stats_reset</structfield> <type>timestamp with time zone</type>
|
||||
</para>
|
||||
<para>
|
||||
Time at which these statistics were last reset
|
||||
</para></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -1163,7 +1163,8 @@ CREATE VIEW pg_stat_database_conflicts AS
|
|||
pg_stat_get_db_conflict_snapshot(D.oid) AS confl_snapshot,
|
||||
pg_stat_get_db_conflict_bufferpin(D.oid) AS confl_bufferpin,
|
||||
pg_stat_get_db_conflict_startup_deadlock(D.oid) AS confl_deadlock,
|
||||
pg_stat_get_db_conflict_logicalslot(D.oid) AS confl_active_logicalslot
|
||||
pg_stat_get_db_conflict_logicalslot(D.oid) AS confl_active_logicalslot,
|
||||
pg_stat_get_db_stat_reset_time(D.oid) AS stats_reset
|
||||
FROM pg_database D;
|
||||
|
||||
CREATE VIEW pg_stat_user_functions AS
|
||||
|
|
|
|||
|
|
@ -57,6 +57,6 @@
|
|||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 202603101
|
||||
#define CATALOG_VERSION_NO 202603131
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1921,7 +1921,8 @@ pg_stat_database_conflicts| SELECT oid AS datid,
|
|||
pg_stat_get_db_conflict_snapshot(oid) AS confl_snapshot,
|
||||
pg_stat_get_db_conflict_bufferpin(oid) AS confl_bufferpin,
|
||||
pg_stat_get_db_conflict_startup_deadlock(oid) AS confl_deadlock,
|
||||
pg_stat_get_db_conflict_logicalslot(oid) AS confl_active_logicalslot
|
||||
pg_stat_get_db_conflict_logicalslot(oid) AS confl_active_logicalslot,
|
||||
pg_stat_get_db_stat_reset_time(oid) AS stats_reset
|
||||
FROM pg_database d;
|
||||
pg_stat_gssapi| SELECT pid,
|
||||
gss_auth AS gss_authenticated,
|
||||
|
|
|
|||
|
|
@ -1131,8 +1131,10 @@ SELECT stats_reset > :'wal_reset_ts'::timestamptz FROM pg_stat_wal;
|
|||
SELECT pg_stat_reset_shared('unknown');
|
||||
ERROR: unrecognized reset target: "unknown"
|
||||
HINT: Target must be "archiver", "bgwriter", "checkpointer", "io", "recovery_prefetch", "slru", or "wal".
|
||||
-- Test that reset works for pg_stat_database
|
||||
-- Since pg_stat_database stats_reset starts out as NULL, reset it once first so we have something to compare it to
|
||||
-- Test that reset works for pg_stat_database and pg_stat_database_conflicts
|
||||
-- Since pg_stat_database stats_reset starts out as NULL, reset it once first so that we
|
||||
-- have a baseline for comparison. The same for pg_stat_database_conflicts as it shares
|
||||
-- the same stats_reset as pg_stat_database.
|
||||
SELECT pg_stat_reset();
|
||||
pg_stat_reset
|
||||
---------------
|
||||
|
|
@ -1140,6 +1142,13 @@ SELECT pg_stat_reset();
|
|||
(1 row)
|
||||
|
||||
SELECT stats_reset AS db_reset_ts FROM pg_stat_database WHERE datname = (SELECT current_database()) \gset
|
||||
SELECT stats_reset AS dbc_reset_ts FROM pg_stat_database_conflicts WHERE datname = (SELECT current_database()) \gset
|
||||
SELECT :'db_reset_ts'::timestamptz = :'dbc_reset_ts'::timestamptz;
|
||||
?column?
|
||||
----------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT pg_stat_reset();
|
||||
pg_stat_reset
|
||||
---------------
|
||||
|
|
@ -1152,6 +1161,12 @@ SELECT stats_reset > :'db_reset_ts'::timestamptz FROM pg_stat_database WHERE dat
|
|||
t
|
||||
(1 row)
|
||||
|
||||
SELECT stats_reset > :'dbc_reset_ts'::timestamptz FROM pg_stat_database_conflicts WHERE datname = (SELECT current_database());
|
||||
?column?
|
||||
----------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
----
|
||||
-- pg_stat_get_snapshot_timestamp behavior
|
||||
----
|
||||
|
|
|
|||
|
|
@ -523,13 +523,18 @@ SELECT stats_reset > :'wal_reset_ts'::timestamptz FROM pg_stat_wal;
|
|||
-- Test error case for reset_shared with unknown stats type
|
||||
SELECT pg_stat_reset_shared('unknown');
|
||||
|
||||
-- Test that reset works for pg_stat_database
|
||||
-- Test that reset works for pg_stat_database and pg_stat_database_conflicts
|
||||
|
||||
-- Since pg_stat_database stats_reset starts out as NULL, reset it once first so we have something to compare it to
|
||||
-- Since pg_stat_database stats_reset starts out as NULL, reset it once first so that we
|
||||
-- have a baseline for comparison. The same for pg_stat_database_conflicts as it shares
|
||||
-- the same stats_reset as pg_stat_database.
|
||||
SELECT pg_stat_reset();
|
||||
SELECT stats_reset AS db_reset_ts FROM pg_stat_database WHERE datname = (SELECT current_database()) \gset
|
||||
SELECT stats_reset AS dbc_reset_ts FROM pg_stat_database_conflicts WHERE datname = (SELECT current_database()) \gset
|
||||
SELECT :'db_reset_ts'::timestamptz = :'dbc_reset_ts'::timestamptz;
|
||||
SELECT pg_stat_reset();
|
||||
SELECT stats_reset > :'db_reset_ts'::timestamptz FROM pg_stat_database WHERE datname = (SELECT current_database());
|
||||
SELECT stats_reset > :'dbc_reset_ts'::timestamptz FROM pg_stat_database_conflicts WHERE datname = (SELECT current_database());
|
||||
|
||||
|
||||
----
|
||||
|
|
|
|||
Loading…
Reference in a new issue