Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5243f9a

Browse files
committed
Allow pg_statistics to be reset by calling pg_stat_reset().
Christopher Kings-Lynne
1 parentde9801f commit5243f9a

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/2004: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
externDatumpg_stat_get_backend_idset(PG_FUNCTION_ARGS);
2222
externDatumpg_backend_pid(PG_FUNCTION_ARGS);
23+
externDatumpg_stat_reset(PG_FUNCTION_ARGS);
2324
externDatumpg_stat_get_backend_pid(PG_FUNCTION_ARGS);
2425
externDatumpg_stat_get_backend_dbid(PG_FUNCTION_ARGS);
2526
externDatumpg_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_idsetPGNSP PGUID 12 f f t t s 0
27152715
DESCR("Statistics: Currently active backend IDs");
27162716
DATA(insertOID=2026 (pg_backend_pidPGNSPPGUID12fftfs023""pg_backend_pid-_null_ ));
27172717
DESCR("Statistics: Current backend PID");
2718+
DATA(insertOID=2274 (pg_stat_resetPGNSPPGUID12ffffv016""pg_stat_reset-_null_ ));
2719+
DESCR("Statistics: Reset collected statistics");
27182720
DATA(insertOID=1937 (pg_stat_get_backend_pidPGNSPPGUID12fftfs123"23"pg_stat_get_backend_pid-_null_ ));
27192721
DESCR("Statistics: PID of backend");
27202722
DATA(insertOID=1938 (pg_stat_get_backend_dbidPGNSPPGUID12fftfs126"23"pg_stat_get_backend_dbid-_null_ ));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp