Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5243f9a

Browse files
committed
Allow pg_statistics to be reset by calling pg_stat_reset().
Christopher Kings-Lynne
1 parent de9801f commit 5243f9a

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

doc/src/sgml/monitoring.sgml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/monitoring.sgml,v 1.11 2002/08/17 13:04:14 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/monitoring.sgml,v 1.12 2002/08/20 04:47:52 momjian Exp $
33
-->
44

55
<chapter id="monitoring">
@@ -519,6 +519,14 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
519519
Current query of backend process (NULL if caller is not superuser)
520520
</entry>
521521
</row>
522+
523+
<row>
524+
<entry><function>pg_stat_reset</function>()</entry>
525+
<entry><type>boolean</type></entry>
526+
<entry>
527+
Reset all currently collected statistics.
528+
</entry>
529+
</row>
522530
</tbody>
523531
</tgroup>
524532
</table>

src/backend/utils/adt/pgstatfuncs.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ extern Datum pg_stat_get_blocks_hit(PG_FUNCTION_ARGS);
2020

2121
extern Datum pg_stat_get_backend_idset(PG_FUNCTION_ARGS);
2222
extern Datum pg_backend_pid(PG_FUNCTION_ARGS);
23+
extern Datum pg_stat_reset(PG_FUNCTION_ARGS);
2324
extern Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS);
2425
extern Datum pg_stat_get_backend_dbid(PG_FUNCTION_ARGS);
2526
extern Datum pg_stat_get_backend_userid(PG_FUNCTION_ARGS);
@@ -218,6 +219,17 @@ pg_backend_pid(PG_FUNCTION_ARGS)
218219
PG_RETURN_INT32(MyProcPid);
219220
}
220221

222+
/*
223+
* Built-in function for resetting the counters
224+
*
225+
*/
226+
Datum
227+
pg_stat_reset(PG_FUNCTION_ARGS)
228+
{
229+
pgstat_reset_counters();
230+
231+
PG_RETURN_BOOL(true);
232+
}
221233

222234
Datum
223235
pg_stat_get_backend_pid(PG_FUNCTION_ARGS)

src/include/catalog/pg_proc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_proc.h,v 1.257 2002/08/20 04:45:59 momjian Exp $
10+
* $Id: pg_proc.h,v 1.258 2002/08/20 04:47:52 momjian Exp $
1111
*
1212
* NOTES
1313
* 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
27152715
DESCR("Statistics: Currently active backend IDs");
27162716
DATA(insert OID = 2026 ( pg_backend_pid PGNSP PGUID 12 f f t f s 0 23 "" pg_backend_pid - _null_ ));
27172717
DESCR("Statistics: Current backend PID");
2718+
DATA(insert OID = 2274 ( pg_stat_reset PGNSP PGUID 12 f f f f v 0 16 "" pg_stat_reset - _null_ ));
2719+
DESCR("Statistics: Reset collected statistics");
27182720
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_ ));
27192721
DESCR("Statistics: PID of backend");
27202722
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_ ));

0 commit comments

Comments
 (0)