Contents
pg_stat_reset()
A function for resetting the statistics counters of the current database
pg_stat_reset()
is a system function for resetting all statistics counters for the current database to zero.
pg_stat_reset()
was added in PostgreSQL 7.3.
Usage
pg_stat_reset () → void
If track_functions is enabled, function statistics will be reset as well.
To determine the time when the statistics were last reset for a database, see the stats_reset
column in the pg_stat_database
entry for that database.
By default pg_stat_reset()
can only be executed by a superuser. Other users can be granted permission via the EXECUTE
privilege.
Change history
- PostgreSQL 7.3
- added (commit 5243f9a9)
Examples
Usage example for pg_stat_reset()
:
appdb=# SELECT count(*) FROM pg_stat_all_tables WHERE seq_scan > 0; count ------- 59 (1 row) appdb=# SELECT count(*) FROM pg_stat_user_functions; count ------- 5 (1 row) appdb=# SELECT pg_stat_reset(); pg_stat_reset --------------- (1 row) appdb=# SELECT count(*) FROM pg_stat_user_functions; count ------- 0 (1 row) appdb=# SELECT count(*) FROM pg_stat_all_tables WHERE seq_scan > 0; count ------- 3 (1 row)
Note that immediately after the statistics have been set, it's likely system catalog tables will be already accessed, meaning the window when no table statistics at all exist is very small.
References
- PostgreSQL documentation: Additional Statistics Functions