From 93c701edc6c6f065cd25f77f63ab31aff085d6ac Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 15 May 2008 00:17:41 +0000 Subject: Add support for tracking call counts and elapsed runtime for user-defined functions. Note that because this patch changes FmgrInfo, any external C functions you might be testing with 8.4 will need to be recompiled. Patch by Martin Pihlak, some editorialization by me (principally, removing tracking of getrusage() numbers) --- doc/src/sgml/config.sgml | 18 +++++++++++++- doc/src/sgml/monitoring.sgml | 56 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 66 insertions(+), 8 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index a3fecc4934c..1961d28893a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1,4 +1,4 @@ - + Server Configuration @@ -3342,6 +3342,22 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; + + track_functions (string) + + track_functions configuration parameter + + + + Enables tracking of function call counts and time used. Specify + pl to count only procedural language functions, + all to also track SQL and C language functions. + The default is none. + Only superusers can change this setting. + + + + update_process_title (boolean) diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 069bad8dc13..5018b17c59a 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -1,4 +1,4 @@ - + Monitoring Database Activity @@ -119,7 +119,8 @@ postgres: user database host @@ -141,15 +142,19 @@ postgres: user database host The parameter controls whether - information is actually sent to the collector process and thus determines - whether any run-time overhead occurs for event counting. + statistics are collected about table and index accesses. + + + + The parameter enables tracking of + usage of user-defined functions. The parameter enables monitoring of the current command being executed by any server process. - + Normally these parameters are set in postgresql.conf so that they apply to all server processes, but it is possible to turn @@ -370,6 +375,16 @@ postgres: user database host Same as pg_statio_all_sequences, except that only user sequences are shown. + + + pg_stat_user_functions + For all tracked functions, function OID, schema, name, number + of calls, total time, and self time. Self time is the + amount of time spent in the function itself, total time includes the + time spent in functions it called. Time values are in milliseconds. + + + @@ -429,8 +444,9 @@ postgres: user database host . The per-database access functions take a database OID as argument to identify which database to report on. The per-table and per-index functions take - a table or index OID. (Note that only tables and indexes in the - current database can be seen with these functions.) The + a table or index OID. The functions for function-call statistics + take a function OID. (Note that only tables, indexes, and functions + in the current database can be seen with these functions.) The per-server-process access functions take a server process number, which ranges from one to the number of currently active server processes. @@ -674,6 +690,32 @@ postgres: user database host + + pg_stat_get_function_calls(oid) + bigint + + Number of times the function has been called. + + + + + pg_stat_get_function_time(oid) + bigint + + Total wall clock time spent in the function, in microseconds. Includes + the time spent in functions called by this one. + + + + + pg_stat_get_function_self_time(oid) + bigint + + Time spent in only this function. Time spent in called functions + is excluded. + + + pg_stat_get_backend_idset() setof integer -- cgit v1.2.3