pg_stat_reset_single_function_counters()

A function resettting the statistics of a function

pg_stat_reset_single_function_counters() is a system function  for resetting the statistics for a function to zero.

pg_stat_reset_single_function_counters() was added in PostgreSQL 9.0.

Usage

pg_stat_reset_single_function_counters ( oid ) → void

No error is raised if an invalid OID is provided.

By default pg_stat_reset_single_function_counters() can only be executed by a superuser. Other users can be granted permission via the EXECUTE privilege.

Change history

Examples

Basic usage example for pg_stat_reset_single_function_counters():

appdb=# SELECT * FROM pg_stat_user_functions WHERE funcname = 'object_property_value';
 funcid | schemaname |       funcname        |  calls   | total_time  |  self_time  
--------+------------+-----------------------+----------+-------------+-------------
  16749 | app        | object_property_value | 56898312 | 2283753.382 | 2283753.382
(1 row)

appdb=# SELECT pg_stat_reset_single_function_counters('app.object_property_value'::regproc);
 pg_stat_reset_single_function_counters 
----------------------------------------
 
(1 row)

appdb=# SELECT * FROM pg_stat_user_functions WHERE funcname = 'object_property_value';
 funcid | schemaname | funcname | calls | total_time | self_time 
--------+------------+----------+-------+------------+-----------
(0 rows)

Note that successful execution of pg_stat_reset_single_function_counters() means the pg_stat_user_functions will no longer contain an entry for that function.

Providing an invalid OID does not result in an error being raised or any other kind of warning:

epp=# SELECT pg_stat_reset_single_function_counters(-1);
 pg_stat_reset_single_function_counters 
----------------------------------------
 
(1 row)

Categories

Server statistics, System function

See also

pg_stat_reset(), pg_stat_reset_shared(), pg_stat_reset_single_table_counters(), pg_stat_reset_slru(), pg_stat_reset_replication_slot()