The pg_stat_statements PostgreSQL module provides a means for tracking execution statistics of all SQL statements executed by a server.
The module must be loaded by adding pg_stat_statements to shared_preload_libraries
in postgresql.conf
, because it requires additional shared memory. This means that a server restart is needed to add or remove the module.
The pg_stat_statements
View
The statistics gathered by the module are made available via a system view named pg_stat_statements
. This view contains one row for each distinct query, database ID, and user ID (up to the maximum number of distinct statements that the module can track).
Functions
pg_stat_statements_reset
discards all statistics gathered so far by pg_stat_statements
. By default, this function can only be executed by superusers.