mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Show shared object statistics in pg_stat_database
This adds a row to the pg_stat_database view with datoid 0 and datname NULL for those objects that are not in a database. This was added particularly for checksums, but we were already tracking more satistics for these objects, just not returning it. Also add a checksum_last_failure column that holds the timestamptz of the last checksum failure that occurred in a database (or in a non-dataabase file), if any. Author: Julien Rouhaud <rjuju123@gmail.com>
This commit is contained in:
@ -1805,7 +1805,10 @@ pg_stat_bgwriter| SELECT pg_stat_get_bgwriter_timed_checkpoints() AS checkpoints
|
||||
pg_stat_get_bgwriter_stat_reset_time() AS stats_reset;
|
||||
pg_stat_database| SELECT d.oid AS datid,
|
||||
d.datname,
|
||||
pg_stat_get_db_numbackends(d.oid) AS numbackends,
|
||||
CASE
|
||||
WHEN (d.oid = (0)::oid) THEN NULL::integer
|
||||
ELSE pg_stat_get_db_numbackends(d.oid)
|
||||
END AS numbackends,
|
||||
pg_stat_get_db_xact_commit(d.oid) AS xact_commit,
|
||||
pg_stat_get_db_xact_rollback(d.oid) AS xact_rollback,
|
||||
(pg_stat_get_db_blocks_fetched(d.oid) - pg_stat_get_db_blocks_hit(d.oid)) AS blks_read,
|
||||
@ -1820,10 +1823,16 @@ pg_stat_database| SELECT d.oid AS datid,
|
||||
pg_stat_get_db_temp_bytes(d.oid) AS temp_bytes,
|
||||
pg_stat_get_db_deadlocks(d.oid) AS deadlocks,
|
||||
pg_stat_get_db_checksum_failures(d.oid) AS checksum_failures,
|
||||
pg_stat_get_db_checksum_last_failure(d.oid) AS checksum_last_failure,
|
||||
pg_stat_get_db_blk_read_time(d.oid) AS blk_read_time,
|
||||
pg_stat_get_db_blk_write_time(d.oid) AS blk_write_time,
|
||||
pg_stat_get_db_stat_reset_time(d.oid) AS stats_reset
|
||||
FROM pg_database d;
|
||||
FROM ( SELECT 0 AS oid,
|
||||
NULL::name AS datname
|
||||
UNION ALL
|
||||
SELECT pg_database.oid,
|
||||
pg_database.datname
|
||||
FROM pg_database) d;
|
||||
pg_stat_database_conflicts| SELECT d.oid AS datid,
|
||||
d.datname,
|
||||
pg_stat_get_db_conflict_tablespace(d.oid) AS confl_tablespace,
|
||||
|
Reference in New Issue
Block a user