From 54145d59f021ad619d0bd36fb3b3cffa8f3b3688 Mon Sep 17 00:00:00 2001 From: Loyal-Young <266632325+Loyal-Young@users.noreply.github.com> Date: Thu, 12 Nov 2026 23:21:52 +0800 Subject: [PATCH] docs: update background writer and checkpoint monitoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Align the master monitoring guide with the actual background writer statistics view. Add examples for checkpoint counters in pg_stat_checkpointer and client backend writes in pg_stat_io. Assisted-by: Codex:GPT-6 Percentage of AI-generated code: 100% Signed-off-by: 王泽浩 <266632325+Loyal-Young@users.noreply.github.com> --- .../getting-started/daily_monitoring.adoc | 31 ++++++++++++++----- .../getting-started/daily_monitoring.adoc | 31 ++++++++++++++----- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/CN/modules/ROOT/pages/master/getting-started/daily_monitoring.adoc b/CN/modules/ROOT/pages/master/getting-started/daily_monitoring.adoc index 2ff69046..a69ea37a 100644 --- a/CN/modules/ROOT/pages/master/getting-started/daily_monitoring.adoc +++ b/CN/modules/ROOT/pages/master/getting-started/daily_monitoring.adoc @@ -107,6 +107,8 @@ IvorySQL也支持报告有关系统正在干什么的 动态信息,例如当 |视图名称 | 描述 | `pg_stat_archiver` | 只有一行,显示有关 WAL 归档进程活动的统计信息。 | `pg_stat_bgwriter` | 只有一行,显示有关后台写进程的活动的统计信息。 +| `pg_stat_checkpointer` | 只有一行,显示检查点和重启点的活动。 +| `pg_stat_io` | 按后端类型、目标对象和上下文分组显示 I/O 统计信息。 | `pg_stat_database` | 每个数据库一行,显示数据库范围的统计信息。 | `pg_stat_database_conflicts` | 每个数据库一行,显示数据库范围的统计信息, 这些信息的内容是关于由于与后备服务器的恢复过程 发生冲突而被取消的查询。 | `pg_stat_all_tables` | 当前数据库中每个表一行,显示有关访问指定表的统计信息。 @@ -594,19 +596,34 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i **表20.`pg_stat_bgwriter` 视图** |==== | 列 | 类型 | 描述 -| `checkpoints_timed` | `bigint` | 已执行的预定检查点数 -| `checkpoints_req` | `bigint` | 请求已执行的检查点数 -| `checkpoint_write_time` | `double precision` | 检查点处理中将文件写入磁盘的部分所花费的总时间,以毫秒为单位 -| `checkpoint_sync_time` | `double precision` | 检查点处理中将文件同步到磁盘的部分所花费的总时间,以毫秒为单位 -| `buffers_checkpoint` | `bigint` | 检查点期间写入的缓冲区数 | `buffers_clean` | `bigint` | 后台写入器写入的缓冲区数 | `maxwritten_clean` | `bigint` | 后台写入器因为写入太多缓冲区而停止清理扫描的次数 -| `buffers_backend` | `bigint` | 后端直接写入的缓冲区数 -| `buffers_backend_fsync` | `bigint` | 后端必须执行自己的 `fsync` 调用的次数(通常后台写入器处理这些,即使后端执行自己的写入) | `buffers_alloc` | `bigint` | 分配的缓冲区数 | `stats_reset` | `timestamp with time zone` | 这些统计数据最后一次重置的时间 |==== +==== `pg_stat_checkpointer` + +通过此视图查看定时、请求和已完成的检查点以及相关 I/O。视图也包含重启点计数。写入和同步时间以毫秒计。 + +[source,sql] +---- +SELECT num_timed, num_requested, num_done, buffers_written, + write_time, sync_time, stats_reset +FROM pg_stat_checkpointer; +---- + +==== `pg_stat_io` + +通过此视图查看后端写入和同步调用。查询时保留 `object` 和 `context`,以区分 I/O 的目标对象与上下文。 + +[source,sql] +---- +SELECT backend_type, object, context, writes, write_bytes, fsyncs +FROM pg_stat_io +WHERE backend_type = 'client backend'; +---- + ==== `pg_stat_database` `pg_stat_database`视图将包含一行用于集群中的每个数据库,加一行用于共享对象,显示数据库范围的统计信息。 diff --git a/EN/modules/ROOT/pages/master/getting-started/daily_monitoring.adoc b/EN/modules/ROOT/pages/master/getting-started/daily_monitoring.adoc index 789859c1..618ba506 100644 --- a/EN/modules/ROOT/pages/master/getting-started/daily_monitoring.adoc +++ b/EN/modules/ROOT/pages/master/getting-started/daily_monitoring.adoc @@ -112,6 +112,8 @@ Some of the information in the dynamic statistics views shown in Table 1 is sec | View Name | Description | `pg_stat_archiver` | One row only, showing statistics about the WAL archiver process's activity. See https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ARCHIVER-VIEW[`pg_stat_archiver`] for details. | `pg_stat_bgwriter` | One row only, showing statistics about the background writer process's activity. See https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-BGWRITER-VIEW[`pg_stat_bgwriter`] for details. +| `pg_stat_checkpointer` | One row showing checkpoint and restartpoint activity. +| `pg_stat_io` | I/O statistics grouped by backend type, target object and context. | `pg_stat_wal` | One row only, showing statistics about WAL activity. See https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-WAL-VIEW[`pg_stat_wal`] for details. | `pg_stat_database` | One row per database, showing database-wide statistics. See https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-DATABASE-VIEW[`pg_stat_database`] for details. | `pg_stat_database_conflicts` | One row per database, showing database-wide statistics about query cancels due to conflict with recovery on standby servers. See https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-DATABASE-CONFLICTS-VIEW[`pg_stat_database_conflicts`] for details. @@ -675,19 +677,34 @@ The `pg_stat_bgwriter` view will always have a single row, containing global dat .**`pg_stat_bgwriter` View** |==== | Column | Type | Description -| `checkpoints_timed` | `bigint` | Number of scheduled checkpoints that have been performed -| `checkpoints_req` | `bigint` | Number of requested checkpoints that have been performed -| `checkpoint_write_time` | `double precision` | Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk, in milliseconds -| `checkpoint_sync_time` | `double precision` | Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk, in milliseconds -| `buffers_checkpoint` | `bigint` | Number of buffers written during checkpoints | `buffers_clean` | `bigint` | Number of buffers written by the background writer | `maxwritten_clean` | `bigint` | Number of times the background writer stopped a cleaning scan because it had written too many buffers -| `buffers_backend` | `bigint` | Number of buffers written directly by a backend -| `buffers_backend_fsync` | `bigint` | Number of times a backend had to execute its own `fsync` call (normally the background writer handles those even when the backend does its own write) | `buffers_alloc` | `bigint` | Number of buffers allocated | `stats_reset` | `timestamp with time zone` | Time at which these statistics were last reset |==== +==== `pg_stat_checkpointer` + +Use this view for scheduled and requested checkpoints, completed checkpoints, and checkpoint I/O. The view also includes restartpoint counters. Write and synchronization times are measured in milliseconds. + +[source,sql] +---- +SELECT num_timed, num_requested, num_done, buffers_written, + write_time, sync_time, stats_reset +FROM pg_stat_checkpointer; +---- + +==== `pg_stat_io` + +Use this view to inspect writes and synchronization calls made by backends. Keep `object` and `context` in the result to distinguish the type of I/O. + +[source,sql] +---- +SELECT backend_type, object, context, writes, write_bytes, fsyncs +FROM pg_stat_io +WHERE backend_type = 'client backend'; +---- + ==== `pg_stat_wal` The `pg_stat_wal` view will always have a single row, containing data about WAL activity of the cluster.