Hi

čt 30. 7. 2026 v 15:41 odesílatel MAILBOX-DBS <[email protected]>
napsal:

> Hello all
>
>
>
> pg_stat_statements does not seem to collect metrics for queries inside
> functions, in my understanding this should be possible.
>
> Is there a documentation about restrictions or has someone a clue why this
> is not working for me?
>
>
>
> Values of parameters that may influence the behaviour:
>
>
>
> shared_preload_libraries = 'pgaudit,pg_stat_statements'
>
> pg_stat_statements.track = 'all'
>
> pg_stat_statements.max = 20000
>
> track_functions = 'all'
>
>
>
> the function header:
>
> CREATE OR REPLACE FUNCTION core.sf_generic_daily_merge_landing_to_target(
>
>             p_sys_daily_load_run_key bigint)
>
>     RETURNS integer
>
>     LANGUAGE 'plpgsql'
>
>     COST 100
>
>     VOLATILE PARALLEL UNSAFE
>
> AS $BODY$
>
> Declare
>
>
>
> Best Regards
>
> Rolf
>
>
It does it - track=all surely does it.

CREATE OR REPLACE FUNCTION public.foo()
 RETURNS void
 LANGUAGE plpgsql
AS $function$declare x int;
begin
  select 1 from pg_sleep(1), pg_class limit 1 into x;
end;
$function$

select foo();

select * from pg_stat_statements;

and you should to see

2026-07-30 16:09:10) postgres=# select query, calls, total_exec_time from
pg_stat_statements where query like '%sleep%' and toplevel = 'f';
┌─[ RECORD 1 ]────┬────────────────────────────────────────────────┐
│ query           │ select $1 from pg_sleep($2), pg_class limit $3 │
│ calls           │ 1                                              │
│ total_exec_time │ 1001.123917                                    │
└─────────────────┴────────────────────────────────────────────────┘

 Regards

Pavel


>
>
> ------------------------------
>
>
>
> This message is not intended for persons who are citizens of, domiciled or
> resident in, or entities registered in a country or jurisdiction in which
> its distribution, publication, provision or use would violate current laws
> and regulations.
> The content of this message is confidential and may be read and/or used
> only by the recipient of this message. For information about personal data
> protection, please refer to the Pictet Group’s Privacy Notice available at
> https://www.group.pictet/privacynotice. If you have received this e-mail
> message in error, please destroy it and delete it from your computer.
> The Pictet Group may not be held liable for the use, transmission or
> treatment of the content of this message. The recipient of this message
> remains solely liable for any form of reproduction, copying, disclosure,
> modification and/or publication of the content. No liability whatsoever
> will be incurred by the Pictet Group. The recipient of this message agrees
> to comply with the applicable laws and regulations in the jurisdictions
> where they use the information contained herein..
>

Reply via email to