Re: unreliable behaviour of track_functions
От | Adrian Klaver |
---|---|
Тема | Re: unreliable behaviour of track_functions |
Дата | |
Msg-id | 370eb893-48e8-8fa2-9ecf-c3e77e74cdc1@aklaver.com обсуждение исходный текст |
Ответ на | Re: unreliable behaviour of track_functions (pinker <pinker@onet.eu>) |
Список | pgsql-general |
On 04/01/2018 06:02 AM, pinker wrote: > I mean this part describing track_function: > > https://www.postgresql.org/docs/10/static/runtime-config-statistics.html > > 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. > > Only case described here, that exclude function from being tracked it's > inlining, not the time and not the place in the query. The below might help: https://wiki.postgresql.org/wiki/Inlining_of_SQL_functions In particular for your second case(place in query): " Table functions A table function call is any instance where func(args) appears where a table is expected. (This is, for most functions, a PostgreSQL extension to the SQL standard.) For example: select * from func(123); " For your first case: Inlining conditions for scalar functions "the function body consists of a single, simple, SELECT expression" So from your OP: CREATE FUNCTION a(a bigint) RETURNS bigint STABLE LANGUAGE SQL AS $$ SELECT $1 $$; If you change to: CREATE FUNCTION a(a bigint) RETURNS bigint STABLE LANGUAGE SQL AS $$ SELECT 'test'; SELECT $1 $$; then before change: test=> select * from pg_stat_user_functions ; funcid | schemaname | funcname | calls | total_time | self_time ---------+------------+----------+-------+------------+----------- 1386647 | public | a | 2 | 1251.598 | 1251.598 (1 row) after change: test=> select * from pg_stat_user_functions ; funcid | schemaname | funcname | calls | total_time | self_time ---------+------------+----------+-------+------------+----------- 1386647 | public | a | 3 | 1251.682 | 1251.682 > So I would expect that pg_stat_user_function will show me that my function > was executed. Good that are other ways to do it, but changing > track_functions to 'all' I would expect all calls will be tracked... > > > > -- > Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html > > -- Adrian Klaver adrian.klaver@aklaver.com
В списке pgsql-general по дате отправления: