Thread: Functions not visible in pg_stat_user_functions view
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
Bartek
Hi all,
Does anyone have an idea why it works like this?
Regards,
Bartek
On 01/29/2013 03:50 AM, Bartosz Dmytrak wrote: > 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. " > > Regards, > Bartek > -- Adrian Klaver adrian.klaver@gmail.com
2013/1/29 Adrian Klaver <adrian.klaver@gmail.com>
I am asking for info why not all functions are tracked.
Not quite sure what you are asking.
"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
Bartek
On 01/29/2013 07:36 AM, Bartosz Dmytrak wrote: > > > 2013/1/29 Adrian Klaver <adrian.klaver@gmail.com > <mailto:adrian.klaver@gmail.com>> > > > 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? > > Regards, > Bartek > -- Adrian Klaver adrian.klaver@gmail.com
2013/1/29 Adrian Klaver <adrian.klaver@gmail.com>
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
Bartosz Dmytrak wrote: > 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
2013/1/30 Albe Laurenz <laurenz.albe@wien.gv.at>
thanks a lot :)
The most likely explanation for what you observe is thatthe 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.
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