mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Track last time for statistics reset on databases and bgwriter
Tracks one counter for each database, which is reset whenever the statistics for any individual object inside the database is reset, and one counter for the background writer. Tomas Vondra, reviewed by Greg Smith
This commit is contained in:
@ -77,12 +77,14 @@ extern Datum pg_stat_get_db_conflict_snapshot(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_conflict_bufferpin(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_conflict_startup_deadlock(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_conflict_all(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_stat_reset_time(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum pg_stat_get_bgwriter_timed_checkpoints(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_bgwriter_requested_checkpoints(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_bgwriter_buf_written_checkpoints(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_bgwriter_buf_written_clean(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_bgwriter_maxwritten_clean(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_bgwriter_stat_reset_time(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_buf_written_backend(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_buf_fsync_backend(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_buf_alloc(PG_FUNCTION_ARGS);
|
||||
@ -1135,6 +1137,24 @@ pg_stat_get_db_tuples_deleted(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT64(result);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_db_stat_reset_time(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid dbid = PG_GETARG_OID(0);
|
||||
TimestampTz result;
|
||||
PgStat_StatDBEntry *dbentry;
|
||||
|
||||
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
||||
result = 0;
|
||||
else
|
||||
result = dbentry->stat_reset_timestamp;
|
||||
|
||||
if (result == 0)
|
||||
PG_RETURN_NULL();
|
||||
else
|
||||
PG_RETURN_TIMESTAMPTZ(result);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_db_conflict_tablespace(PG_FUNCTION_ARGS)
|
||||
{
|
||||
@ -1260,6 +1280,12 @@ pg_stat_get_bgwriter_maxwritten_clean(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT64(pgstat_fetch_global()->maxwritten_clean);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_bgwriter_stat_reset_time(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_TIMESTAMPTZ(pgstat_fetch_global()->stat_reset_timestamp);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_buf_written_backend(PG_FUNCTION_ARGS)
|
||||
{
|
||||
|
Reference in New Issue
Block a user