Re: Introduce a new view for checkpointer related stats

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Introduce a new view for checkpointer related stats
Date: 2022-11-30 11:45:08
Message-ID: CALj2ACV-s5gzuCpt7uXkRJkFhcGPKrv8eZqKOaEmsRFLCXqVoQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 30, 2022 at 12:44 PM Drouvot, Bertrand
<bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
>
> +CREATE VIEW pg_stat_checkpointer AS
> + SELECT
> + pg_stat_get_timed_checkpoints() AS checkpoints_timed,
> + pg_stat_get_requested_checkpoints() AS checkpoints_req,
> + pg_stat_get_checkpoint_write_time() AS checkpoint_write_time,
> + pg_stat_get_checkpoint_sync_time() AS checkpoint_sync_time,
> + pg_stat_get_buf_written_checkpoints() AS buffers_checkpoint,
> + pg_stat_get_buf_written_backend() AS buffers_backend,
> + pg_stat_get_buf_fsync_backend() AS buffers_backend_fsync,
> + pg_stat_get_checkpointer_stat_reset_time() AS stats_reset;
> +
>
> I still think that having checkpoints_ prefix in a pg_stat_checkpointer view sounds "weird" (made sense when they were part of pg_stat_bgwriter)
>
> maybe we could have something like this instead?
>
> +CREATE VIEW pg_stat_checkpointer AS
> + SELECT
> + pg_stat_get_timed_checkpoints() AS num_timed,
> + pg_stat_get_requested_checkpoints() AS num_req,
> + pg_stat_get_checkpoint_write_time() AS total_write_time,
> + pg_stat_get_checkpoint_sync_time() AS total_sync_time,
> + pg_stat_get_buf_written_checkpoints() AS buffers_checkpoint,
> + pg_stat_get_buf_written_backend() AS buffers_backend,
> + pg_stat_get_buf_fsync_backend() AS buffers_backend_fsync,
> + pg_stat_get_checkpointer_stat_reset_time() AS stats_reset;
> +

I don't have a strong opinion about changing column names. However, if
we were to change it, I prefer to use names that
PgStat_CheckpointerStats has. BTW, that's what
PgStat_BgWriterStats/pg_stat_bgwriter and
PgStat_ArchiverStats/pg_stat_archiver uses.
typedef struct PgStat_CheckpointerStats
{
PgStat_Counter timed_checkpoints;
PgStat_Counter requested_checkpoints;
PgStat_Counter checkpoint_write_time; /* times in milliseconds */
PgStat_Counter checkpoint_sync_time;
PgStat_Counter buf_written_checkpoints;
PgStat_Counter buf_written_backend;
PgStat_Counter buf_fsync_backend;
TimestampTz stat_reset_timestamp;
} PgStat_CheckpointerStats;

> That's a nit in any case and the patch LGTM.

Thanks.

--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2022-11-30 11:57:10 Re: O(n) tasks cause lengthy startups and checkpoints
Previous Message Hayato Kuroda (Fujitsu) 2022-11-30 11:35:58 RE: Perform streaming logical transactions by background workers and parallel apply