PostgreSQL 18 中文参考文档(未翻译部分保留英文)🌐 切换到英文原版 →

27.2. 累积统计收集器 #

27.2.1. 统计收集配置
27.2.2. 内置统计视图概览
27.2.3. pg_stat_activity 视图
27.2.4. pg_stat_replication 视图
27.2.5. pg_stat_replication_slots 视图
27.2.6. pg_stat_wal_receiver 视图
27.2.7. pg_stat_recovery_prefetch 视图
27.2.8. pg_stat_subscription 视图
27.2.9. pg_stat_subscription_stats 视图
27.2.10. pg_stat_ssl 视图
27.2.11. pg_stat_gssapi 视图
27.2.12. pg_stat_archiver 视图
27.2.13. pg_stat_io 视图
27.2.14. pg_stat_bgwriter 视图
27.2.15. pg_stat_checkpointer 视图
27.2.16. pg_stat_wal 视图
27.2.17. pg_stat_database 视图
27.2.18. pg_stat_database_conflicts 视图
27.2.19. pg_stat_all_tables 视图
27.2.20. pg_stat_all_indexes 视图
27.2.21. pg_statio_all_tables 视图
27.2.22. pg_statio_all_indexes 视图
27.2.23. pg_statio_all_sequences 视图
27.2.24. pg_stat_user_functions 视图
27.2.25. pg_stat_slru 视图
27.2.26. 统计收集函数

PostgreSQL 内置了高性能的累积统计收集系统,能够记录对数据表的访问频次、磁盘 I/O 读写块数、WAL 生成量以及会话连接事件。

27.2.1. 统计收集配置 #

统计数据的采集开销极其低廉,默认全部自动开启(包括 track_activities、track_counts 与 track_io_timing)。

27.2.2. 内置统计视图概览 #

系统提供了两组核心内置视图:动态视图与累积统计视图。

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_walWAL 写入与磁盘刷盘统计

27.2.3. 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 EventDescription
ArchiverMainWaiting in main loop of archiver process.
AutovacuumMainWaiting in main loop of autovacuum launcher process.
BgwriterHibernateWaiting in background writer process, hibernating.
BgwriterMainWaiting in main loop of background writer process.
CheckpointerMainWaiting in main loop of checkpointer process.
CheckpointerShutdownWaiting for checkpointer process to be terminated.
IoWorkerMainWaiting in main loop of IO Worker process.
LogicalApplyMainWaiting in main loop of logical replication apply process.
LogicalLauncherMainWaiting in main loop of logical replication launcher process.
LogicalParallelApplyMainWaiting in main loop of logical replication parallel apply process.
RecoveryWalStreamWaiting in main loop of startup process for WAL to arrive, during streaming recovery.
ReplicationSlotsyncMainWaiting in main loop of slot sync worker.
ReplicationSlotsyncShutdownWaiting for slot sync worker to shut down.
SysloggerMainWaiting in main loop of syslogger process.
WalReceiverMainWaiting in main loop of WAL receiver process.
WalSenderMainWaiting in main loop of WAL sender process.
WalSummarizerWalWaiting in WAL summarizer for more WAL to be generated.
WalWriterMainWaiting in main loop of WAL writer process.

Table 27.6. Wait Events of Type Bufferpin

BufferPin Wait EventDescription
BufferPinWaiting to acquire an exclusive pin on a buffer.

Table 27.7. Wait Events of Type Client

Client Wait EventDescription
ClientReadWaiting to read data from the client.
ClientWriteWaiting to write data to the client.
GssOpenServerWaiting to read data from the client while establishing a GSSAPI session.
LibpqwalreceiverConnectWaiting in WAL receiver to establish connection to remote server.
LibpqwalreceiverReceiveWaiting in WAL receiver to receive data from remote server.
SslOpenServerWaiting for SSL while attempting connection.
WaitForStandbyConfirmationWaiting for WAL to be received and flushed by the physical standby.
WalSenderWaitForWalWaiting for WAL to be flushed in WAL sender process.
WalSenderWriteDataWaiting for any activity when processing replies from WAL receiver in WAL sender process.

