backup: This WAL sender is sending a backup. Waiting for a read while adding a line to the data directory lock file. Prevent sudden database connection spikes by using a connection pool. Waiting for a write when creating a new WAL segment by copying an existing one. Waiting to read or update information about synchronous replicas. Waiting for a replication slot control file to reach durable storage while restoring it to memory. quorum: This standby server is considered as a candidate for quorum standbys. Alternatively, one can build custom views using the underlying statistics functions, as discussed in Section28.2.3. Waiting for a replication slot control file to reach durable storage while restoring it to memory. wait_event will identify the specific wait point. Returns the wait event name if this backend is currently waiting, otherwise NULL. wait_event will identify the type of lock awaited. Waiting to read or update information about serializable transactions. idle: The backend is waiting for a new client command. Waiting for a write of logical rewrite mappings. Waiting for SSL while attempting connection. This field will only be non-null for IP connections, and only when log_hostname is enabled. wait_event will identify the specific wait point. The parameter track_io_timing enables monitoring of block read and write times. idle in transaction: The backend is in a transaction, but is not currently executing a query. Number of times this function has been called, Total time spent in this function and all other functions called by it, in milliseconds, Total time spent in this function itself, not including other functions called by it, in milliseconds. Waiting for base backup to read from a file. Therefore, a bitmap scan increments the pg_stat_all_indexes.idx_tup_read count(s) for the index(es) it uses, and it increments the pg_stat_all_tables.idx_tup_fetch count for the table, but it does not affect pg_stat_all_indexes.idx_tup_fetch. Number of transactions spilled to disk once the memory used by logical decoding to decode changes from WAL has exceeded logical_decoding_work_mem. This and other streaming counters for this slot can be used to tune logical_decoding_work_mem. DN of the issuer of the client certificate, or NULL if no client certificate was supplied or if SSL is not in use on this connection. In particular, when the standby has caught up completely, pg_stat_replication shows the time taken to write, flush and replay the most recent reported WAL location rather than zero as some users might expect. 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. Waiting for I/O on a multixact member SLRU buffer. Waiting in main loop of WAL sender process. Number of temporary files created by queries in this database. Waiting for a write of a serialized historical catalog snapshot. Waiting for logical rewrite mappings to reach durable storage during a checkpoint. The access functions for per-database statistics take a database OID as an argument to identify which database to report on. A process can wait for the data needed from a client ( Client) or another process ( IPC ). Sometimes it may be more convenient to obtain just a subset of this information. What we have discussed in this episode of 5mins of Postgres. See, One row for each tracked function, showing statistics about executions of that function. Increase the number of wal_buffers available to the database. Waiting to read or record conflicting serializable transactions. It also tracks the total number of rows in each table, and information about . > However, someone with deeper knowledge of page pinning and buffer manager > internals could certainly devise a better solution. Waiting to read or update the progress of one replication origin. The server process is waiting for a timeout to expire. The pg_stat_replication view will contain one row per WAL sender process, showing statistics about replication to that sender's connected standby server. See, One row per subscription, showing statistics about errors. The combination of certificate serial number and certificate issuer uniquely identifies a certificate (unless the issuer erroneously reuses serial numbers). Table28.12.pg_stat_database_conflicts View. Waiting for a write during reorder buffer management. From pg_stat_activity i noticed that the wait_event_type and wait_event of these queries is as follows: However, they are also used to ensure mutual exclusion for certain internal operations such as relation extension. Waiting to read or update vacuum-related information for a B-tree index. Waiting for data to reach durable storage while creating the data directory lock file. Waiting for a newly created timeline history file to reach durable storage. Autovacuum worker or launcher waiting to update or read the current state of autovacuum workers. Waiting in main loop of WAL receiver process. Returns the text of this backend's most recent query. Waiting to access the list of finished serializable transactions. This field is truncated if the principal is longer than NAMEDATALEN (64 characters in a standard build). The parameter track_io_timing enables monitoring of block read and write times. A backend process is waiting to associate a data block with a buffer in the shared buffer pool. Heavyweight locks, also known as lock manager locks or simply locks, primarily protect SQL-visible objects such as tables. Table28.31.pg_statio_all_sequences View, Number of disk blocks read from this sequence. BufferCacheHitRatio and LWLock:BufferIO wait This field is truncated if the DN field is longer than, Number of WAL files that have been successfully archived, Name of the last WAL file successfully archived, Time of the last successful archive operation, Number of failed attempts for archiving WAL files, Name of the WAL file of the last failed archival operation, Time of the last failed archival operation, Time at which these statistics were last reset, Number of scheduled checkpoints that have been performed, Number of requested checkpoints that have been performed, Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk, in milliseconds, Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk, in milliseconds, Number of buffers written during checkpoints, Number of buffers written by the background writer, Number of times the background writer stopped a cleaning scan because it had written too many buffers, Number of buffers written directly by a backend, Number of times a backend had to execute its own. These access functions use a backend ID number, which ranges from one to the number of currently active backends. pg_stat_get_backend_client_port ( integer ) integer. PostgreSQL utilizes lightweight locks (LWLocks) to synchronize and control access to the buffer content. See. pg_stat_get_backend_userid ( integer ) oid. Returns the OID of the database this backend is connected to. Identifier of this backend's most recent query. Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written and flushed it (but not yet applied it). Resets statistics for a single subscription shown in the pg_stat_subscription_stats view to zero. idle: The backend is waiting for a new client command. Waiting for confirmation from a remote server during synchronous replication. Waiting for a replication slot to become inactive to be dropped. Waiting to read or update information about. Waiting for logical rewrite mappings to reach durable storage during a checkpoint. Resetting these counters can cause autovacuum to not perform necessary work, which can cause problems such as table bloat or out-dated table statistics. Waiting for a read during recheck of the data directory lock file. OID of the user logged into this WAL sender process, Name of the user logged into this WAL sender process, Name of the application that is connected to this WAL sender. Resets statistics of the replication slot defined by the argument. See, One row for each index in the current database, showing statistics about accesses to that specific index. Re: Improve WALRead() to suck data directly from WAL buffers when possible Waiting for a read during reorder buffer management. Waiting for a write of a two phase state file. Waiting for any activity when processing replies from WAL receiver in WAL sender process. checksum_last_failure timestamp with time zone. Waiting to write a protocol message to a shared message queue. The columns wal_distance, block_distance and io_depth show current values, and the other columns show cumulative counters that can be reset with the pg_stat_reset_shared function. LWLock:buffer_mapping. The pg_stat_wal view will always have a single row, containing data about WAL activity of the cluster. (See Chapter19 for details about setting configuration parameters.). replication_slot_io: Waiting for I/O on a replication slot. The optimizer also accesses indexes to check for supplied constants whose values are outside the recorded range of the optimizer statistics because the optimizer statistics might be stale. This can be used to gauge the delay that. Waiting to acquire an exclusive lock to truncate off any empty pages at the end of a table vacuumed. Possible values are: active: The backend is executing a query. TCP port number that the client is using for communication with this WAL sender, or -1 if a Unix socket is used, Time when this process was started, i.e., when the client connected to this WAL sender. Principal used to authenticate this connection, or NULL if GSSAPI was not used to authenticate this connection. The pg_stat_all_tables view will contain one row for each table in the current database (including TOAST tables), showing statistics about accesses to that specific table. finish their input/output (I/O) operations when concurrently trying to access a page. A database-wide ANALYZE is recommended after the statistics have been reset. Waiting to read or update shared notification state. Waiting to access the sub-transaction SLRU cache. Waiting in main loop of syslogger process. this form 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. The generated IO patterns are also much worse. See, One row per database, showing database-wide statistics about query cancels due to conflict with recovery on standby servers. 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). Waiting to update limits on transaction id and multixact consumption. All temporary files are counted, regardless of why the temporary file was created, and regardless of the, Number of deadlocks detected in this database, Time spent reading data file blocks by backends in this database, in milliseconds, Time spent writing data file blocks by backends in this database, in milliseconds, Number of queries in this database that have been canceled due to dropped tablespaces, Number of queries in this database that have been canceled due to lock timeouts, Number of queries in this database that have been canceled due to old snapshots, Number of queries in this database that have been canceled due to pinned buffers, Number of queries in this database that have been canceled due to deadlocks, Number of sequential scans initiated on this table, Number of live rows fetched by sequential scans, Number of index scans initiated on this table, Number of live rows fetched by index scans, Number of rows updated (includes HOT updated rows), Number of rows HOT updated (i.e., with no separate index update required), Estimated number of rows modified since this table was last analyzed, Last time at which this table was manually vacuumed (not counting, Last time at which this table was vacuumed by the autovacuum daemon, Last time at which this table was manually analyzed, Last time at which this table was analyzed by the autovacuum daemon, Number of times this table has been manually vacuumed (not counting, Number of times this table has been vacuumed by the autovacuum daemon, Number of times this table has been manually analyzed, Number of times this table has been analyzed by the autovacuum daemon, Number of index scans initiated on this index, Number of index entries returned by scans on this index, Number of live table rows fetched by simple index scans using this index, Number of disk blocks read from this table, Number of disk blocks read from all indexes on this table, Number of buffer hits in all indexes on this table, Number of disk blocks read from this table's TOAST table (if any), Number of buffer hits in this table's TOAST table (if any), Number of disk blocks read from this table's TOAST table indexes (if any), Number of buffer hits in this table's TOAST table indexes (if any), Number of disk blocks read from this index, Number of disk blocks read from this sequence, Number of times this function has been called, Total time spent in this function and all other functions called by it, in milliseconds, Total time spent in this function itself, not including other functions called by it, in milliseconds, Process ID of the server process handling the current session, Returns a record of information about the backend with the specified PID, or one record for each active backend in the system if, Returns the timestamp of the current statistics snapshot, Reset all statistics counters for the current database to zero (requires superuser privileges by default, but EXECUTE for this function can be granted to others. Every PostgreSQL process collects statistics locally, then updates the shared data at appropriate intervals.