1
- <!-- $PostgreSQL: pgsql/doc/src/sgml/monitoring.sgml,v 1.58 2008/05/07 14:41:55 mha Exp $ -->
1
+ <!-- $PostgreSQL: pgsql/doc/src/sgml/monitoring.sgml,v 1.59 2008/05/15 00:17:39 tgl Exp $ -->
2
2
3
3
<chapter id="monitoring">
4
4
<title>Monitoring Database Activity</title>
@@ -119,7 +119,8 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
119
119
server activity. Presently, the collector can count accesses to tables
120
120
and indexes in both disk-block and individual-row terms. It also tracks
121
121
total numbers of rows in each table, and the last vacuum and analyze times
122
- for each table.
122
+ for each table. It can also count calls to user-defined functions and
123
+ the total time spent in each one.
123
124
</para>
124
125
125
126
<para>
@@ -141,15 +142,19 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
141
142
142
143
<para>
143
144
The parameter <xref linkend="guc-track-counts"> controls whether
144
- information is actually sent to the collector process and thus determines
145
- whether any run-time overhead occurs for event counting.
145
+ statistics are collected about table and index accesses.
146
+ </para>
147
+
148
+ <para>
149
+ The parameter <xref linkend="guc-track-functions"> enables tracking of
150
+ usage of user-defined functions.
146
151
</para>
147
152
148
153
<para>
149
154
The parameter <xref linkend="guc-track-activities"> enables monitoring
150
155
of the current command being executed by any server process.
151
156
</para>
152
-
157
+
153
158
<para>
154
159
Normally these parameters are set in <filename>postgresql.conf</> so
155
160
that they apply to all server processes, but it is possible to turn
@@ -370,6 +375,16 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
370
375
<entry>Same as <structname>pg_statio_all_sequences</>, except that only
371
376
user sequences are shown.</entry>
372
377
</row>
378
+
379
+ <row>
380
+ <entry><structname>pg_stat_user_functions</></entry>
381
+ <entry>For all tracked functions, function OID, schema, name, number
382
+ of calls, total time, and self time. Self time is the
383
+ amount of time spent in the function itself, total time includes the
384
+ time spent in functions it called. Time values are in milliseconds.
385
+ </entry>
386
+ </row>
387
+
373
388
</tbody>
374
389
</tgroup>
375
390
</table>
@@ -429,8 +444,9 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
429
444
linkend="monitoring-stats-funcs-table">. The per-database access
430
445
functions take a database OID as argument to identify which
431
446
database to report on. The per-table and per-index functions take
432
- a table or index OID. (Note that only tables and indexes in the
433
- current database can be seen with these functions.) The
447
+ a table or index OID. The functions for function-call statistics
448
+ take a function OID. (Note that only tables, indexes, and functions
449
+ in the current database can be seen with these functions.) The
434
450
per-server-process access functions take a server process
435
451
number, which ranges from one to the number of currently active
436
452
server processes.
@@ -674,6 +690,32 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
674
690
</entry>
675
691
</row>
676
692
693
+ <row>
694
+ <entry><literal><function>pg_stat_get_function_calls</function>(<type>oid</type>)</literal></entry>
695
+ <entry><type>bigint</type></entry>
696
+ <entry>
697
+ Number of times the function has been called.
698
+ </entry>
699
+ </row>
700
+
701
+ <row>
702
+ <entry><literal><function>pg_stat_get_function_time</function>(<type>oid</type>)</literal></entry>
703
+ <entry><type>bigint</type></entry>
704
+ <entry>
705
+ Total wall clock time spent in the function, in microseconds. Includes
706
+ the time spent in functions called by this one.
707
+ </entry>
708
+ </row>
709
+
710
+ <row>
711
+ <entry><literal><function>pg_stat_get_function_self_time</function>(<type>oid</type>)</literal></entry>
712
+ <entry><type>bigint</type></entry>
713
+ <entry>
714
+ Time spent in only this function. Time spent in called functions
715
+ is excluded.
716
+ </entry>
717
+ </row>
718
+
677
719
<row>
678
720
<entry><literal><function>pg_stat_get_backend_idset</function>()</literal></entry>
679
721
<entry><type>setof integer</type></entry>
0 commit comments