Redrock Postgres Documentation
Home Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Wait Events Overview

At any point in time, each database server process is busy processing a request or waiting for a specific event to occur. We say that it is busy, which means that the process needs to use the CPU at that time. For example, when a session process executes a SQL procedure, it may be doing an arithmetic calculation that we say is busy, not waiting. At the same time, another session process may be committing a transaction, and it is waiting for a response from the operating system telling it that the fsync system call it used to flush the log has been completed, and we say it is in a waiting state.

Here is an example of how wait events can be viewed:

SELECT pid, wait_event_type, wait_event
   FROM pg_stat_activity
   WHERE wait_event is NOT NULL;

Execute the following query to view collected and summarized statistics of wait events occured in the system:

SELECT * FROM pg_stat_wait_event
   ORDER BY total_time DESC;

Execute the following query to view statistics of wait events occurred in a session:

SELECT pg_stat_reset_wait_event(pg_backend_pid());
-- In current session, execute a series of SQL commands
SELECT * FROM pg_stat_get_wait_event(pg_backend_pid()) AS we
   ORDER BY total_time DESC;

Wait Event Types

Table 1. Wait Event Types

Wait Event Type Description
Activity The server process is idle. This event type indicates a process waiting for activity in its main processing loop. wait_event will identify the specific wait point; see Table 2.
BufferPin The server process is waiting for exclusive access to a data buffer. Buffer pin waits can be protracted if another process holds an open cursor that last read data from the buffer in question. See Table 3.
Client The server process is waiting for activity on a socket connected to a user application. Thus, the server expects something to happen that is independent of its internal processes. wait_event will identify the specific wait point; see Table 4.
CPU The server process is active in CPU or is waiting for CPU. See Table 5.
Extension The server process is waiting for some condition defined by an extension module. See Table 6.
IO The server process is waiting for an I/O operation to complete. wait_event will identify the specific wait point; see Table 7.
IPC The server process is waiting for some interaction with another server process. wait_event will identify the specific wait point; see Table 8.
Lock The server process is waiting for a heavyweight lock. Heavyweight locks, also known as lock manager locks or simply locks, primarily protect SQL-visible objects such as tables. However, they are also used to ensure mutual exclusion for certain internal operations such as relation extension. wait_event will identify the type of lock awaited; see Table 9.
LWLock The server process is waiting for a lightweight lock. Most such locks protect a particular data structure in shared memory. wait_event will contain a name identifying the purpose of the lightweight lock. (Some locks have specific names; others are part of a group of locks each with a similar purpose.) See Table 10.
SpinLock The server process is waiting for a spin lock. Most such locks protect a particular data structure in shared memory. wait_event will contain a name identifying the purpose of the spin lock. (Some locks have specific names; others are part of a group of locks each with a similar purpose.) See Table 11.
Timeout The server process is waiting for a timeout to expire. wait_event will identify the specific wait point; see Table 12.

Wait Events of Type Activity

Table 2. Wait Events of Type Activity

Activity Wait Event Description
ArchiverMain Waiting in main loop of archiver process.
AnalyzeLauncherMain Waiting in main loop of autoanalyze 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.
LogicalApplyMain Waiting in main loop of logical replication apply process.
LogicalLauncherMain Waiting in main loop of logical replication launcher process.
PgStatMain Waiting in main loop of statistics collector process.
RecoveryWalStream Waiting in main loop of startup process for WAL to arrive, during streaming recovery.
SysLoggerMain Waiting in main loop of syslogger process.
UndoLauncherMain Waiting in main loop of undo maintenance launcher process.
WalReceiverMain Waiting in main loop of WAL receiver process.
WalSenderMain Waiting in main loop of WAL sender process.
WalWriterMain Waiting in main loop of WAL writer process.

Wait Events of Type BufferPin

Table 3. Wait Events of Type BufferPin

BufferPin Wait Event Description
BufferPin Waiting to acquire an exclusive pin on a buffer.

Wait Events of Type Client

Table 4. 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.
LibPQStorageConnect Waiting in compute server to establish connection to remote storage server.
LibPQStorageReceive Waiting in compute server to receive data from remote storage server.
SSLOpenServer Waiting for SSL while attempting connection.
WalReceiverWaitStart Waiting for startup process to send initial data for streaming replication.
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.

Wait Events of Type CPU

Table 5. Wait Events of Type CPU

CPU Wait Event Description
CPU Active in CPU or Waiting for CPU.

Wait Events of Type Extension

Table 6. Wait Events of Type Extension

Extension Wait Event Description
Extension Waiting in an extension.

Wait Events of Type IO

Table 7. Wait Events of Type IO

IO Wait Event Description
BaseBackupRead Waiting for base backup to read from a file.
BufFileRead Waiting for a read from a buffered file.
BufFileWrite Waiting for a write to a buffered file.
BufFileTruncate Waiting for a buffered file to be truncated.
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.
CopyFileRead Waiting for a read during a file copy operation.
CopyFileWrite Waiting for a write during a file copy operation.
DSMFillZeroWrite Waiting to fill a dynamic shared memory backing file with zeroes.
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.
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.
RelationMapSync Waiting for the relation map file to reach durable storage.
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.
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.
WALSenderTimelineHistoryRead Waiting for a read from a timeline history file during a walsender timeline command.
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.

Wait Events of Type IPC

Table 8. Wait Events of Type IPC

IPC Wait Event Description
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.
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.
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.
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 end of a parallel operation.
ProcSignalBarrier Waiting for a barrier event to be processed by all backends.
Promote Waiting for standby promotion.
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.
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.
WalReceiverWaitStart Waiting for startup process to send initial data for streaming replication.
XactGroupUpdate Waiting for the group leader to update transaction status at end of a parallel operation.

