Allow pg_statistics to be reset by calling pg_stat_reset().
authorBruce Momjian <bruce@momjian.us>
Tue, 20 Aug 2002 04:47:52 +0000 (04:47 +0000)
committerBruce Momjian <bruce@momjian.us>
Tue, 20 Aug 2002 04:47:52 +0000 (04:47 +0000)
Christopher Kings-Lynne

doc/src/sgml/monitoring.sgml
src/backend/utils/adt/pgstatfuncs.c
src/include/catalog/pg_proc.h

index 1b063129fc78c08683036d8c29a79f9d01432294..e759789c1f44ae95c7df3a65e48e5e29e83cc546 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$Header: /cvsroot/pgsql/doc/src/sgml/monitoring.sgml,v 1.11 2002/08/17 13:04:14 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/monitoring.sgml,v 1.12 2002/08/20 04:47:52 momjian Exp $
 -->
 
 <chapter id="monitoring">
@@ -519,6 +519,14 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
        Current query of backend process (NULL if caller is not superuser)
       </entry>
      </row>
+
+     <row>
+      <entry><function>pg_stat_reset</function>()</entry>
+      <entry><type>boolean</type></entry>
+      <entry>
+       Reset all currently collected statistics.
+      </entry>
+     </row>
     </tbody>
    </tgroup>
   </table>
index 2d7054327a7b6aeaa60a0d06af11c121aa4cca77..8e36b0014043bd7f71df9697378bcabc0369669f 100644 (file)
@@ -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)
index a186cb0825603be77b6cd0a06d8e147feec675bf..e0ac00720d5d2a90103e880720c4332f5cddfb05 100644 (file)
@@ -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_ ));