mirror of
https://github.com/postgres/postgres.git
synced 2025-07-24 14:22:24 +03:00
Introduce pg_stat_checkpointer
Historically, the statistics of the checkpointer have been always part of pg_stat_bgwriter. This commit removes a few columns from pg_stat_bgwriter, and introduces pg_stat_checkpointer with equivalent, renamed columns (plus a new one for the reset timestamp): - checkpoints_timed -> num_timed - checkpoints_req -> num_requested - checkpoint_write_time -> write_time - checkpoint_sync_time -> sync_time - buffers_checkpoint -> buffers_written The fields of PgStat_CheckpointerStats and its SQL functions are renamed to match with the new field names, for consistency. Note that background writer and checkpointer have been split into two different processes in commits806a2aee37
andbf405ba8e4
. The pgstat structures were already split, making this change straight-forward. Bump catalog version. Author: Bharath Rupireddy Reviewed-by: Bertrand Drouvot, Andres Freund, Michael Paquier Discussion: https://postgr.es/m/CALj2ACVxX2ii=66RypXRweZe2EsBRiPMj0aHfRfHUeXJcC7kHg@mail.gmail.com
This commit is contained in:
@ -1182,21 +1182,21 @@ PG_STAT_GET_DBENTRY_FLOAT8_MS(idle_in_transaction_time)
|
||||
PG_STAT_GET_DBENTRY_FLOAT8_MS(session_time)
|
||||
|
||||
Datum
|
||||
pg_stat_get_bgwriter_timed_checkpoints(PG_FUNCTION_ARGS)
|
||||
pg_stat_get_checkpointer_num_timed(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_INT64(pgstat_fetch_stat_checkpointer()->timed_checkpoints);
|
||||
PG_RETURN_INT64(pgstat_fetch_stat_checkpointer()->num_timed);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_bgwriter_requested_checkpoints(PG_FUNCTION_ARGS)
|
||||
pg_stat_get_checkpointer_num_requested(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_INT64(pgstat_fetch_stat_checkpointer()->requested_checkpoints);
|
||||
PG_RETURN_INT64(pgstat_fetch_stat_checkpointer()->num_requested);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_bgwriter_buf_written_checkpoints(PG_FUNCTION_ARGS)
|
||||
pg_stat_get_checkpointer_buffers_written(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_INT64(pgstat_fetch_stat_checkpointer()->buf_written_checkpoints);
|
||||
PG_RETURN_INT64(pgstat_fetch_stat_checkpointer()->buffers_written);
|
||||
}
|
||||
|
||||
Datum
|
||||
@ -1212,19 +1212,25 @@ pg_stat_get_bgwriter_maxwritten_clean(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_checkpoint_write_time(PG_FUNCTION_ARGS)
|
||||
pg_stat_get_checkpointer_write_time(PG_FUNCTION_ARGS)
|
||||
{
|
||||
/* time is already in msec, just convert to double for presentation */
|
||||
PG_RETURN_FLOAT8((double)
|
||||
pgstat_fetch_stat_checkpointer()->checkpoint_write_time);
|
||||
pgstat_fetch_stat_checkpointer()->write_time);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_checkpoint_sync_time(PG_FUNCTION_ARGS)
|
||||
pg_stat_get_checkpointer_sync_time(PG_FUNCTION_ARGS)
|
||||
{
|
||||
/* time is already in msec, just convert to double for presentation */
|
||||
PG_RETURN_FLOAT8((double)
|
||||
pgstat_fetch_stat_checkpointer()->checkpoint_sync_time);
|
||||
pgstat_fetch_stat_checkpointer()->sync_time);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_checkpointer_stat_reset_time(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_TIMESTAMPTZ(pgstat_fetch_stat_checkpointer()->stat_reset_timestamp);
|
||||
}
|
||||
|
||||
Datum
|
||||
@ -1684,14 +1690,9 @@ pg_stat_reset_shared(PG_FUNCTION_ARGS)
|
||||
if (strcmp(target, "archiver") == 0)
|
||||
pgstat_reset_of_kind(PGSTAT_KIND_ARCHIVER);
|
||||
else if (strcmp(target, "bgwriter") == 0)
|
||||
{
|
||||
/*
|
||||
* Historically checkpointer was part of bgwriter, continue to reset
|
||||
* both for now.
|
||||
*/
|
||||
pgstat_reset_of_kind(PGSTAT_KIND_BGWRITER);
|
||||
else if (strcmp(target, "checkpointer") == 0)
|
||||
pgstat_reset_of_kind(PGSTAT_KIND_CHECKPOINTER);
|
||||
}
|
||||
else if (strcmp(target, "io") == 0)
|
||||
pgstat_reset_of_kind(PGSTAT_KIND_IO);
|
||||
else if (strcmp(target, "recovery_prefetch") == 0)
|
||||
@ -1702,7 +1703,7 @@ pg_stat_reset_shared(PG_FUNCTION_ARGS)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("unrecognized reset target: \"%s\"", target),
|
||||
errhint("Target must be \"archiver\", \"bgwriter\", \"io\", \"recovery_prefetch\", or \"wal\".")));
|
||||
errhint("Target must be \"archiver\", \"bgwriter\", \"checkpointer\", \"io\", \"recovery_prefetch\", or \"wal\".")));
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
Reference in New Issue
Block a user