diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 0eb085e213..1f4f0929e3 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -140,13 +140,13 @@ postgres: user database host - The parameter controls whether - statistics are collected about table and index accesses. + The parameter enables monitoring + of the current command being executed by any server process. - The parameter enables monitoring - of block read and write times. + The parameter controls whether + statistics are collected about table and index accesses. @@ -155,8 +155,8 @@ postgres: user database host - The parameter enables monitoring - of the current command being executed by any server process. + The parameter enables monitoring + of block read and write times. @@ -170,13 +170,16 @@ postgres: user database host - The statistics collector transmits the collected - information to backends (including autovacuum) through temporary files. - These files are stored in the pg_stat_tmp subdirectory. - When the postmaster shuts down, a permanent copy of the statistics - data is stored in the global subdirectory. For increased - performance, the parameter can - be pointed at a RAM-based file system, decreasing physical I/O requirements. + The statistics collector transmits the collected information to other + PostgreSQL processes through temporary files. + These files are stored in the directory named by the + parameter, + pg_stat_tmp by default. + For better performance, stats_temp_directory can be + pointed at a RAM-based file system, decreasing physical I/O requirements. + When the server shuts down, a permanent copy of the statistics + data is stored in the global subdirectory, so that + statistics can be retained across server restarts. @@ -188,7 +191,8 @@ postgres: user database host , are available to show the results of statistics collection. Alternatively, one can - build custom views using the underlying statistics functions. + build custom views using the underlying statistics functions, as discussed + in . @@ -198,7 +202,7 @@ postgres: user database host PGSTAT_STAT_INTERVAL - milliseconds (500 unless altered while building the server). So the + milliseconds (500 msec unless altered while building the server). So the displayed information lags behind actual activity. However, current-query information collected by track_activities is always up-to-date. @@ -229,10 +233,8 @@ postgres: user database host pg_stat_xact_all_tables, pg_stat_xact_sys_tables, pg_stat_xact_user_tables, and - pg_stat_xact_user_functions, or via these views' underlying - functions (named the same as the standard statistics functions but with the - prefix pg_stat_get_xact_). These numbers do not act - as stated above; instead they update continuously throughout the transaction. + pg_stat_xact_user_functions. These numbers do not act as + stated above; instead they update continuously throughout the transaction. @@ -253,58 +255,33 @@ postgres: user database host pg_stat_activity - One row per server process, showing information related to - each connection to the server. Unless the - parameter has been turned - off, it is possible to monitor state and query information of - all running processes. - - - See for more details. - - + One row per server process, showing information related to + the current activity of that process, such as state and current query. + See for details. + pg_stat_bgwriterpg_stat_bgwriter - One row only, showing cluster-wide statistics. See - for more details. + One row only, showing statistics about the + background writer process's activity. See + for details. pg_stat_databasepg_stat_database One row per database, showing database-wide statistics. See - for more details. + for details. - - pg_stat_database_conflictspg_stat_database_conflicts - - One row per database showing database-wide statistics about - query cancels due to conflict with recovery on standby servers. - Will only contain information on standby servers, since - conflicts do not occur on master servers. - See for more details. - - - - - pg_stat_replicationpg_stat_replication - One row per WAL sender process, showing statistics about the - replication to this slave. See - for more details. Only directly connected standbys are listed; no - information about downstream standby servers is recorded. - - - pg_stat_all_tablespg_stat_all_tables - One row for each table in the current database (including TOAST - tables) with information about accesses to this specific table. - See for more details. + One row for each table in the current database, showing statistics + about accesses to that specific table. + See for details. @@ -344,9 +321,9 @@ postgres: user database host pg_stat_all_indexespg_stat_all_indexes - One row for each index in the current database with information - about accesses to this specific index. - See for more details. + One row for each index in the current database, showing statistics + about accesses to that specific index. + See for details. @@ -365,9 +342,9 @@ postgres: user database host pg_statio_all_tablespg_statio_all_tables - One row for each table in the current database (including TOAST - tables) with information about I/O on this specific table. - See for more details. + One row for each table in the current database, showing statistics + about I/O on that specific table. + See for details. @@ -386,9 +363,9 @@ postgres: user database host pg_statio_all_indexespg_statio_all_indexes - One row for each index in the current database - with information about I/O on this specific index. - See for more details. + One row for each index in the current database, + showing statistics about I/O on that specific index. + See for details. @@ -407,9 +384,9 @@ postgres: user database host pg_statio_all_sequencespg_statio_all_sequences - One row for each sequence in the current database - with information about I/O on this specific sequence. - See for more details. + One row for each sequence in the current database, + showing statistics about I/O on that specific sequence. + See for details. @@ -429,9 +406,9 @@ postgres: user database host pg_stat_user_functionspg_stat_user_functions - One row for each tracked function (as specified by the - parameter). See - for more details. + One row for each tracked function, showing statistics + about executions of that function. See + for details. @@ -442,6 +419,23 @@ postgres: user database host pg_stat_user_functions). + + pg_stat_replicationpg_stat_replication + One row per WAL sender process, showing statistics about + replication to that sender's connected standby server. + See for details. + + + + + pg_stat_database_conflictspg_stat_database_conflicts + + One row per database, showing database-wide statistics about + query cancels due to conflict with recovery on standby servers. + See for details. + + +
@@ -451,33 +445,6 @@ postgres: user database host - - Indexes can be - used either directly or via bitmap scans. In a bitmap scan - the output of several indexes can be combined via AND or OR rules; - so it is difficult to associate individual heap row fetches - with specific indexes when a bitmap scan is used. 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. - - - - - Before PostgreSQL 8.1, the - idx_tup_read and idx_tup_fetch counts - were essentially always equal. Now they can be different even without - considering bitmap scans, because idx_tup_read counts - index entries retrieved from the index while idx_tup_fetch - counts live rows fetched from the table; the latter will be less if any - dead or not-yet-committed rows are fetched using the index, or if any - heap fetches are avoided by means of an index-only scan. - - - The pg_statio_ views are primarily useful to determine the effectiveness of the buffer cache. When the number @@ -495,21 +462,6 @@ postgres: user database host - - Other ways of looking at the statistics can be set up by writing - queries that use the same underlying statistics access functions as - these standard views do. These functions are listed in . The per-database access - functions take a database OID as an argument to identify which - database to report on. The per-table and per-index functions take - a table or index OID. The functions for function-call statistics - take a function OID. (Note that only tables, indexes, and functions - in the current database can be seen with these functions.) The - per-server-process access functions take a server process - number, which ranges from one to the number of currently active - server processes. - - pg_stat_activity view @@ -525,98 +477,94 @@ postgres: user database host - datid + datid oid - The OID of the database the backend is connected to. + OID of the database this backend is connected to. This value can also be returned by directly calling the pg_stat_get_backend_dbid function. - datname + datname name - The name of the database the backend is connected to. + Name of the database this backend is connected to - pid + pid integer - The process ID of the backend. + Process ID of this backend. This value can also be returned by directly calling the pg_stat_get_backend_pid. - usesysid + usesysid oid - The id of the user logged into the backend. + OID of the user logged into this backend. This value can also be returned by directly calling the pg_stat_get_backend_userid. - usename + usename name - The name of the user logged into the backend. + Name of the user logged into this backend - application_name + application_name text - The name of the application that has initiated the connection - to the backend. + Name of the application that is connected + to this backend - client_addr + client_addr inet - The remote IP of the client connected to the backend. - If this field is not set, it indicates that the client is either connected - via a Unix socket on the server machine or is an internal process such - as autovacuum. + IP address of the client connected to this backend. + If this field is not set, it indicates either that the client is + connected via a Unix socket on the server machine or that this is an + internal process such as autovacuum. This value can also be returned by directly calling the pg_stat_get_backend_client_addr. - client_hostname + client_hostname text - - If available, the hostname of the client as reported by a - reverse lookup of client_addr. This field will - only be set when is enabled. + Host name of the connected client, as reported by a + reverse DNS lookup of client_addr. This field will + only be set for IP connections, and only when is enabled. - client_port + client_port integer - - The remote TCP port that the client is using for communication - to the backend, or NULL if a unix socket is used. + TCP port number that the client is using for communication + with the backend, or NULL if a Unix socket is used. This value can also be returned by directly calling the pg_stat_get_backend_client_port. - backend_start + backend_start timestamp with time zone - - The time when this process was started, i.e. when the + Time when this process was started, i.e., when the client connected to the server. This value can also be returned by directly calling the pg_stat_get_backend_start. - xact_start + xact_start timestamp with time zone - - The time when the current transaction was started. If the client is - using autocommit for transactions, this value is equal to the - query_start column. + Time when the current transaction was started. If the current + query is the first of its transaction, this value is equal to the + query_start column. This value can also be returned by directly calling the pg_stat_get_backend_xact_start. - query_start + query_start timestamp with time zone - - The time when the currently active query started, or if + Time when the currently active query was started, or if state is idle, when the last query was started. This value can also be returned by directly calling @@ -624,98 +572,69 @@ postgres: user database host - state_change + state_change timestamp with time zone - The time when the state was last changed. + Time when the state was last changed - waiting + waiting boolean - - Boolean indicating if a backend is currently waiting on a lock. + True if the backend is currently waiting on a lock. This value can also be returned by directly calling the pg_stat_get_backend_waiting. - state + state text - - The state of the currently running query. - Can be one of: - - - active - - - The backend is executing a query. - - - - - idle - - - There is no query executing in the backend. - - - - - idle in transaction - - - The backend is in a transaction, but is currently not currently - executing a query. - - - - - idle in transaction (aborted) - - - This state is similar to idle in transaction, - except one of the statements in the transaction caused an error. - - - - - fastpath function call - - - The backend is executing a fast-path function. - - - - - disabled - - - This state indicates that - is disabled. - - - - - - - The waiting and state columns are - independent. If a query is in the active state, - it may or may not be waiting. If a query is - active and waiting is true, it means - that the query is being executed, but is being blocked by a lock - somewhere in the system. - - + Current overall state of this backend. + Possible values are: + + + + active: The backend is executing a query. + + + + + idle: The backend is waiting for a new client command. + + + + + idle in transaction: The backend is in a transaction, + but is not currently executing a query. + + + + + idle in transaction (aborted): This state is similar to + idle in transaction, except one of the statements in + the transaction caused an error. + + + + + fastpath function call: The backend is executing a + fast-path function. + + + + + disabled: This state is reported if is disabled in this backend. + + + - query + query text - - The most recent query that the backend has executed. If - state is active this means the currently - executing query. In all other states, it means the last query that was - executed. + Text of the backend's most recent query. If + state is active this field shows the + currently executing query. In all other states, it shows the last query + that was executed. @@ -724,21 +643,20 @@ postgres: user database host The pg_stat_activity view will have one row - per server process, showing information related to each connection to - the server. + per server process, showing information related to + the current activity of that process. - - All functions used in the view are indexed by backend id number. The - function pg_stat_get_backend_idset provides a - convenient way to generate one row for each active server process. For - example, to show the PIDs and current queries of all server processes: - -SELECT pg_stat_get_backend_pid(s.backendid) AS pid, - pg_stat_get_backend_activity(s.backendid) AS query - FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s; - - + + + The waiting and state columns are + independent. If a backend is in the active state, + it may or may not be waiting. If the state is + active and waiting is true, it means + that a query is being executed, but is being blocked by a lock + somewhere in the system. + +
pg_stat_bgwriter view @@ -754,21 +672,21 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, - checkpoints_timed + checkpoints_timed bigint - Number of scheduled checkpoints. + Number of scheduled checkpoints that have been performed. This value can also be returned by directly calling the pg_stat_get_bgwriter_timed_checkpoints function. - checkpoints_requested + checkpoints_req bigint - Number of requested checkpoints. + Number of requested checkpoints that have been performed. This value can also be returned by directly calling the pg_stat_get_bgwriter_requested_checkpoints function. - checkpoint_write_time + checkpoint_write_time bigint Total amount of time that has been spent in the portion of @@ -779,7 +697,7 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, - checkpoint_sync_time + checkpoint_sync_time bigint Total amount of time that has been spent in the portion of @@ -790,21 +708,21 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, - buffers_checkpoint + buffers_checkpoint bigint Number of buffers written during checkpoints. This value can also be returned by directly calling the pg_stat_get_bgwriter_buf_written_checkpoints function. - buffers_clean + buffers_clean bigint Number of buffers written by the background writer. This value can also be returned by directly calling the pg_stat_get_bgwriter_buf_written_clean function. - maxwritten_clean + maxwritten_clean bigint Number of times the background writer stopped a cleaning scan because it had written too many buffers. @@ -812,30 +730,30 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, the pg_stat_get_bgwriter_maxwritten_clean function. - buffers_backend + buffers_backend bigint Number of buffers written directly by a backend. This value can also be returned by directly calling the pg_stat_get_buf_written_backend function. - buffers_backend_fsync + buffers_backend_fsync bigint - Number of times a backend had to execute its own fsync - call (normally the background writer handles those even when the - backend does its own write) + Number of times a backend had to execute its own + fsync call (normally the background writer handles those + even when the backend does its own write) - buffers_alloc + buffers_alloc bigint Number of buffers allocated. This value can also be returned by directly calling the pg_stat_get_buf_alloc function. - stats_reset - bigint - The last time these statistics were reset. + stats_reset + timestamp with time zone + Time at which these statistics were last reset. This value can also be returned by directly calling the pg_stat_get_bgwriter_stat_reset_time function. @@ -845,7 +763,7 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, The pg_stat_bgwriter view will always have a - single row with global data for the cluster. + single row, containing global data for the cluster.
@@ -861,151 +779,150 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, - datid + datid oid - The OID of the database + OID of a database - datname + datname name - The name of the database + Name of this database - numbackends + numbackends integer - The number of backends currently connected to this database. - This is the only column in this view that returns a value for the - current state, all other columns return the accumulated values since + Number of backends currently connected to this database. + This is the only column in this view that returns a value reflecting + current state; all other columns return the accumulated values since the last reset. This value can also be returned by directly calling the pg_stat_get_db_numbackends function. - xact_commit + xact_commit bigint - The number of transactions in this database that have been + Number of transactions in this database that have been committed. This value can also be returned by directly calling the pg_stat_get_db_xact_commit function. - xact_rollback + xact_rollback bigint - The number of transactions in this database that have been + Number of transactions in this database that have been rolled back. This value can also be returned by directly calling the pg_stat_get_db_xact_rollback function. - blks_read + blks_read bigint - The number of disk blocks read in this database. + Number of disk blocks read in this database. This value can also be returned by directly calling the pg_stat_get_db_blocks_fetched and pg_stat_get_db_blocks_hit functions and subtracting the results. - blks_hits + blks_hit bigint - The number of disk blocks read from the buffer cache - (this only includes hits in the PostgreSQL buffer cache, and not - the operating system filesystem cache). + Number of times disk blocks were found already in the buffer + cache, so that a read was not necessary (this only includes hits in the + PostgreSQL buffer cache, not the operating system's filesystem cache). This value can also be returned by directly calling the pg_stat_get_db_blocks_hit function. - tup_returned + tup_returned bigint - The number of rows returned by queries in this database. + Number of rows returned by queries in this database. This value can also be returned by directly calling the pg_stat_get_db_tuples_returned function. - tup_fetched + tup_fetched bigint - The number of rows fetched by queries in this database. + Number of rows fetched by queries in this database. This value can also be returned by directly calling the pg_stat_get_db_tuples_fetched function. - tup_inserted + tup_inserted bigint - The number of rows inserted by queries in this database. + Number of rows inserted by queries in this database. This value can also be returned by directly calling the pg_stat_get_db_tuples_inserted function. - tup_updated + tup_updated bigint - The number of rows updated by queries in this database. + Number of rows updated by queries in this database. This value can also be returned by directly calling the pg_stat_get_db_tuples_updated function. - tup_deleted + tup_deleted bigint - The number of rows deleted by queries in this database. + Number of rows deleted by queries in this database. This value can also be returned by directly calling the pg_stat_get_db_tuples_deleted function. - conflicts + conflicts bigint - - The number of queries canceled due to conflict with recovery - (on standby servers) in this database. (See - for more details). + Number of queries canceled due to conflicts with recovery + in this database. (Conflicts occur only on standby servers; see + for details.) This value can also be returned by directly calling the pg_stat_get_db_conflict_all function. - temp_files + temp_files bigint - - The number of temporary files written by queries in the database. + Number of temporary files created by queries in this database. All temporary files are counted, regardless of why the temporary file - was created (sorting or hash) or file size, and regardless of the + was created (e.g., sorting or hash), and regardless of the setting. This value can also be returned by directly calling the pg_stat_get_db_temp_files function. - temp_bytes + temp_bytes bigint - - The amount of data written to temporary files by queries in - the database. All temporary files are counted, regardless of why - the temporary file was created (sorting or hash) or file size, and + Total amount of data written to temporary files by queries in + this database. All temporary files are counted, regardless of why + the temporary file was created, and regardless of the setting. This value can also be returned by directly calling the pg_stat_get_db_temp_bytes function. - deadlocks + deadlocks bigint - Number of deadlocks detected in the database. + Number of deadlocks detected in this database. This value can also be returned by directly calling the pg_stat_get_db_deadlocks function. - block_read_time + block_read_time bigint - Time spent by backends reading data file blocks, in milliseconds. + Time spent reading data file blocks by backends in this database, + in milliseconds. The same value can be returned in microseconds by directly calling the pg_stat_get_db_block_time_read function. - block_write_time + block_write_time bigint - Time spent by backends writing data file blocks, in milliseconds. + Time spent writing data file blocks by backends in this database, + in milliseconds. The same value can be returned in microseconds by directly calling the pg_stat_get_db_block_time_write function. - stats_reset - timestamptz - The last time the statistics were reset. + stats_reset + timestamp with time zone + Time at which these statistics were last reset. This value can also be returned by directly calling the pg_stat_get_reset_time function. @@ -1015,194 +932,7 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, The pg_stat_database view will contain one row - for each database in the cluster showing database-wide statistics. - - -
- pg_stat_database_conflicts view - - - - Column - Type - Description - - - - - - datid - oid - The OID of the database - - - datname - name - The name of the database - - - confl_tablespace - bigint - The number of queries that have been canceled due to - dropped tablespaces. This value can also be returned by directly calling - the pg_stat_get_db_conflict_tablespace function. - - - confl_lock - bigint - The number of queries that have been canceled due to - lock timeouts. This value can also be returned by directly calling - the pg_stat_get_db_conflict_lock function. - - - confl_snapshot - bigint - The number of queries that have been canceled due to - old snapshots. This value can also be returned by directly calling - the pg_stat_get_db_conflict_snapshot function. - - - confl_bufferpin - bigint - The number of queries that have been canceled due to - pinned buffers. This value can also be returned by directly calling - the pg_stat_get_db_conflict_bufferpin function. - - - confl_deadlock - bigint - The number of queries that have been canceled due to - deadlocks. This value can also be returned by directly calling - the pg_stat_get_db_conflict_startup_deadlock - function. - - - -
- - - The pg_stat_database_conflicts view will contain - one row per database showing database-wide statistics about - query cancels due to conflict with recovery on standby servers. - Will only contain information on standby servers, since - conflicts do not occur on master servers. - - - - pg_stat_replication view - - - - Column - Type - Description - - - - - - pid - integer - The process id of the WAL sender process - - - usesysid - oid - The OID of the user logged into this WAL sender process - - - usename - name - The name of the user logged into this WAL sender process - - - application_name - text - The name of the application that has initiated the connection - to the WAL sender. - - - client_addr - inet - The remote IP of the client connected to the WAL sender. - If this field is not set, it indicates that the client is - connected via a Unix socket on the server machine. - - - - client_hostname - text - - If available, the hostname of the client as reported by a - reverse lookup of client_addr. This field will - only be set when is enabled. - - - - client_port - integer - - The remote TCP port that the client is using for communication - to the, or NULL if a unix socket is used. - - - - backend_start - timestamp with time zone - - The time when this process was started, i.e. when the - client connected to the WAL sender. - - - - state - text - Current WAL sender state - - - sent_location - text - Last transaction log position sent on this connection - - - write_location - text - Last transaction log position written to disk by the slave - - - flush_location - text - Last transaction log position flushed to disk by the slave - - - replay_location - text - Last transaction log position replayed into the database on the slave - - - sync_priority - int - - The priority in the order which this slave will be picked as - the synchronous standby. - - - - sync_state - text - - The synchronous state of this slave. - - - - -
- - - The pg_stat_replication view will contain one row - per WAL sender process, showing statistics about the replication to this - slave. Only directly connected standbys are listed; no information about - downstream standby servers is recorded. + for each database in the cluster, showing database-wide statistics. @@ -1218,139 +948,144 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, - relid + relid oid - The OID of the table + OID of a table - schemaname + schemaname name - The name of the schema that the table is in + Name of the schema that this table is in - relname + relname name - The name of the table + Name of this table - seq_scan + seq_scan bigint - The number of sequential scans initiated on this table. + Number of sequential scans initiated on this table. This value can also be returned by directly calling the pg_stat_get_numscans function. - seq_tup_read + seq_tup_read bigint - The number of live rows fetch by sequential scans. + Number of live rows fetched by sequential scans. This value can also be returned by directly calling the pg_stat_get_tuples_returned function. - idx_scan + idx_scan bigint - The number of index scans initiated on this table + Number of index scans initiated on this table - idx_tup_fetch + idx_tup_fetch bigint - The number of live rows fetch by index scans. + Number of live rows fetched by index scans - n_tup_ins + n_tup_ins bigint - The number of rows inserted. + Number of rows inserted. This value can also be returned by directly calling the pg_stat_get_tuples_inserted function. - n_tup_upd + n_tup_upd bigint - The number of rows updated. + Number of rows updated. This value can also be returned by directly calling the pg_stat_get_tuples_updated function. - n_tup_del + n_tup_del bigint - The number of rows deleted. + Number of rows deleted. This value can also be returned by directly calling the pg_stat_get_tuples_deleted function. - n_tup_hot_upd + n_tup_hot_upd bigint - The number of rows HOT (i.e., no separate index update) updated. + Number of rows HOT updated (i.e., with no separate index + update required). This value can also be returned by directly calling the pg_stat_get_tuples_hot_updated function. - n_live_tup + n_live_tup bigint - The number of live rows. + Estimated number of live rows. This value can also be returned by directly calling the pg_stat_get_live_tuples function. - n_dead_tup + n_dead_tup bigint - The number of dead rows. + Estimated number of dead rows. This value can also be returned by directly calling the pg_stat_get_dead_tuples function. - last_vacuum + last_vacuum timestamp with time zone - The last time the table was manually non- - last_autovacuum + last_autovacuum timestamp with time zone - The last time the table was vacuumed by the autovacuum daemon. + Last time at which this table was vacuumed by the autovacuum + daemon. This value can also be returned by directly calling the pg_stat_get_last_autovacuum_time function. - last_analyze + last_analyze timestamp with time zone - The last time the table was manually analyzed. + Last time at which this table was manually analyzed. This value can also be returned by directly calling the pg_stat_get_last_analyze_time function. - last_autoanalyze + last_autoanalyze timestamp with time zone - The last time the table was analyzed by the autovacuum daemon. + Last time at which this table was analyzed by the autovacuum + daemon. This value can also be returned by directly calling the pg_stat_get_last_autoanalyze_time function. - vacuum_count + vacuum_count bigint - The number of times this table has been manually non- + Number of times this table has been manually vacuumed + (not counting VACUUM FULL) - autovacuum_count + autovacuum_count bigint - The number of times this table has been vacuumed by the autovacuum daemon. + Number of times this table has been vacuumed by the autovacuum + daemon. This value can also be returned by directly calling the pg_stat_get_autovacuum_count function. - analyze_count + analyze_count bigint - The number of times this table has been manually analyzed. + Number of times this table has been manually analyzed. This value can also be returned by directly calling the pg_stat_get_analyze_count function. - autoanalyze_count + autoanalyze_count bigint - The number of times this table has been analyzed by the autovacuum daemon. + Number of times this table has been analyzed by the autovacuum + daemon. This value can also be returned by directly calling the pg_stat_get_autoanalyze_count function. @@ -1361,10 +1096,11 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, The pg_stat_all_tables view will contain one row for each table in the current database (including TOAST - tables) with information about accesses to this specific table. The + tables), showing statistics about accesses to that specific table. The pg_stat_user_tables and - pg_stat_sys_tables contain the same information, - but filtered to only have rows for user and system tables. + pg_stat_sys_tables views + contain the same information, + but filtered to only show user and system tables respectively.
@@ -1380,48 +1116,49 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, - relid + relid oid - The OID of the table for this index + OID of the table for this index - indexrelid + indexrelid oid - The OID of the index + OID of this index - schemaname + schemaname name - The name of the schema the index is in + Name of the schema this index is in - relname + relname name - The name of the table for this index + Name of the table for this index - indexrelname + indexrelname name - The name of the index + Name of this index - idx_scan + idx_scan bigint Number of index scans initiated on this index. This value can also be returned by directly calling the pg_stat_get_numscans function. - idx_tup_read + idx_tup_read bigint Number of index entries returned by scans on this index. This value can also be returned by directly calling the pg_stat_get_tuples_returned function. - idx_tup_fetch + idx_tup_fetch bigint - Number of live table rows fetched by simple index scans using this index. + Number of live table rows fetched by simple index scans using this + index. This value can also be returned by directly calling the pg_stat_get_tuples_fetched function. @@ -1431,13 +1168,40 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, The pg_stat_all_indexes view will contain - one row for each index in the current database - with information about accesses to this specific index. The + one row for each index in the current database, + showing statistics about accesses to that specific index. The pg_stat_user_indexes and - pg_stat_sys_indexes contain the same information, - but filtered to only have rows for user and system indexes. + pg_stat_sys_indexes views + contain the same information, + but filtered to only show user and system indexes respectively. + + Indexes can be used via either simple index scans or bitmap + index scans. In a bitmap scan + the output of several indexes can be combined via AND or OR rules, + so it is difficult to associate individual heap row fetches + with specific indexes when a bitmap scan is used. 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. + + + + + The idx_tup_read and idx_tup_fetch counts + can be different even without any use of bitmap scans, + because idx_tup_read counts + index entries retrieved from the index while idx_tup_fetch + counts live rows fetched from the table. The latter will be less if any + dead or not-yet-committed rows are fetched using the index, or if any + heap fetches are avoided by means of an index-only scan. + + +
pg_statio_all_tables view @@ -1451,23 +1215,23 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, - relid + relid oid - The OID of the table + OID of a table - schemaname + schemaname name - The name of the schema that the table is in + Name of the schema that this table is in - relname + relname name - The name of the table + Name of this table - heap_blks_read - name + heap_blks_read + bigint Number of disk blocks read from this table. This value can also be returned by directly calling the pg_stat_get_blocks_fetched and @@ -1475,40 +1239,40 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, subtracting the results. - heap_blks_hit - name + heap_blks_hit + bigint Number of buffer hits in this table. This value can also be returned by directly calling the pg_stat_get_blocks_hit function. - idx_blks_read - name + idx_blks_read + bigint Number of disk blocks read from all indexes on this table - idx_blks_hit - name - Number of buffer hits in all indexes of this table. + idx_blks_hit + bigint + Number of buffer hits in all indexes of this table - toast_blks_read - name + toast_blks_read + bigint Number of disk blocks read from this table's TOAST table (if any) - toast_blks_hit - name + toast_blks_hit + bigint Number of buffer hits in this table's TOAST table (if any) - tidx_blks_read - name + tidx_blks_read + bigint Number of disk blocks read from this table's TOAST table index (if any) - tidx_blks_hit - name + tidx_blks_hit + bigint Number of buffer hits in this table's TOAST table index (if any) @@ -1518,10 +1282,11 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, The pg_statio_all_tables view will contain one row for each table in the current database (including TOAST - tables) with information about I/O on this specific table. The + tables), showing statistics about I/O on that specific table. The pg_statio_user_tables and - pg_statio_sys_tables contain the same information, - but filtered to only have rows for user and system tables. + pg_statio_sys_tables views + contain the same information, + but filtered to only show user and system tables respectively.
@@ -1537,43 +1302,43 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, - relid + relid oid - The OID of the table for this index + OID of the table for this index - indexrelid + indexrelid oid - The OID of the index + OID of this index - schemaname + schemaname name - The name of the schema the index is in + Name of the schema this index is in - relname + relname name - The name of the table for this index + Name of the table for this index - indexrelname + indexrelname name - The name of the index + Name of this index - idx_blks_read - name - Number of disk blocks read from the index. + idx_blks_read + bigint + Number of disk blocks read from this index. This value can also be returned by directly calling the pg_stat_get_blocks_fetched and pg_stat_get_blocks_hit functions and subtracting the results. - idx_blks_hit - name - Number of buffer hits in the index. + idx_blks_hit + bigint + Number of buffer hits in this index. This value can also be returned by directly calling the pg_stat_get_blocks_hit function. @@ -1583,11 +1348,12 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, The pg_statio_all_indexes view will contain - one row for each index in the current database - with information about I/O on this specific index. The + one row for each index in the current database, + showing statistics about I/O on that specific index. The pg_statio_user_indexes and - pg_statio_sys_indexes contain the same information, - but filtered to only have rows for user and system indexes. + pg_statio_sys_indexes views + contain the same information, + but filtered to only show user and system indexes respectively.
@@ -1603,38 +1369,38 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, - relid + relid oid - The OID of the sequence + OID of a sequence - schemaname + schemaname name - The name of the schema the sequence is in + Name of the schema this sequence is in - relname + relname name - The name of the sequence + Name of this sequence - blks_read - name - Number of disk blocks read from the sequence + blks_read + bigint + Number of disk blocks read from this sequence - blks_hit - name - Number of buffer hits in the sequence + blks_hit + bigint + Number of buffer hits in this sequence
- The pg_statio_all_indexes view will contain - one row for each sequence in the current database - with information about I/O on this specific sequence. + The pg_statio_all_sequences view will contain + one row for each sequence in the current database, + showing statistics about I/O on that specific sequence. @@ -1650,39 +1416,39 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, - funcid + funcid oid - The OID of the function + OID of a function - schemaname + schemaname name - The name of the schema the function is in + Name of the schema this function is in - funcname + funcname name - The name of the function + Name of this function - calls + calls bigint - Number of times the function has been called. + Number of times this function has been called. This value can also be returned by directly calling the pg_stat_get_function_calls function. - total_time + total_time bigint - Total time spent in this functions and all other functions + Total time spent in this function and all other functions called by it, in milliseconds. The same value can be returned in microseconds by directly calling the pg_stat_get_function_time function. - self_time + self_time bigint - Total time spent in this functions itself but not including + Total time spent in this function itself, not including other functions called by it, in milliseconds. The same value can be returned in microseconds by directly calling the pg_stat_get_function_self_time function. @@ -1693,13 +1459,218 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, The pg_stat_user_functions view will contain - one row for each tracked function (as specified by the - parameter). + one row for each tracked function, showing statistics about executions of + that function. The parameter + controls exactly which functions are tracked. - - Other Statistics Functions +
+ pg_stat_replication view + + + + 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 not set, 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 set for IP connections, and only when is enabled. + + + + client_port + integer + TCP port number that the client is using for communication + with this WAL sender, or NULL 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 + + + + state + text + Current WAL sender state + + + sent_location + text + Last transaction log position sent on this connection + + + write_location + text + Last transaction log position written to disk by this standby + server + + + flush_location + text + Last transaction log position flushed to disk by this standby + server + + + replay_location + text + Last transaction log position replayed into the database on this + standby server + + + sync_priority + integer + Priority of this standby server for being chosen as the + synchronous standby + + + sync_state + text + Synchronous state of this standby server + + + +
+ + + 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. + + + + pg_stat_database_conflicts view + + + + Column + Type + Description + + + + + + datid + oid + OID of a database + + + datname + name + Name of this database + + + confl_tablespace + bigint + Number of queries in this database that have been canceled due to + dropped tablespaces. This value can also be returned by directly calling + the pg_stat_get_db_conflict_tablespace function. + + + confl_lock + bigint + Number of queries in this database that have been canceled due to + lock timeouts. This value can also be returned by directly calling + the pg_stat_get_db_conflict_lock function. + + + confl_snapshot + bigint + Number of queries in this database that have been canceled due to + old snapshots. This value can also be returned by directly calling + the pg_stat_get_db_conflict_snapshot function. + + + confl_bufferpin + bigint + Number of queries in this database that have been canceled due to + pinned buffers. This value can also be returned by directly calling + the pg_stat_get_db_conflict_bufferpin function. + + + confl_deadlock + bigint + Number of queries in this database that have been canceled due to + deadlocks. This value can also be returned by directly calling + the pg_stat_get_db_conflict_startup_deadlock + function. + + + +
+ + + The pg_stat_database_conflicts view will contain + one row per database, showing database-wide statistics about + query cancels occurring due to conflicts with recovery on standby servers. + This view will only contain information on standby servers, since + conflicts do not occur on master servers. + + + + + + Statistics Functions + + + Other ways of looking at the statistics can be set up by writing + queries that use the same underlying statistics access functions as + the standard views do. The per-database access + functions take a database OID as an argument to identify which + database to report on. The per-table and per-index functions take + a table or index OID. The functions for function-call statistics + take a function OID. (Note that only tables, indexes, and functions + in the current database can be seen with these functions.) The + per-server-process access functions take a server process + number, which ranges from one to the number of currently active + server processes. + + + + Additional functions related to statistics collection are listed in . + Other Statistics Functions @@ -1720,7 +1691,7 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, pg_backend_pid()integer - Process ID of the server process attached to the current session + Process ID of the server process handling the current session @@ -1744,12 +1715,11 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, - pg_stat_get_wal_senders() setof record - One record for each active wal sender. The fields returned are a subset + One record for each active WAL sender. The fields returned are a subset of those in the pg_stat_replication view. @@ -1775,10 +1745,10 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, pg_stat_reset_shared(text)void - Reset some of the shared statistics counters for the database cluster to - zero (requires superuser privileges). Calling - pg_stat_reset_shared('bgwriter') will zero all the values shown by - pg_stat_bgwriter. + Reset some cluster-wide statistics counters to zero, depending on the + argument (requires superuser privileges). + Calling pg_stat_reset_shared('bgwriter') will zero all the + counters shown in the pg_stat_bgwriter view. @@ -1803,7 +1773,21 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
- + + All the underlying functions of the pg_stat_activity view + require a backend ID number. + The function pg_stat_get_backend_idset provides a + convenient way to generate one row for each active server process for + invoking these functions. For example, to show the PIDs and + current queries of all server processes: + + +SELECT pg_stat_get_backend_pid(s.backendid) AS pid, + pg_stat_get_backend_activity(s.backendid) AS query + FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s; + + +