From 5243f9a9988c02ba5ed496fcc5067f13e7157fa6 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 20 Aug 2002 04:47:52 +0000 Subject: [PATCH] Allow pg_statistics to be reset by calling pg_stat_reset(). Christopher Kings-Lynne --- doc/src/sgml/monitoring.sgml | 10 +++++++++- src/backend/utils/adt/pgstatfuncs.c | 12 ++++++++++++ src/include/catalog/pg_proc.h | 4 +++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 1b063129fc..e759789c1f 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -1,5 +1,5 @@ @@ -519,6 +519,14 @@ postgres: user database host + + + pg_stat_reset() + boolean + + Reset all currently collected statistics. + + diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 2d7054327a..8e36b00140 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -20,6 +20,7 @@ extern Datum pg_stat_get_blocks_hit(PG_FUNCTION_ARGS); extern Datum pg_stat_get_backend_idset(PG_FUNCTION_ARGS); extern Datum pg_backend_pid(PG_FUNCTION_ARGS); +extern Datum pg_stat_reset(PG_FUNCTION_ARGS); extern Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS); extern Datum pg_stat_get_backend_dbid(PG_FUNCTION_ARGS); extern Datum pg_stat_get_backend_userid(PG_FUNCTION_ARGS); @@ -218,6 +219,17 @@ pg_backend_pid(PG_FUNCTION_ARGS) PG_RETURN_INT32(MyProcPid); } +/* + * Built-in function for resetting the counters + * + */ +Datum +pg_stat_reset(PG_FUNCTION_ARGS) +{ + pgstat_reset_counters(); + + PG_RETURN_BOOL(true); +} Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS) diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index a186cb0825..e0ac00720d 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_proc.h,v 1.257 2002/08/20 04:45:59 momjian Exp $ + * $Id: pg_proc.h,v 1.258 2002/08/20 04:47:52 momjian Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -2715,6 +2715,8 @@ DATA(insert OID = 1936 ( pg_stat_get_backend_idset PGNSP PGUID 12 f f t t s 0 DESCR("Statistics: Currently active backend IDs"); DATA(insert OID = 2026 ( pg_backend_pid PGNSP PGUID 12 f f t f s 0 23 "" pg_backend_pid - _null_ )); DESCR("Statistics: Current backend PID"); +DATA(insert OID = 2274 ( pg_stat_reset PGNSP PGUID 12 f f f f v 0 16 "" pg_stat_reset - _null_ )); +DESCR("Statistics: Reset collected statistics"); DATA(insert OID = 1937 ( pg_stat_get_backend_pid PGNSP PGUID 12 f f t f s 1 23 "23" pg_stat_get_backend_pid - _null_ )); DESCR("Statistics: PID of backend"); DATA(insert OID = 1938 ( pg_stat_get_backend_dbid PGNSP PGUID 12 f f t f s 1 26 "23" pg_stat_get_backend_dbid - _null_ ));