

When using the cumulative statistics views and functions to monitor collected data, it is important to realize that the information does not update instantaneously. Alternatively, one can build custom views using the underlying cumulative statistics functions, as discussed in Section 28.2.24. There are also several other views, listed in Table 28.2, available to show the accumulated statistics. Several predefined views, listed in Table 28.1, are available to show the current state of the system. In contrast, when starting from an unclean shutdown (e.g., after an immediate shutdown, a server crash, starting from a base backup, and point-in-time recovery), all statistics counters are reset. When a server, including a physical replica, shuts down cleanly, a permanent copy of the statistics data is stored in the pg_stat subdirectory, so that statistics can be retained across server restarts. Every PostgreSQL process collects statistics locally, then updates the shared data at appropriate intervals. (To prevent ordinary users from hiding their activity from the administrator, only superusers are allowed to change these parameters with SET.)Ĭumulative statistics are collected in shared memory. Normally these parameters are set in nf so that they apply to all server processes, but it is possible to turn them on or off in individual sessions using the SET command. The parameter track_wal_io_timing enables monitoring of WAL write times. The parameter track_io_timing enables monitoring of block read and write times.

The parameter track_functions enables tracking of usage of user-defined functions. The parameter track_counts controls whether cumulative statistics are collected about table and index accesses. The parameter track_activities enables monitoring of the current command being executed by any server process. (See Chapter 20 for details about setting configuration parameters.) This is controlled by configuration parameters that are normally set in nf. Since collection of statistics adds some overhead to query execution, the system can be configured to collect or not collect information. This facility is independent of the cumulative statistics system.Ģ8.2.1. Statistics Collection Configuration PostgreSQL also supports reporting dynamic information about exactly what is going on in the system right now, such as the exact command currently being executed by other server processes, and which other connections exist in the system. If enabled, calls to user-defined functions and the total time spent in each one are counted as well. The total number of rows in each table, and information about vacuum and analyze actions for each table are also counted. Presently, accesses to tables and indexes in both disk-block and individual-row terms are counted. PostgreSQL's cumulative statistics system supports collection and reporting of information about server activity. Statistics Collection Configuration 28.2.2.