Wait Events of Type Lock

Table 9. Wait Events of Type Lock

Lock Wait Event Description
advisory Waiting to acquire an advisory user lock.
extend Waiting to extend a relation.
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.
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.

Wait Events of Type LWLock

Table 10. Wait Events of Type LWLock

LWLock Wait Event Description
AddinShmemInitLock Waiting to manage an extension’s space allocation in shared memory.
AutoFileLock Waiting to update the postgresql.auto.conf file.
AutoanalyzeLock Waiting to read or update the current state of autoanalyze workers.
AutoanalyzeScheduleLock Waiting to ensure that a table selected for autoanalyze still needs analyzing.
BackgroundWorkerLock Waiting to read or update background worker state.
buffer_content Waiting to access a data page in memory.
buffer_io Waiting to read or write a data page in disk.
buffer_mapping Waiting to associate a data block with a buffer in the buffer pool.
CheckpointLock Waiting to perform checkpoint.
CheckpointerCommLock Waiting to manage fsync requests.
ControlFileLock Waiting to read or update the pg_control file or create a new WAL file.
DatabaseStateLock Waiting to update state of databases.
DynamicSharedMemoryControlLock Waiting to read or update dynamic shared memory allocation information.
lock_manager Waiting to read or update information about “heavyweight” locks.
LogicalRepWorkerLock Waiting to read or update the state of logical replication workers.
OidGenLock Waiting to allocate a new OID.
OldSerXidLock Waiting to read or record conflicting serializable transactions.
PLogSpaceLock Waiting to update state of network tablespaces.
PLogWriteLock Waiting for PLOG buffers to be written to disk.
predicate_lock_manager Waiting to access predicate lock information used by serializable transactions.
ProcArrayLock Waiting to access the shared per-process data structures. Usually occurs when a connection is established and released, or when reporting a session’s transaction ID.
RelCacheInitLock Waiting to read or update a pg_internal.init relation cache initialization file.
ReplicationOriginLock Waiting to create, drop or use a replication origin.
ReplicationSlotAllocationLock Waiting to allocate or free a replication slot.
ReplicationSlotControlLock Waiting to read or update replication slot state.
replication_origin Waiting to read or update the replication progress.
replication_slot_io Waiting for I/O on a replication slot.
SerializableFinishedListLock Waiting to access the list of finished serializable transactions.
SerializablePredicateListLock Waiting to access the list of predicate locks held by serializable transactions.
SerializableXactHashLock Waiting to read or update information about serializable transactions.
ShmemIndexLock Waiting to find or allocate space in shared memory.
SInvalReadLock Waiting to retrieve messages from the shared catalog invalidation queue.
SInvalWriteLock Waiting to add a message to the shared catalog invalidation queue.
SyncRepLock Waiting to read or update information about the state of synchronous replication.
SyncScanLock Waiting to select the starting location of a synchronized table scan.
TablespaceMapLock Waiting to read or update the storage location configuration files of tablespaces.
TwoPhaseStateLock Waiting to read or update the state of prepared transactions.
WALBufMappingLock Waiting to replace a page in WAL buffers.
wal_insert Waiting to insert WAL data into a memory buffer.
WALWriteLock Waiting for WAL buffers to be written to disk.
Extensions can add LWLock types to the list shown in Table 9. In some cases, the name assigned by an extension will not be available in all server processes; so an LWLock wait event might be reported as just “extension” rather than the extension-assigned name.

Wait Events of Type SpinLock

Table 11. Wait Events of Type SpinLock

SpinLock Wait Event Description
BufferHeader Waiting for access buffer header information.
BufferStrategyControl Waiting for access information about buffer allocation and elimination, and maintain a free buffer list and buffer elimination based on a clock sweep algorithm.
CheckpointerShmem Waiting for access information about checkpoint.
ConditionVariable Waiting to enter or exit the queue used by condition variable.
FastPathStrongLock Waiting to read or update a process’ fast-path lock information.
HashFreelist Waiting to access the free element list in the shared partitioned hash table.
InvalMessageNumber Waiting to retrieve invalidation message counter.
LogicalTableSync Waiting for access information about the initial table synchronization in logical replication.
LWLockWaitList Waiting to enter or exit the queue to used by LWLock.
ParallelBitmapHeapScan Waiting for access information used by parallel bitmap scan.
ParallelBtreeScan Waiting for access information used by parallel btree scan.
ParallelFixedState Waiting for access some basic information about parallel query, mainly used to update the latest log sequence number of the parallel worker process.
ParallelHeapScan Waiting for access information used by parallel heap scan.
PGProcFreeList Waiting for allocate or release shared per-process data structure. Usually occurs during the establishment and release of a database connection.
PLogControl Waiting for access information about the PLOG buffer state.
ReplicationSlot Waiting for access information about replication slot.
ShmemAlloc Waiting for allocate shared memory.
ShmemMessageQueue Waiting for access shared memory message queue.
ShmemSegmentTable Waiting for access shared memory segment table of contents.
StorageServerControl Waiting for access information about the storage server process.
UnloggedLSN Wait to retrieve a instance level log sequence number similar to the LSN.
VFDHeader Waiting for read or update information about the virtual file descriptor.
VSDHeader Waiting for read or update information about the virtual storage descriptor.
WALReceiverData Waiting for access information about the WAL receiver process.
WALSenderControl Waiting for access information about the WAL sender process.
XLogControl Waiting for access information about the WAL buffer state.

Wait Events of Type Timeout

Table 12. Wait Events of Type Timeout

Timeout Wait Event Description
BaseBackupThrottle Waiting during base backup when throttling activity.
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.