跳转到主要内容
← 目录图谱 / pg_stat_replication

STATISTICS VIEW · 统计视图

pg_stat_replication

The pg_stat_replication view will contain one row per WAL sender process, showing statistics about replication to that sender's connected standby server. Only directly connected standbys are listed; no information is available about downstream standby servers. The lag times reported in the pg_stat_replication view are measurements of the time taken for recent WAL to be written, flushed and replayed and for the sender to know about it. These times represent the commit delay that was (or would have been) introduced by each synchronous commit level, if the remote server was configured as a synchronous standby. For an asynchronous standby, the replay_lag column approximates the delay before recent transactions became visible to queries. If the standby server has entirely caught up with the sending server and there is no more WAL activity, the most recently measured lag times will continue to be displayed for a short time and then show NULL. Lag times work automatically for physical replication. Logical decoding plugins may optionally emit tracking messages; if they do not, the tracking mechanism will simply display NULL lag.

首次收录 PG 9.1最近收录 PG 19当前字段 20

已与 PostgreSQL 18.6 实例逐字段核对 · 原始实测记录 ↗

字段结构 PostgreSQL 18

pg_stat_replication
字段 / COLUMN类型 / TYPE说明 / DESCRIPTION
pid integer Process ID of a WAL sender process
usesysid oid OID of the user logged into this WAL sender process
usename name Name of the user logged into this WAL sender process
application_name text Name of the application that is connected to this WAL sender
client_addr inet IP address of the client connected to this WAL sender. If this field is null, it indicates that the client is connected via a Unix socket on the server machine.
client_hostname text Host name of the connected client, as reported by a reverse DNS lookup of client_addr. This field will only be non-null for IP connections, and only when log_hostname is enabled.
client_port integer TCP port number that the client is using for communication with this WAL sender, or -1 if a Unix socket is used
backend_start timestamp with time zone Time when this process was started, i.e., when the client connected to this WAL sender
backend_xmin xid This standby's xmin horizon reported by hot_standby_feedback.
state text Current WAL sender state. Possible values are:
sent_lsn pg_lsn Last write-ahead log location sent on this connection
write_lsn pg_lsn Last write-ahead log location written to disk by this standby server
flush_lsn pg_lsn Last write-ahead log location flushed to disk by this standby server
replay_lsn pg_lsn Last write-ahead log location replayed into the database on this standby server
write_lag interval Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written it (but not yet flushed it or applied it). This can be used to gauge the delay that synchronous_commit level remote_write incurred while committing if this server was configured as a synchronous standby.
flush_lag interval Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written and flushed it (but not yet applied it). This can be used to gauge the delay that synchronous_commit level on incurred while committing if this server was configured as a synchronous standby.
replay_lag interval Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written, flushed and applied it. This can be used to gauge the delay that synchronous_commit level remote_apply incurred while committing if this server was configured as a synchronous standby.
sync_priority integer Priority of this standby server for being chosen as the synchronous standby in a priority-based synchronous replication. This has no effect in a quorum-based synchronous replication.
sync_state text Synchronous state of this standby server. Possible values are:
reply_time timestamp with time zone Send time of last reply message received from standby server

标记“隐式列”的字段不包含在 SELECT * 中;部分早期统计视图由同版本源码补全,额外来源会显示在字段说明中。

字段演化矩阵

悬停查看字段类型
存在新增 / 类型或属性变化移除
字段 / COLUMN9.09.19.29.39.49.59.610111213141516171819
procpid
usesysid
usename
application_name
client_addr
client_hostname
client_port
backend_start
state
sent_location
write_location
flush_location
replay_location
sync_priority
sync_state
pid
backend_xmin
sent_lsn
write_lsn
flush_lsn
replay_lsn
write_lag
flush_lag
replay_lag
reply_time

9.0 是收录基线;基线中已存在的字段不标记为新增。矩阵按字段名称对齐,重命名显示为旧字段移除与新字段新增。

演化时间线

相邻大版本的变化

PostgreSQL 19 ← 18

1 处字段说明更新

PostgreSQL 13 ← 12

2 处字段说明更新目录说明更新

PostgreSQL 12 ← 11

+ reply_time目录说明更新

PostgreSQL 10 ← 9.6

+ sent_lsn+ write_lsn+ flush_lsn+ replay_lsn+ write_lag+ flush_lag+ replay_lag− sent_location− write_location− flush_location− replay_location3 处字段说明更新目录说明更新

PostgreSQL 9.6 ← 9.5

目录说明更新

PostgreSQL 9.5 ← 9.4

目录说明更新

PostgreSQL 9.4 ← 9.3

+ backend_xmin~ flush_location: text → pg_lsn~ replay_location: text → pg_lsn~ sent_location: text → pg_lsn~ write_location: text → pg_lsn目录说明更新

PostgreSQL 9.2 ← 9.1

+ pid− procpid1 处字段说明更新目录说明更新

PostgreSQL 9.1 ← 9.0新增目录

+ procpid+ usesysid+ usename+ application_name+ client_addr+ client_hostname+ client_port+ backend_start+ state+ sent_location+ write_location+ flush_location+ replay_location+ sync_priority+ sync_state

比较任意两个版本

选择两个版本,查看字段的新增、移除与类型变化。交互比较需要 JavaScript;演化时间线可直接阅读。