Discussion:
Functions not visible in pg_stat_user_functions view
(too old to reply)
Bartosz Dmytrak
2013-01-18 09:20:52 UTC
Permalink
Hi all,
I've notice not all my functions are tracked by pg_stat_user_functions view.
Interesting thing is similar functions in different db are tracked
correctly.

query:
SELECT p.* FROM pg_proc p
LEFT JOIN pg_stat_user_functions stat
ON (p.OID = stat.funcid)
INNER JOIN pg_language l
ON (l.oid = p.prolang)
WHERE stat.funcid IS NULL AND l.lanname = 'plpgsql'

gives non null output (50 rows in my case)
I am aware internal functions are not tracked, but in my case there are
user defined functions all written in plpgsql

any ideas?

params:
track_functions=all
PostgreSQL v. 9.2.2 on Windows 2008R2 (64bit)


Regards,
Bartek
Adrian Klaver
2013-01-29 15:28:52 UTC
Permalink
Post by Bartosz Dmytrak
Hi all,
Does anyone have an idea why it works like this?
Not quite sure what you are asking. On the assumption that functions are
not showing up in the view, have you checked:

http://www.postgresql.org/docs/9.2/static/runtime-config-statistics.html#GUC-TRACK-FUNCTIONS
"
track_functions (enum)
Enables tracking of function call counts and time used. Specify pl to
track only procedural-language functions, all to also track SQL and C
language functions. The default is none, which disables function
statistics tracking. Only superusers can change this setting.

Note: SQL-language functions that are simple enough to be "inlined" into
the calling query will not be tracked, regardless of this setting.
"
Post by Bartosz Dmytrak
Regards,
Bartek
--
Adrian Klaver
***@gmail.com
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Bartosz Dmytrak
2013-01-29 15:36:27 UTC
Permalink
Post by Adrian Klaver
Not quite sure what you are asking.
I am asking for info why not all functions are tracked.
"All" - I mean plpgsql functions. Just like I said before, I am aware not
all functions all tracked but my functions (written in plpgsql) should be.

Regards,
Bartek
Adrian Klaver
2013-01-29 15:46:12 UTC
Permalink
Post by Adrian Klaver
Not quite sure what you are asking.
I am asking for info why not all functions are tracked.
"All" - I mean plpgsql functions. Just like I said before, I am aware
not all functions all tracked but my functions (written in plpgsql)
should be.
Are they never tracked or just sometimes?
Is it particular functions or random?
Post by Adrian Klaver
Regards,
Bartek
--
Adrian Klaver
***@gmail.com
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Bartosz Dmytrak
2013-01-30 07:57:55 UTC
Permalink
Post by Adrian Klaver
Post by Adrian Klaver
Are they never tracked or just sometimes?
Is it particular functions or random?
and this is strange for me.
I have few DBs with the same function (copy -> paste), in one DB they are
tracked (visible in pg_stat_user_functions) in other not. In DB where some
functions are not tracked, others are visible - no issue. I cannot find any
logical connection between function structure and visibility in
pg_stat_user_functions.

Regards,
Bartek
Albe Laurenz
2013-01-30 08:35:48 UTC
Permalink
Post by Adrian Klaver
and this is strange for me.
I have few DBs with the same function (copy -> paste), in one DB they are tracked (visible in
pg_stat_user_functions) in other not. In DB where some functions are not tracked, others are visible -
no issue. I cannot find any logical connection between function structure and visibility in
pg_stat_user_functions.
If you look at the definition of pg_stat_user_functions,
you'll notice that it shows only functions for which
pg_stat_get_function_calls(oid) IS NOT NULL.

The most likely explanation for what you observe is that
the functions have never been called since track_functions
has been set to "all".

You can see if that is indeed the reason by calling one
of your "invisible" functions and see if it becomes
visible afterwards.

Yours,
Laurenz Albe
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Bartosz Dmytrak
2013-01-30 08:57:54 UTC
Permalink
Post by Albe Laurenz
The most likely explanation for what you observe is that
the functions have never been called since track_functions
has been set to "all".
You can see if that is indeed the reason by calling one
of your "invisible" functions and see if it becomes
visible afterwards.
thanks a lot :)
works as described.

I think it is good idea to extend description in doc (
http://www.postgresql.org/docs/9.2/static/monitoring-stats.html#PG-STAT-USER-FUNCTIONS-VIEW)
to cover this case.

again: thank You very much for help.

Regards,
Bartek

Loading...