Table 27.8. Wait Events of Type Extension

Extension Wait EventDescription
ExtensionWaiting in an extension.

Table 27.9. Wait Events of Type Io

IO Wait EventDescription
AioIoCompletionWaiting for another process to complete IO.
AioIoUringExecutionWaiting for IO execution via io_uring.
AioIoUringSubmitWaiting for IO submission via io_uring.
BasebackupReadWaiting for base backup to read from a file.
BasebackupSyncWaiting for data written by a base backup to reach durable storage.
BasebackupWriteWaiting for base backup to write to a file.
BuffileReadWaiting for a read from a buffered file.
BuffileTruncateWaiting for a buffered file to be truncated.
BuffileWriteWaiting for a write to a buffered file.
ControlFileReadWaiting for a read from the pg_control file.
ControlFileSyncWaiting for the pg_control file to reach durable storage.
ControlFileSyncUpdateWaiting for an update to the pg_control file to reach durable storage.
ControlFileWriteWaiting for a write to the pg_control file.
ControlFileWriteUpdateWaiting for a write to update the pg_control file.
CopyFileCopyWaiting for a file copy operation.
CopyFileReadWaiting for a read during a file copy operation.
CopyFileWriteWaiting for a write during a file copy operation.
DataFileExtendWaiting for a relation data file to be extended.
DataFileFlushWaiting for a relation data file to reach durable storage.
DataFileImmediateSyncWaiting for an immediate synchronization of a relation data file to durable storage.
DataFilePrefetchWaiting for an asynchronous prefetch from a relation data file.
DataFileReadWaiting for a read from a relation data file.
DataFileSyncWaiting for changes to a relation data file to reach durable storage.
DataFileTruncateWaiting for a relation data file to be truncated.
DataFileWriteWaiting for a write to a relation data file.
DsmAllocateWaiting for a dynamic shared memory segment to be allocated.
DsmFillZeroWriteWaiting to fill a dynamic shared memory backing file with zeroes.
LockFileAddtodatadirReadWaiting for a read while adding a line to the data directory lock file.
LockFileAddtodatadirSyncWaiting for data to reach durable storage while adding a line to the data directory lock file.
LockFileAddtodatadirWriteWaiting for a write while adding a line to the data directory lock file.
LockFileCreateReadWaiting to read while creating the data directory lock file.
LockFileCreateSyncWaiting for data to reach durable storage while creating the data directory lock file.
LockFileCreateWriteWaiting for a write while creating the data directory lock file.
LockFileRecheckdatadirReadWaiting for a read during recheck of the data directory lock file.
LogicalRewriteCheckpointSyncWaiting for logical rewrite mappings to reach durable storage during a checkpoint.
LogicalRewriteMappingSyncWaiting for mapping data to reach durable storage during a logical rewrite.
LogicalRewriteMappingWriteWaiting for a write of mapping data during a logical rewrite.
LogicalRewriteSyncWaiting for logical rewrite mappings to reach durable storage.
LogicalRewriteTruncateWaiting for truncate of mapping data during a logical rewrite.
LogicalRewriteWriteWaiting for a write of logical rewrite mappings.
RelationMapReadWaiting for a read of the relation map file.
RelationMapReplaceWaiting for durable replacement of a relation map file.
RelationMapWriteWaiting for a write to the relation map file.
ReorderBufferReadWaiting for a read during reorder buffer management.
ReorderBufferWriteWaiting for a write during reorder buffer management.
ReorderLogicalMappingReadWaiting for a read of a logical mapping during reorder buffer management.
ReplicationSlotReadWaiting for a read from a replication slot control file.
ReplicationSlotRestoreSyncWaiting for a replication slot control file to reach durable storage while restoring it to memory.
ReplicationSlotSyncWaiting for a replication slot control file to reach durable storage.
ReplicationSlotWriteWaiting for a write to a replication slot control file.
SlruFlushSyncWaiting for SLRU data to reach durable storage during a checkpoint or database shutdown.
SlruReadWaiting for a read of an SLRU page.
SlruSyncWaiting for SLRU data to reach durable storage following a page write.
SlruWriteWaiting for a write of an SLRU page.
SnapbuildReadWaiting for a read of a serialized historical catalog snapshot.
SnapbuildSyncWaiting for a serialized historical catalog snapshot to reach durable storage.
SnapbuildWriteWaiting for a write of a serialized historical catalog snapshot.
TimelineHistoryFileSyncWaiting for a timeline history file received via streaming replication to reach durable storage.
TimelineHistoryFileWriteWaiting for a write of a timeline history file received via streaming replication.
TimelineHistoryReadWaiting for a read of a timeline history file.
TimelineHistorySyncWaiting for a newly created timeline history file to reach durable storage.
TimelineHistoryWriteWaiting for a write of a newly created timeline history file.
TwophaseFileReadWaiting for a read of a two phase state file.
TwophaseFileSyncWaiting for a two phase state file to reach durable storage.
TwophaseFileWriteWaiting for a write of a two phase state file.
VersionFileSyncWaiting for the version file to reach durable storage while creating a database.
VersionFileWriteWaiting for the version file to be written while creating a database.
WalsenderTimelineHistoryReadWaiting for a read from a timeline history file during a walsender timeline command.
WalBootstrapSyncWaiting for WAL to reach durable storage during bootstrapping.
WalBootstrapWriteWaiting for a write of a WAL page during bootstrapping.
WalCopyReadWaiting for a read when creating a new WAL segment by copying an existing one.
WalCopySyncWaiting for a new WAL segment created by copying an existing one to reach durable storage.
WalCopyWriteWaiting for a write when creating a new WAL segment by copying an existing one.
WalInitSyncWaiting for a newly initialized WAL file to reach durable storage.
WalInitWriteWaiting for a write while initializing a new WAL file.
WalReadWaiting for a read from a WAL file.
WalSummaryReadWaiting for a read from a WAL summary file.
WalSummaryWriteWaiting for a write to a WAL summary file.
WalSyncWaiting for a WAL file to reach durable storage.
WalSyncMethodAssignWaiting for data to reach durable storage while assigning a new WAL sync method.
WalWriteWaiting for a write to a WAL file.

