pg_stat_activity 视图pg_stat_replication 视图pg_stat_replication_slots 视图pg_stat_wal_receiver 视图pg_stat_recovery_prefetch 视图pg_stat_subscription 视图pg_stat_subscription_stats 视图pg_stat_ssl 视图pg_stat_gssapi 视图pg_stat_archiver 视图pg_stat_io 视图pg_stat_bgwriter 视图pg_stat_checkpointer 视图pg_stat_wal 视图pg_stat_database 视图pg_stat_database_conflicts 视图pg_stat_all_tables 视图pg_stat_all_indexes 视图pg_statio_all_tables 视图pg_statio_all_indexes 视图pg_statio_all_sequences 视图pg_stat_user_functions 视图pg_stat_slru 视图PostgreSQL 内置了高性能的累积统计收集系统,能够记录对数据表的访问频次、磁盘 I/O 读写块数、WAL 生成量以及会话连接事件。
统计数据的采集开销极其低廉,默认全部自动开启(包括 track_activities、track_counts 与 track_io_timing)。
系统提供了两组核心内置视图:动态视图与累积统计视图。
Table 27.1. 动态统计视图
| 视图名称 | 说明 |
|---|---|
pg_stat_activity | 每个活跃客户端会话的当前执行状态 |
pg_stat_replication | 流复制连接的发送状态 |
pg_stat_wal_receiver | 流复制接收端工作进程状态 |
Table 27.2. 累积统计视图
| 视图名称 | 说明 |
|---|---|
pg_stat_database | 数据库级别的全局聚合度量 |
pg_stat_all_tables | 表级别访问与元组增删改统计 |
pg_stat_all_indexes | 索引使用频次与检索效率统计 |
pg_statio_all_tables | 表级别磁盘读取与缓冲命中统计 |
pg_stat_io | 全集群细粒度物理 I/O 统计 |
pg_stat_wal | WAL 写入与磁盘刷盘统计 |
pg_stat_activity 视图 #显示每个后台连接进程的当前活动、正在执行的 SQL 语句文本、事务启动时间以及锁等待事件。
Table 27.3. pg_stat_activity 视图字段
| 字段名 | 说明 |
|---|---|
pid | 后台进程 ID |
state | 当前连接状态(active, idle 等) |
query | 当前正在执行的 SQL |
Table 27.4. 等待事件分类表
| 事件类型 | 说明 |
|---|---|
| Lock | 常规锁等待 |
| IO | 磁盘 I/O 读写等待 |
Table 27.5. Wait Events of Type Activity
Activity Wait Event | Description |
|---|---|
ArchiverMain | Waiting in main loop of archiver process. |
AutovacuumMain | Waiting in main loop of autovacuum launcher process. |
BgwriterHibernate | Waiting in background writer process, hibernating. |
BgwriterMain | Waiting in main loop of background writer process. |
CheckpointerMain | Waiting in main loop of checkpointer process. |
CheckpointerShutdown | Waiting for checkpointer process to be terminated. |
IoWorkerMain | Waiting in main loop of IO Worker process. |
LogicalApplyMain | Waiting in main loop of logical replication apply process. |
LogicalLauncherMain | Waiting in main loop of logical replication launcher process. |
LogicalParallelApplyMain | Waiting in main loop of logical replication parallel apply process. |
RecoveryWalStream | Waiting in main loop of startup process for WAL to arrive, during streaming recovery. |
ReplicationSlotsyncMain | Waiting in main loop of slot sync worker. |
ReplicationSlotsyncShutdown | Waiting for slot sync worker to shut down. |
SysloggerMain | Waiting in main loop of syslogger process. |
WalReceiverMain | Waiting in main loop of WAL receiver process. |
WalSenderMain | Waiting in main loop of WAL sender process. |
WalSummarizerWal | Waiting in WAL summarizer for more WAL to be generated. |
WalWriterMain | Waiting in main loop of WAL writer process. |
Table 27.6. Wait Events of Type Bufferpin
BufferPin Wait Event | Description |
|---|---|
BufferPin | Waiting to acquire an exclusive pin on a buffer. |
Table 27.7. Wait Events of Type Client
Client Wait Event | Description |
|---|---|
ClientRead | Waiting to read data from the client. |
ClientWrite | Waiting to write data to the client. |
GssOpenServer | Waiting to read data from the client while establishing a GSSAPI session. |
LibpqwalreceiverConnect | Waiting in WAL receiver to establish connection to remote server. |
LibpqwalreceiverReceive | Waiting in WAL receiver to receive data from remote server. |
SslOpenServer | Waiting for SSL while attempting connection. |
WaitForStandbyConfirmation | Waiting for WAL to be received and flushed by the physical standby. |
WalSenderWaitForWal | Waiting for WAL to be flushed in WAL sender process. |
WalSenderWriteData | Waiting for any activity when processing replies from WAL receiver in WAL sender process. |
Table 27.8. Wait Events of Type Extension
Extension Wait Event | Description |
|---|---|
Extension | Waiting in an extension. |
Table 27.9. Wait Events of Type Io
IO Wait Event | Description |
|---|---|
AioIoCompletion | Waiting for another process to complete IO. |
AioIoUringExecution | Waiting for IO execution via io_uring. |
AioIoUringSubmit | Waiting for IO submission via io_uring. |
BasebackupRead | Waiting for base backup to read from a file. |
BasebackupSync | Waiting for data written by a base backup to reach durable storage. |
BasebackupWrite | Waiting for base backup to write to a file. |
BuffileRead | Waiting for a read from a buffered file. |
BuffileTruncate | Waiting for a buffered file to be truncated. |
BuffileWrite | Waiting for a write to a buffered file. |
ControlFileRead | Waiting for a read from the pg_control file. |
ControlFileSync | Waiting for the pg_control file to reach durable storage. |
ControlFileSyncUpdate | Waiting for an update to the pg_control file to reach durable storage. |
ControlFileWrite | Waiting for a write to the pg_control file. |
ControlFileWriteUpdate | Waiting for a write to update the pg_control file. |
CopyFileCopy | Waiting for a file copy operation. |
CopyFileRead | Waiting for a read during a file copy operation. |
CopyFileWrite | Waiting for a write during a file copy operation. |
DataFileExtend | Waiting for a relation data file to be extended. |
DataFileFlush | Waiting for a relation data file to reach durable storage. |
DataFileImmediateSync | Waiting for an immediate synchronization of a relation data file to durable storage. |
DataFilePrefetch | Waiting for an asynchronous prefetch from a relation data file. |
DataFileRead | Waiting for a read from a relation data file. |
DataFileSync | Waiting for changes to a relation data file to reach durable storage. |
DataFileTruncate | Waiting for a relation data file to be truncated. |
DataFileWrite | Waiting for a write to a relation data file. |
DsmAllocate | Waiting for a dynamic shared memory segment to be allocated. |
DsmFillZeroWrite | Waiting to fill a dynamic shared memory backing file with zeroes. |
LockFileAddtodatadirRead | Waiting for a read while adding a line to the data directory lock file. |
LockFileAddtodatadirSync | Waiting for data to reach durable storage while adding a line to the data directory lock file. |
LockFileAddtodatadirWrite | Waiting for a write while adding a line to the data directory lock file. |
LockFileCreateRead | Waiting to read while creating the data directory lock file. |
LockFileCreateSync | Waiting for data to reach durable storage while creating the data directory lock file. |
LockFileCreateWrite | Waiting for a write while creating the data directory lock file. |
LockFileRecheckdatadirRead | Waiting for a read during recheck of the data directory lock file. |
LogicalRewriteCheckpointSync | Waiting for logical rewrite mappings to reach durable storage during a checkpoint. |
LogicalRewriteMappingSync | Waiting for mapping data to reach durable storage during a logical rewrite. |
LogicalRewriteMappingWrite | Waiting for a write of mapping data during a logical rewrite. |
LogicalRewriteSync | Waiting for logical rewrite mappings to reach durable storage. |
LogicalRewriteTruncate | Waiting for truncate of mapping data during a logical rewrite. |
LogicalRewriteWrite | Waiting for a write of logical rewrite mappings. |
RelationMapRead | Waiting for a read of the relation map file. |
RelationMapReplace | Waiting for durable replacement of a relation map file. |
RelationMapWrite | Waiting for a write to the relation map file. |
ReorderBufferRead | Waiting for a read during reorder buffer management. |
ReorderBufferWrite | Waiting for a write during reorder buffer management. |
ReorderLogicalMappingRead | Waiting for a read of a logical mapping during reorder buffer management. |
ReplicationSlotRead | Waiting for a read from a replication slot control file. |
ReplicationSlotRestoreSync | Waiting for a replication slot control file to reach durable storage while restoring it to memory. |
ReplicationSlotSync | Waiting for a replication slot control file to reach durable storage. |
ReplicationSlotWrite | Waiting for a write to a replication slot control file. |
SlruFlushSync | Waiting for SLRU data to reach durable storage during a checkpoint or database shutdown. |
SlruRead | Waiting for a read of an SLRU page. |
SlruSync | Waiting for SLRU data to reach durable storage following a page write. |
SlruWrite | Waiting for a write of an SLRU page. |
SnapbuildRead | Waiting for a read of a serialized historical catalog snapshot. |
SnapbuildSync | Waiting for a serialized historical catalog snapshot to reach durable storage. |
SnapbuildWrite | Waiting for a write of a serialized historical catalog snapshot. |
TimelineHistoryFileSync | Waiting for a timeline history file received via streaming replication to reach durable storage. |
TimelineHistoryFileWrite | Waiting for a write of a timeline history file received via streaming replication. |
TimelineHistoryRead | Waiting for a read of a timeline history file. |
TimelineHistorySync | Waiting for a newly created timeline history file to reach durable storage. |
TimelineHistoryWrite | Waiting for a write of a newly created timeline history file. |
TwophaseFileRead | Waiting for a read of a two phase state file. |
TwophaseFileSync | Waiting for a two phase state file to reach durable storage. |
TwophaseFileWrite | Waiting for a write of a two phase state file. |
VersionFileSync | Waiting for the version file to reach durable storage while creating a database. |
VersionFileWrite | Waiting for the version file to be written while creating a database. |
WalsenderTimelineHistoryRead | Waiting for a read from a timeline history file during a walsender timeline command. |
WalBootstrapSync | Waiting for WAL to reach durable storage during bootstrapping. |
WalBootstrapWrite | Waiting for a write of a WAL page during bootstrapping. |
WalCopyRead | Waiting for a read when creating a new WAL segment by copying an existing one. |
WalCopySync | Waiting for a new WAL segment created by copying an existing one to reach durable storage. |
WalCopyWrite | Waiting for a write when creating a new WAL segment by copying an existing one. |
WalInitSync | Waiting for a newly initialized WAL file to reach durable storage. |
WalInitWrite | Waiting for a write while initializing a new WAL file. |
WalRead | Waiting for a read from a WAL file. |
WalSummaryRead | Waiting for a read from a WAL summary file. |
WalSummaryWrite | Waiting for a write to a WAL summary file. |
WalSync | Waiting for a WAL file to reach durable storage. |
WalSyncMethodAssign | Waiting for data to reach durable storage while assigning a new WAL sync method. |
WalWrite | Waiting for a write to a WAL file. |
Table 27.10. Wait Events of Type Ipc
IPC Wait Event | Description |
|---|---|
AppendReady | Waiting for subplan nodes of an Append plan node to be ready. |
ArchiveCleanupCommand | Waiting for archive_cleanup_command to complete. |
ArchiveCommand | Waiting for archive_command to complete. |
BackendTermination | Waiting for the termination of another backend. |
BackupWaitWalArchive | Waiting for WAL files required for a backup to be successfully archived. |
BgworkerShutdown | Waiting for background worker to shut down. |
BgworkerStartup | Waiting for background worker to start up. |
BtreePage | Waiting for the page number needed to continue a parallel B-tree scan to become available. |
BufferIo | Waiting for buffer I/O to complete. |
CheckpointDelayComplete | Waiting for a backend that blocks a checkpoint from completing. |
CheckpointDelayStart | Waiting for a backend that blocks a checkpoint from starting. |
CheckpointDone | Waiting for a checkpoint to complete. |
CheckpointStart | Waiting for a checkpoint to start. |
ExecuteGather | Waiting for activity from a child process while executing a Gather plan node. |
HashBatchAllocate | Waiting for an elected Parallel Hash participant to allocate a hash table. |
HashBatchElect | Waiting to elect a Parallel Hash participant to allocate a hash table. |
HashBatchLoad | Waiting for other Parallel Hash participants to finish loading a hash table. |
HashBuildAllocate | Waiting for an elected Parallel Hash participant to allocate the initial hash table. |
HashBuildElect | Waiting to elect a Parallel Hash participant to allocate the initial hash table. |
HashBuildHashInner | Waiting for other Parallel Hash participants to finish hashing the inner relation. |
HashBuildHashOuter | Waiting for other Parallel Hash participants to finish partitioning the outer relation. |
HashGrowBatchesDecide | Waiting to elect a Parallel Hash participant to decide on future batch growth. |
HashGrowBatchesElect | Waiting to elect a Parallel Hash participant to allocate more batches. |
HashGrowBatchesFinish | Waiting for an elected Parallel Hash participant to decide on future batch growth. |
HashGrowBatchesReallocate | Waiting for an elected Parallel Hash participant to allocate more batches. |
HashGrowBatchesRepartition | Waiting for other Parallel Hash participants to finish repartitioning. |
HashGrowBucketsElect | Waiting to elect a Parallel Hash participant to allocate more buckets. |
HashGrowBucketsReallocate | Waiting for an elected Parallel Hash participant to finish allocating more buckets. |
HashGrowBucketsReinsert | Waiting for other Parallel Hash participants to finish inserting tuples into new buckets. |
LogicalApplySendData | Waiting for a logical replication leader apply process to send data to a parallel apply process. |
LogicalParallelApplyStateChange | Waiting for a logical replication parallel apply process to change state. |
LogicalSyncData | Waiting for a logical replication remote server to send data for initial table synchronization. |
LogicalSyncStateChange | Waiting for a logical replication remote server to change state. |
MessageQueueInternal | Waiting for another process to be attached to a shared message queue. |
MessageQueuePutMessage | Waiting to write a protocol message to a shared message queue. |
MessageQueueReceive | Waiting to receive bytes from a shared message queue. |
MessageQueueSend | Waiting to send bytes to a shared message queue. |
MultixactCreation | Waiting for a multixact creation to complete. |
ParallelBitmapScan | Waiting for parallel bitmap scan to become initialized. |
ParallelCreateIndexScan | Waiting for parallel CREATE INDEX workers to finish heap scan. |
ParallelFinish | Waiting for parallel workers to finish computing. |
ProcarrayGroupUpdate | Waiting for the group leader to clear the transaction ID at transaction end. |
ProcSignalBarrier | Waiting for a barrier event to be processed by all backends. |
Promote | Waiting for standby promotion. |
RecoveryConflictSnapshot | Waiting for recovery conflict resolution for a vacuum cleanup. |
RecoveryConflictTablespace | Waiting for recovery conflict resolution for dropping a tablespace. |
RecoveryEndCommand | Waiting for recovery_end_command to complete. |
RecoveryPause | Waiting for recovery to be resumed. |
ReplicationOriginDrop | Waiting for a replication origin to become inactive so it can be dropped. |
ReplicationSlotDrop | Waiting for a replication slot to become inactive so it can be dropped. |
RestoreCommand | Waiting for restore_command to complete. |
SafeSnapshot | Waiting to obtain a valid snapshot for a READ ONLY DEFERRABLE transaction. |
SyncRep | Waiting for confirmation from a remote server during synchronous replication. |
WalReceiverExit | Waiting for the WAL receiver to exit. |
WalReceiverUpstreamCatchup | Waiting for upstream server WAL flush position to catch up to requested start point. |
WalReceiverWaitStart | Waiting for startup process to send initial data for streaming replication. |
WalSummaryReady | Waiting for a new WAL summary to be generated. |
XactGroupUpdate | Waiting for the group leader to update transaction status at transaction end. |
Table 27.11. Wait Events of Type Lock
Lock Wait Event | Description |
|---|---|
advisory | Waiting to acquire an advisory user lock. |
applytransaction | Waiting to acquire a lock on a remote transaction being applied by a logical replication subscriber. |
extend | Waiting to extend a relation. |
frozenid | Waiting to update pg_database.datfrozenxid and pg_database.datminmxid. |
object | Waiting to acquire a lock on a non-relation database object. |
page | Waiting to acquire a lock on a page of a relation. |
relation | Waiting to acquire a lock on a relation. |
spectoken | Waiting to acquire a speculative insertion lock. |
transactionid | Waiting for a transaction to finish. |
tuple | Waiting to acquire a lock on a tuple. |
userlock | Waiting to acquire a user lock. |
virtualxid | Waiting to acquire a virtual transaction ID lock; see Section 67.1. |
Table 27.12. Wait Events of Type Lwlock
LWLock Wait Event | Description |
|---|---|
AddinShmemInit | Waiting to manage an extension's space allocation in shared memory. |
AioUringCompletion | Waiting for another process to complete IO via io_uring. |
AioWorkerSubmissionQueue | Waiting to access AIO worker submission queue. |
AutoFile | Waiting to update the postgresql.auto.conf file. |
Autovacuum | Waiting to read or update the current state of autovacuum workers. |
AutovacuumSchedule | Waiting to ensure that a table selected for autovacuum still needs vacuuming. |
BackgroundWorker | Waiting to read or update background worker state. |
BtreeVacuum | Waiting to read or update vacuum-related information for a B-tree index. |
BufferContent | Waiting to access a data page in memory. |
BufferMapping | Waiting to associate a data block with a buffer in the buffer pool. |
CheckpointerComm | Waiting to manage fsync requests. |
CommitTs | Waiting to read or update the last value set for a transaction commit timestamp. |
CommitTsBuffer | Waiting for I/O on a commit timestamp SLRU buffer. |
CommitTsSLRU | Waiting to access the commit timestamp SLRU cache. |
ControlFile | Waiting to read or update the pg_control file or create a new WAL file. |
DSMRegistry | Waiting to read or update the dynamic shared memory registry. |
DSMRegistryDSA | Waiting to access dynamic shared memory registry's dynamic shared memory allocator. |
DSMRegistryHash | Waiting to access dynamic shared memory registry's shared hash table. |
DynamicSharedMemoryControl | Waiting to read or update dynamic shared memory allocation information. |
InjectionPoint | Waiting to read or update information related to injection points. |
LockFastPath | Waiting to read or update a process' fast-path lock information. |
LockManager | Waiting to read or update information about “heavyweight” locks. |
LogicalRepLauncherDSA | Waiting to access logical replication launcher's dynamic shared memory allocator. |
LogicalRepLauncherHash | Waiting to access logical replication launcher's shared hash table. |
LogicalRepWorker | Waiting to read or update the state of logical replication workers. |
MultiXactGen | Waiting to read or update shared multixact state. |
MultiXactMemberBuffer | Waiting for I/O on a multixact member SLRU buffer. |
MultiXactMemberSLRU | Waiting to access the multixact member SLRU cache. |
MultiXactOffsetBuffer | Waiting for I/O on a multixact offset SLRU buffer. |
MultiXactOffsetSLRU | Waiting to access the multixact offset SLRU cache. |
MultiXactTruncation | Waiting to read or truncate multixact information. |
NotifyBuffer | Waiting for I/O on a NOTIFY message SLRU buffer. |
NotifyQueue | Waiting to read or update NOTIFY messages. |
NotifyQueueTail | Waiting to update limit on NOTIFY message storage. |
NotifySLRU | Waiting to access the NOTIFY message SLRU cache. |
OidGen | Waiting to allocate a new OID. |
ParallelAppend | Waiting to choose the next subplan during Parallel Append plan execution. |
ParallelBtreeScan | Waiting to synchronize workers during Parallel B-tree scan plan execution. |
ParallelHashJoin | Waiting to synchronize workers during Parallel Hash Join plan execution. |
ParallelQueryDSA | Waiting for parallel query dynamic shared memory allocation. |
ParallelVacuumDSA | Waiting for parallel vacuum dynamic shared memory allocation. |
PerSessionDSA | Waiting for parallel query dynamic shared memory allocation. |
PerSessionRecordType | Waiting to access a parallel query's information about composite types. |
PerSessionRecordTypmod | Waiting to access a parallel query's information about type modifiers that identify anonymous record types. |
PerXactPredicateList | Waiting to access the list of predicate locks held by the current serializable transaction during a parallel query. |
PgStatsData | Waiting for shared memory stats data access. |
PgStatsDSA | Waiting for stats dynamic shared memory allocator access. |
PgStatsHash | Waiting for stats shared memory hash table access. |
PredicateLockManager | Waiting to access predicate lock information used by serializable transactions. |
ProcArray | Waiting to access the shared per-process data structures (typically, to get a snapshot or report a session's transaction ID). |
RelationMapping | Waiting to read or update a pg_filenode.map file (used to track the filenode assignments of certain system catalogs). |
RelCacheInit | Waiting to read or update a pg_internal.init relation cache initialization file. |
ReplicationOrigin | Waiting to create, drop or use a replication origin. |
ReplicationOriginState | Waiting to read or update the progress of one replication origin. |
ReplicationSlotAllocation | Waiting to allocate or free a replication slot. |
ReplicationSlotControl | Waiting to read or update replication slot state. |
ReplicationSlotIO | Waiting for I/O on a replication slot. |
SerialBuffer | Waiting for I/O on a serializable transaction conflict SLRU buffer. |
SerialControl | Waiting to read or update shared pg_serial state. |
SerializableFinishedList | Waiting to access the list of finished serializable transactions. |
SerializablePredicateList | Waiting to access the list of predicate locks held by serializable transactions. |
SerializableXactHash | Waiting to read or update information about serializable transactions. |
SerialSLRU | Waiting to access the serializable transaction conflict SLRU cache. |
SharedTidBitmap | Waiting to access a shared TID bitmap during a parallel bitmap index scan. |
SharedTupleStore | Waiting to access a shared tuple store during parallel query. |
ShmemIndex | Waiting to find or allocate space in shared memory. |
SInvalRead | Waiting to retrieve messages from the shared catalog invalidation queue. |
SInvalWrite | Waiting to add a message to the shared catalog invalidation queue. |
SubtransBuffer | Waiting for I/O on a sub-transaction SLRU buffer. |
SubtransSLRU | Waiting to access the sub-transaction SLRU cache. |
SyncRep | Waiting to read or update information about the state of synchronous replication. |
SyncScan | Waiting to select the starting location of a synchronized table scan. |
TablespaceCreate | Waiting to create or drop a tablespace. |
TwoPhaseState | Waiting to read or update the state of prepared transactions. |
WaitEventCustom | Waiting to read or update custom wait events information. |
WALBufMapping | Waiting to replace a page in WAL buffers. |
WALInsert | Waiting to insert WAL data into a memory buffer. |
WALSummarizer | Waiting to read or update WAL summarization state. |
WALWrite | Waiting for WAL buffers to be written to disk. |
WrapLimitsVacuum | Waiting to update limits on transaction id and multixact consumption. |
XactBuffer | Waiting for I/O on a transaction status SLRU buffer. |
XactSLRU | Waiting to access the transaction status SLRU cache. |
XactTruncation | Waiting to execute pg_xact_status or update the oldest transaction ID available to it. |
XidGen | Waiting to allocate a new transaction ID. |
Table 27.13. Wait Events of Type Timeout
Timeout Wait Event | Description |
|---|---|
BaseBackupThrottle | Waiting during base backup when throttling activity. |
CheckpointWriteDelay | Waiting between writes while performing a checkpoint. |
PgSleep | Waiting due to a call to pg_sleep or a sibling function. |
RecoveryApplyDelay | Waiting to apply WAL during recovery because of a delay setting. |
RecoveryRetrieveRetryInterval | Waiting during recovery when WAL data is not available from any source (pg_wal, archive or stream). |
RegisterSyncRequest | Waiting while sending synchronization requests to the checkpointer, because the request queue is full. |
SpinDelay | Waiting while acquiring a contended spinlock. |
VacuumDelay | Waiting in a cost-based vacuum delay point. |
VacuumTruncate | Waiting to acquire an exclusive lock to truncate off any empty pages at the end of a table vacuumed. |
WalSummarizerError | Waiting after a WAL summarizer error. |
pg_stat_replication 视图 #显示主节点上正在向备节点流式发送 WAL 的 walsender 进程状态。
Table 27.14. pg_stat_replication 字段
| 字段 | 说明 |
|---|---|
client_addr | 备库 IP 地址 |
replay_lsn | 备库最新回放位点 |
pg_stat_replication_slots 视图 #提供关于逻辑与物理复制槽的数据处理度量统计。
Table 27.15. pg_stat_replication_slots 字段
| 字段 | 说明 |
|---|---|
slot_name | 复制槽名称 |
spill_bytes | 解码溢出到磁盘的字节数 |
pg_stat_wal_receiver 视图 #在备库上显示正在接收 WAL 流的 walreceiver 工作进程实时状态。
Table 27.16. pg_stat_wal_receiver 字段
| 字段 | 说明 |
|---|---|
status | 接收器运行状态 |
pg_stat_recovery_prefetch 视图 #显示备库或故障恢复期间预读磁盘块的命中统计。
Table 27.17. pg_stat_recovery_prefetch 字段
| 字段 | 说明 |
|---|---|
prefetch | 预读页面计数 |
pg_stat_subscription 视图 #显示订阅端上逻辑复制各个订阅工作进程的实时连接状态。
Table 27.18. pg_stat_subscription 字段
| 字段 | 说明 |
|---|---|
subname | 订阅名称 |
pg_stat_subscription_stats 视图 #提供逻辑复制订阅的累积失败与冲突度量统计。
Table 27.19. pg_stat_subscription_stats 字段
| 字段 | 说明 |
|---|---|
confl_count | 写入冲突计数 |
pg_stat_ssl 视图 #显示当前每个客户端会话的 SSL/TLS 连接加密详情(加密算法、协议版本等)。
Table 27.20. pg_stat_ssl 字段
| 字段 | 说明 |
|---|---|
ssl | 是否启用 SSL |
pg_stat_gssapi 视图 #显示当前客户端连接的 GSSAPI 身份认证与加密状态。
Table 27.21. pg_stat_gssapi 字段
| 字段 | 说明 |
|---|---|
gss_authenticated | 是否通过 GSSAPI 认证 |
pg_stat_archiver 视图 #显示 WAL 归档进程的成功与失败计数及最近归档时间。
Table 27.22. pg_stat_archiver 字段
| 字段 | 说明 |
|---|---|
archived_count | 成功归档段数 |
pg_stat_io 视图 #提供整个集群按照后台进程类型、上下文目标与 I/O 操作类型划分的细粒度读写读写统计。
Table 27.23. pg_stat_io 字段
| 字段 | 说明 |
|---|---|
backend_type | 后台进程类别 |
reads | 物理读页面数 |
pg_stat_bgwriter 视图 #显示后台写进程(bgwriter)的物理页面刷盘清理统计。
Table 27.24. pg_stat_bgwriter 字段
| 字段 | 说明 |
|---|---|
buffers_clean | 清理写出的缓冲区页数 |
pg_stat_checkpointer 视图 #显示检查点工作进程的执行频次、触发原因及刷盘耗时。
Table 27.25. pg_stat_checkpointer 字段
| 字段 | 说明 |
|---|---|
num_timed | 定时检查点次数 |
pg_stat_wal 视图 #显示预写式日志(WAL)的生成总量、写入与 fsync 刷盘开销。
Table 27.26. pg_stat_wal 字段
| 字段 | 说明 |
|---|---|
wal_records | 生成的 WAL 记录数 |
pg_stat_database 视图 #显示数据库级别的整体聚合度量(事务提交数、回滚数、死锁数、冲突数等)。
Table 27.27. pg_stat_database 字段
| 字段 | 说明 |
|---|---|
xact_commit | 提交事务总数 |
pg_stat_database_conflicts 视图 #显示热备节点上由不同原因导致的查询取消冲突统计。
Table 27.28. pg_stat_database_conflicts 字段
| 字段 | 说明 |
|---|---|
confl_lock | 锁冲突取消计数 |
pg_stat_all_tables 视图 #显示各数据表的顺序扫描次数、行读取数、存活与死元组数以及上次自动清理时间。
Table 27.29. pg_stat_all_tables 字段
| 字段 | 说明 |
|---|---|
n_dead_tup | 死元组估计数量 |
pg_stat_all_indexes 视图 #显示各索引的扫描次数、抓取元组数及效率。
Table 27.30. pg_stat_all_indexes 字段
| 字段 | 说明 |
|---|---|
idx_scan | 索引扫描次数 |
pg_statio_all_tables 视图 #显示表数据块的真实物理磁盘读取数与共享内存缓冲区命中数。
Table 27.31. pg_statio_all_tables 字段
| 字段 | 说明 |
|---|---|
heap_blks_hit | 内存命中块数 |
pg_statio_all_indexes 视图 #显示索引数据块的磁盘读取与内存命中统计。
Table 27.32. pg_statio_all_indexes 字段
| 字段 | 说明 |
|---|---|
idx_blks_hit | 索引内存命中块数 |
pg_statio_all_sequences 视图 #显示序列对象的 I/O 读写与缓存命中统计。
Table 27.33. pg_statio_all_sequences 字段
| 字段 | 说明 |
|---|---|
blks_hit | 序列内存命中块数 |
pg_stat_user_functions 视图 #显示用户自定义函数的执行次数、单次调用总耗时与自身耗时。
Table 27.34. pg_stat_user_functions 字段
| 字段 | 说明 |
|---|---|
calls | 调用总次数 |
pg_stat_slru 视图 #显示简单近期最少使用(SLRU)缓存的读写、命中与落盘统计。
Table 27.35. pg_stat_slru 字段
| 字段 | 说明 |
|---|---|
blks_hit | SLRU 命中块数 |
用于查询与重置统计收集器数据的内置函数。
Table 27.36. 常用统计查询函数
| 函数 | 说明 |
|---|---|
pg_stat_reset() | 重置集群所有累积统计 |
Table 27.37. 后台统计提取函数
| 函数 | 说明 |
|---|---|
pg_stat_get_backend_io() | 获取指定后台进程的 I/O 统计 |
pg_stat_get_backend_wal() | 获取指定后台进程的 WAL 统计 |