19.9. Run-time Statistics
19.9.1. Query and Index Statistics Collector
These parameters control server-wide statistics collection features.
When statistics collection is enabled, the data that is produced can be
accessed via the
pg_statio family of system views.
Refer to Chapter 27 for more information.
Enables the collection of information on the currently executing command of each session, along with the time when that command began execution. This parameter is on by default. Note that even when enabled, this information is not visible to all users, only to superusers and the user owning the session being reported on, so it should not represent a security risk. Only superusers can change this setting.
Specifies the amount of memory reserved to store the text of the currently executing command for each active session, for the
queryfield. If this value is specified without units, it is taken as bytes. The default value is 1024 bytes. This parameter can only be set at server start.
Enables collection of statistics on database activity. This parameter is on by default, because the autovacuum daemon needs the collected information. Only superusers can change this setting.
Enables timing of database I/O calls. This parameter is off by default, because it will repeatedly query the operating system for the current time, which may cause significant overhead on some platforms. You can use the pg_test_timing tool to measure the overhead of timing on your system. I/O timing information is displayed in
pg_stat_database, in the output of EXPLAIN when the
BUFFERSoption is used, and by pg_stat_statements. Only superusers can change this setting.
Enables tracking of function call counts and time used. Specify
plto track only procedural-language functions,
allto also track SQL and C language functions. The default is
none, which disables function statistics tracking. Only superusers can change this setting.
SQL-language functions that are simple enough to be “inlined” into the calling query will not be tracked, regardless of this setting.
Sets the directory to store temporary statistics data in. This can be a path relative to the data directory or an absolute path. The default is
pg_stat_tmp. Pointing this at a RAM-based file system will decrease physical I/O requirements and can lead to improved performance. This parameter can only be set in the
postgresql.conffile or on the server command line.
19.9.2. Statistics Monitoring
For each query, output performance statistics of the respective module to the server log. This is a crude profiling instrument, similar to the Unix
getrusage()operating system facility.
log_statement_statsreports total statement statistics, while the others report per-module statistics.
log_statement_statscannot be enabled together with any of the per-module options. All of these options are disabled by default. Only superusers can change these settings.