Table 27.10. Wait Events of Type Ipc

IPC Wait EventDescription
AppendReadyWaiting for subplan nodes of an Append plan node to be ready.
ArchiveCleanupCommandWaiting for archive_cleanup_command to complete.
ArchiveCommandWaiting for archive_command to complete.
BackendTerminationWaiting for the termination of another backend.
BackupWaitWalArchiveWaiting for WAL files required for a backup to be successfully archived.
BgworkerShutdownWaiting for background worker to shut down.
BgworkerStartupWaiting for background worker to start up.
BtreePageWaiting for the page number needed to continue a parallel B-tree scan to become available.
BufferIoWaiting for buffer I/O to complete.
CheckpointDelayCompleteWaiting for a backend that blocks a checkpoint from completing.
CheckpointDelayStartWaiting for a backend that blocks a checkpoint from starting.
CheckpointDoneWaiting for a checkpoint to complete.
CheckpointStartWaiting for a checkpoint to start.
ExecuteGatherWaiting for activity from a child process while executing a Gather plan node.
HashBatchAllocateWaiting for an elected Parallel Hash participant to allocate a hash table.
HashBatchElectWaiting to elect a Parallel Hash participant to allocate a hash table.
HashBatchLoadWaiting for other Parallel Hash participants to finish loading a hash table.
HashBuildAllocateWaiting for an elected Parallel Hash participant to allocate the initial hash table.
HashBuildElectWaiting to elect a Parallel Hash participant to allocate the initial hash table.
HashBuildHashInnerWaiting for other Parallel Hash participants to finish hashing the inner relation.
HashBuildHashOuterWaiting for other Parallel Hash participants to finish partitioning the outer relation.
HashGrowBatchesDecideWaiting to elect a Parallel Hash participant to decide on future batch growth.
HashGrowBatchesElectWaiting to elect a Parallel Hash participant to allocate more batches.
HashGrowBatchesFinishWaiting for an elected Parallel Hash participant to decide on future batch growth.
HashGrowBatchesReallocateWaiting for an elected Parallel Hash participant to allocate more batches.
HashGrowBatchesRepartitionWaiting for other Parallel Hash participants to finish repartitioning.
HashGrowBucketsElectWaiting to elect a Parallel Hash participant to allocate more buckets.
HashGrowBucketsReallocateWaiting for an elected Parallel Hash participant to finish allocating more buckets.
HashGrowBucketsReinsertWaiting for other Parallel Hash participants to finish inserting tuples into new buckets.
LogicalApplySendDataWaiting for a logical replication leader apply process to send data to a parallel apply process.
LogicalParallelApplyStateChangeWaiting for a logical replication parallel apply process to change state.
LogicalSyncDataWaiting for a logical replication remote server to send data for initial table synchronization.
LogicalSyncStateChangeWaiting for a logical replication remote server to change state.
MessageQueueInternalWaiting for another process to be attached to a shared message queue.
MessageQueuePutMessageWaiting to write a protocol message to a shared message queue.
MessageQueueReceiveWaiting to receive bytes from a shared message queue.
MessageQueueSendWaiting to send bytes to a shared message queue.
MultixactCreationWaiting for a multixact creation to complete.
ParallelBitmapScanWaiting for parallel bitmap scan to become initialized.
ParallelCreateIndexScanWaiting for parallel CREATE INDEX workers to finish heap scan.
ParallelFinishWaiting for parallel workers to finish computing.
ProcarrayGroupUpdateWaiting for the group leader to clear the transaction ID at transaction end.
ProcSignalBarrierWaiting for a barrier event to be processed by all backends.
PromoteWaiting for standby promotion.
RecoveryConflictSnapshotWaiting for recovery conflict resolution for a vacuum cleanup.
RecoveryConflictTablespaceWaiting for recovery conflict resolution for dropping a tablespace.
RecoveryEndCommandWaiting for recovery_end_command to complete.
RecoveryPauseWaiting for recovery to be resumed.
ReplicationOriginDropWaiting for a replication origin to become inactive so it can be dropped.
ReplicationSlotDropWaiting for a replication slot to become inactive so it can be dropped.
RestoreCommandWaiting for restore_command to complete.
SafeSnapshotWaiting to obtain a valid snapshot for a READ ONLY DEFERRABLE transaction.
SyncRepWaiting for confirmation from a remote server during synchronous replication.
WalReceiverExitWaiting for the WAL receiver to exit.
WalReceiverUpstreamCatchupWaiting for upstream server WAL flush position to catch up to requested start point.
WalReceiverWaitStartWaiting for startup process to send initial data for streaming replication.
WalSummaryReadyWaiting for a new WAL summary to be generated.
XactGroupUpdateWaiting for the group leader to update transaction status at transaction end.

