pg_stat_reset_shared()

A system function for resetting cluster-wide statistics

pg_stat_reset_shared() is a system function for resetting counter for various cluster-wide statistics.

pg_stat_reset_shared() was added in PostgreSQL 9.0.

Usage

pg_stat_reset_shared ( text ) → void

pg_stat_reset_shared() can be executed with one of the three following options:

Change history

Examples

Resetting pg_stat_archiver statistics:

postgres=# SELECT * FROM pg_stat_archiver\gx
-[ RECORD 1 ]------+------------------------------
archived_count     | 0
last_archived_wal  | 
last_archived_time | 
failed_count       | 3
last_failed_wal    | 000000010000000000000001
last_failed_time   | 2021-02-19 09:33:31.498568+01
stats_reset        | 2021-02-19 09:33:08.578549+01

postgres=# SELECT pg_stat_reset_shared('archiver');
 pg_stat_reset_shared 
----------------------
 
(1 row)

postgres=# SELECT * FROM pg_stat_archiver\gx
-[ RECORD 1 ]------+------------------------------
archived_count     | 0
last_archived_wal  | 
last_archived_time | 
failed_count       | 0
last_failed_wal    | 
last_failed_time   | 
stats_reset        | 2021-02-19 09:33:41.615664+01

Attempting to reset an invalid statistic type:

postgres=# SELECT pg_stat_reset_shared('foo');
ERROR:  unrecognized reset target: "foo"
HINT:  Target must be "archiver", "bgwriter" or "wal".

Categories

Server statistics, System function

See also

pg_stat_reset(), pg_stat_reset_single_function_counters(), pg_stat_reset_single_table_counters(), pg_stat_reset_slru(), pg_stat_reset_replication_slot()