Table 27.11. Wait Events of Type Lock

Lock Wait EventDescription
advisoryWaiting to acquire an advisory user lock.
applytransactionWaiting to acquire a lock on a remote transaction being applied by a logical replication subscriber.
extendWaiting to extend a relation.
frozenidWaiting to update pg_database.datfrozenxid and pg_database.datminmxid.
objectWaiting to acquire a lock on a non-relation database object.
pageWaiting to acquire a lock on a page of a relation.
relationWaiting to acquire a lock on a relation.
spectokenWaiting to acquire a speculative insertion lock.
transactionidWaiting for a transaction to finish.
tupleWaiting to acquire a lock on a tuple.
userlockWaiting to acquire a user lock.
virtualxidWaiting to acquire a virtual transaction ID lock; see Section 67.1.

Table 27.12. Wait Events of Type Lwlock

LWLock Wait EventDescription
AddinShmemInitWaiting to manage an extension's space allocation in shared memory.
AioUringCompletionWaiting for another process to complete IO via io_uring.
AioWorkerSubmissionQueueWaiting to access AIO worker submission queue.
AutoFileWaiting to update the postgresql.auto.conf file.
AutovacuumWaiting to read or update the current state of autovacuum workers.
AutovacuumScheduleWaiting to ensure that a table selected for autovacuum still needs vacuuming.
BackgroundWorkerWaiting to read or update background worker state.
BtreeVacuumWaiting to read or update vacuum-related information for a B-tree index.
BufferContentWaiting to access a data page in memory.
BufferMappingWaiting to associate a data block with a buffer in the buffer pool.
CheckpointerCommWaiting to manage fsync requests.
CommitTsWaiting to read or update the last value set for a transaction commit timestamp.
CommitTsBufferWaiting for I/O on a commit timestamp SLRU buffer.
CommitTsSLRUWaiting to access the commit timestamp SLRU cache.
ControlFileWaiting to read or update the pg_control file or create a new WAL file.
DSMRegistryWaiting to read or update the dynamic shared memory registry.
DSMRegistryDSAWaiting to access dynamic shared memory registry's dynamic shared memory allocator.
DSMRegistryHashWaiting to access dynamic shared memory registry's shared hash table.
DynamicSharedMemoryControlWaiting to read or update dynamic shared memory allocation information.
InjectionPointWaiting to read or update information related to injection points.
LockFastPathWaiting to read or update a process' fast-path lock information.
LockManagerWaiting to read or update information about “heavyweight” locks.
LogicalRepLauncherDSAWaiting to access logical replication launcher's dynamic shared memory allocator.
LogicalRepLauncherHashWaiting to access logical replication launcher's shared hash table.
LogicalRepWorkerWaiting to read or update the state of logical replication workers.
MultiXactGenWaiting to read or update shared multixact state.
MultiXactMemberBufferWaiting for I/O on a multixact member SLRU buffer.
MultiXactMemberSLRUWaiting to access the multixact member SLRU cache.
MultiXactOffsetBufferWaiting for I/O on a multixact offset SLRU buffer.
MultiXactOffsetSLRUWaiting to access the multixact offset SLRU cache.
MultiXactTruncationWaiting to read or truncate multixact information.
NotifyBufferWaiting for I/O on a NOTIFY message SLRU buffer.
NotifyQueueWaiting to read or update NOTIFY messages.
NotifyQueueTailWaiting to update limit on NOTIFY message storage.
NotifySLRUWaiting to access the NOTIFY message SLRU cache.
OidGenWaiting to allocate a new OID.
ParallelAppendWaiting to choose the next subplan during Parallel Append plan execution.
ParallelBtreeScanWaiting to synchronize workers during Parallel B-tree scan plan execution.
ParallelHashJoinWaiting to synchronize workers during Parallel Hash Join plan execution.
ParallelQueryDSAWaiting for parallel query dynamic shared memory allocation.
ParallelVacuumDSAWaiting for parallel vacuum dynamic shared memory allocation.
PerSessionDSAWaiting for parallel query dynamic shared memory allocation.
PerSessionRecordTypeWaiting to access a parallel query's information about composite types.
PerSessionRecordTypmodWaiting to access a parallel query's information about type modifiers that identify anonymous record types.
PerXactPredicateListWaiting to access the list of predicate locks held by the current serializable transaction during a parallel query.
PgStatsDataWaiting for shared memory stats data access.
PgStatsDSAWaiting for stats dynamic shared memory allocator access.
PgStatsHashWaiting for stats shared memory hash table access.
PredicateLockManagerWaiting to access predicate lock information used by serializable transactions.
ProcArrayWaiting to access the shared per-process data structures (typically, to get a snapshot or report a session's transaction ID).
RelationMappingWaiting to read or update a pg_filenode.map file (used to track the filenode assignments of certain system catalogs).
RelCacheInitWaiting to read or update a pg_internal.init relation cache initialization file.
ReplicationOriginWaiting to create, drop or use a replication origin.
ReplicationOriginStateWaiting to read or update the progress of one replication origin.
ReplicationSlotAllocationWaiting to allocate or free a replication slot.
ReplicationSlotControlWaiting to read or update replication slot state.
ReplicationSlotIOWaiting for I/O on a replication slot.
SerialBufferWaiting for I/O on a serializable transaction conflict SLRU buffer.
SerialControlWaiting to read or update shared pg_serial state.
SerializableFinishedListWaiting to access the list of finished serializable transactions.
SerializablePredicateListWaiting to access the list of predicate locks held by serializable transactions.
SerializableXactHashWaiting to read or update information about serializable transactions.
SerialSLRUWaiting to access the serializable transaction conflict SLRU cache.
SharedTidBitmapWaiting to access a shared TID bitmap during a parallel bitmap index scan.
SharedTupleStoreWaiting to access a shared tuple store during parallel query.
ShmemIndexWaiting to find or allocate space in shared memory.
SInvalReadWaiting to retrieve messages from the shared catalog invalidation queue.
SInvalWriteWaiting to add a message to the shared catalog invalidation queue.
SubtransBufferWaiting for I/O on a sub-transaction SLRU buffer.
SubtransSLRUWaiting to access the sub-transaction SLRU cache.
SyncRepWaiting to read or update information about the state of synchronous replication.
SyncScanWaiting to select the starting location of a synchronized table scan.
TablespaceCreateWaiting to create or drop a tablespace.
TwoPhaseStateWaiting to read or update the state of prepared transactions.
WaitEventCustomWaiting to read or update custom wait events information.
WALBufMappingWaiting to replace a page in WAL buffers.
WALInsertWaiting to insert WAL data into a memory buffer.
WALSummarizerWaiting to read or update WAL summarization state.
WALWriteWaiting for WAL buffers to be written to disk.
WrapLimitsVacuumWaiting to update limits on transaction id and multixact consumption.
XactBufferWaiting for I/O on a transaction status SLRU buffer.
XactSLRUWaiting to access the transaction status SLRU cache.
XactTruncationWaiting to execute pg_xact_status or update the oldest transaction ID available to it.
XidGenWaiting to allocate a new transaction ID.

Table 27.13. Wait Events of Type Timeout

Timeout Wait EventDescription
BaseBackupThrottleWaiting during base backup when throttling activity.
CheckpointWriteDelayWaiting between writes while performing a checkpoint.
PgSleepWaiting due to a call to pg_sleep or a sibling function.
RecoveryApplyDelayWaiting to apply WAL during recovery because of a delay setting.
RecoveryRetrieveRetryIntervalWaiting during recovery when WAL data is not available from any source (pg_wal, archive or stream).
RegisterSyncRequestWaiting while sending synchronization requests to the checkpointer, because the request queue is full.
SpinDelayWaiting while acquiring a contended spinlock.
VacuumDelayWaiting in a cost-based vacuum delay point.
VacuumTruncateWaiting to acquire an exclusive lock to truncate off any empty pages at the end of a table vacuumed.
WalSummarizerErrorWaiting after a WAL summarizer error.

27.2.4. pg_stat_replication 视图 #

显示主节点上正在向备节点流式发送 WAL 的 walsender 进程状态。

Table 27.14. pg_stat_replication 字段

字段说明
client_addr备库 IP 地址
replay_lsn备库最新回放位点

27.2.5. pg_stat_replication_slots 视图 #

提供关于逻辑与物理复制槽的数据处理度量统计。

Table 27.15. pg_stat_replication_slots 字段

字段说明
slot_name复制槽名称
spill_bytes解码溢出到磁盘的字节数

27.2.6. pg_stat_wal_receiver 视图 #

在备库上显示正在接收 WAL 流的 walreceiver 工作进程实时状态。

Table 27.16. pg_stat_wal_receiver 字段

字段说明
status接收器运行状态

27.2.7. pg_stat_recovery_prefetch 视图 #

显示备库或故障恢复期间预读磁盘块的命中统计。

Table 27.17. pg_stat_recovery_prefetch 字段

字段说明
prefetch预读页面计数

27.2.8. pg_stat_subscription 视图 #

显示订阅端上逻辑复制各个订阅工作进程的实时连接状态。

Table 27.18. pg_stat_subscription 字段

字段说明
subname订阅名称

27.2.9. pg_stat_subscription_stats 视图 #

提供逻辑复制订阅的累积失败与冲突度量统计。

Table 27.19. pg_stat_subscription_stats 字段

字段说明
confl_count写入冲突计数

27.2.10. pg_stat_ssl 视图 #

显示当前每个客户端会话的 SSL/TLS 连接加密详情(加密算法、协议版本等)。

Table 27.20. pg_stat_ssl 字段

字段说明
ssl是否启用 SSL

27.2.11. pg_stat_gssapi 视图 #

显示当前客户端连接的 GSSAPI 身份认证与加密状态。

Table 27.21. pg_stat_gssapi 字段

字段说明
gss_authenticated是否通过 GSSAPI 认证

27.2.12. pg_stat_archiver 视图 #

显示 WAL 归档进程的成功与失败计数及最近归档时间。

Table 27.22. pg_stat_archiver 字段

字段说明
archived_count成功归档段数

27.2.13. pg_stat_io 视图 #

提供整个集群按照后台进程类型、上下文目标与 I/O 操作类型划分的细粒度读写读写统计。

Table 27.23. pg_stat_io 字段

字段说明
backend_type后台进程类别
reads物理读页面数

27.2.14. pg_stat_bgwriter 视图 #

显示后台写进程(bgwriter)的物理页面刷盘清理统计。

Table 27.24. pg_stat_bgwriter 字段

字段说明
buffers_clean清理写出的缓冲区页数

27.2.15. pg_stat_checkpointer 视图 #

显示检查点工作进程的执行频次、触发原因及刷盘耗时。

Table 27.25. pg_stat_checkpointer 字段

字段说明
num_timed定时检查点次数

27.2.16. pg_stat_wal 视图 #

显示预写式日志(WAL)的生成总量、写入与 fsync 刷盘开销。

Table 27.26. pg_stat_wal 字段

字段说明
wal_records生成的 WAL 记录数

27.2.17. pg_stat_database 视图 #

显示数据库级别的整体聚合度量(事务提交数、回滚数、死锁数、冲突数等)。

Table 27.27. pg_stat_database 字段

字段说明
xact_commit提交事务总数

27.2.18. pg_stat_database_conflicts 视图 #

显示热备节点上由不同原因导致的查询取消冲突统计。

Table 27.28. pg_stat_database_conflicts 字段

字段说明
confl_lock锁冲突取消计数

27.2.19. pg_stat_all_tables 视图 #

显示各数据表的顺序扫描次数、行读取数、存活与死元组数以及上次自动清理时间。

Table 27.29. pg_stat_all_tables 字段

字段说明
n_dead_tup死元组估计数量

27.2.20. pg_stat_all_indexes 视图 #

显示各索引的扫描次数、抓取元组数及效率。

Table 27.30. pg_stat_all_indexes 字段

字段说明
idx_scan索引扫描次数

27.2.21. pg_statio_all_tables 视图 #

显示表数据块的真实物理磁盘读取数与共享内存缓冲区命中数。

Table 27.31. pg_statio_all_tables 字段

字段说明
heap_blks_hit内存命中块数

27.2.22. pg_statio_all_indexes 视图 #

显示索引数据块的磁盘读取与内存命中统计。

Table 27.32. pg_statio_all_indexes 字段

字段说明
idx_blks_hit索引内存命中块数

27.2.23. pg_statio_all_sequences 视图 #

显示序列对象的 I/O 读写与缓存命中统计。

Table 27.33. pg_statio_all_sequences 字段

字段说明
blks_hit序列内存命中块数

27.2.24. pg_stat_user_functions 视图 #

显示用户自定义函数的执行次数、单次调用总耗时与自身耗时。

Table 27.34. pg_stat_user_functions 字段

字段说明
calls调用总次数

27.2.25. pg_stat_slru 视图 #

显示简单近期最少使用(SLRU)缓存的读写、命中与落盘统计。

Table 27.35. pg_stat_slru 字段

字段说明
blks_hitSLRU 命中块数

27.2.26. 统计收集函数 #

用于查询与重置统计收集器数据的内置函数。

Table 27.36. 常用统计查询函数

函数说明
pg_stat_reset()重置集群所有累积统计

Table 27.37. 后台统计提取函数

函数说明
pg_stat_get_backend_io()获取指定后台进程的 I/O 统计
pg_stat_get_backend_wal()获取指定后台进程的 WAL 统计