Profiling a function call

Started by Tiffany Thangalmost 3 years ago4 messagesgeneral
Jump to latest
#1Tiffany Thang
tiffanythang@gmail.com

Hi,
I have a function that has been executing for a long time and not returning
any results. Wait event=NULL so it seems like it is still executing and not
waiting on any specific resources. Is there a way to profile the function
call to get an idea of what it is currently executing within the function?
All I could find in pg_stat_activity is the function is running. I want to
know what query/transaction within the function is running. Is there a way
to obtain that information?

PostgreSQL 15.2 on Linux.

Thanks.

Tiff

#2Jan Wieck
JanWieck@Yahoo.com
In reply to: Tiffany Thang (#1)
Re: Profiling a function call

On 5/20/23 00:36, Tiffany Thang wrote:

Hi,
I have a function that has been executing for a long time and not
returning any results. Wait event=NULL so it seems like it is still
executing and not waiting on any specific resources. Is there a way to
profile the function call to get an idea of what it is currently
executing within the function? All I could find in pg_stat_activity is
the function is running. I want to know what query/transaction within
the function is running. Is there a way to obtain that information?

This may give you some idea. I haven't touched or used it in many years,
but it might get you started:

https://github.com/wieck/plbacktrace

Best Regards, Jan

Show quoted text

PostgreSQL 15.2 on Linux.

Thanks.

Tiff

#3Pavel Stehule
pavel.stehule@gmail.com
In reply to: Jan Wieck (#2)
Re: Profiling a function call

ne 21. 5. 2023 v 13:30 odesílatel Jan Wieck <jan@wi3ck.info> napsal:

On 5/20/23 00:36, Tiffany Thang wrote:

Hi,
I have a function that has been executing for a long time and not
returning any results. Wait event=NULL so it seems like it is still
executing and not waiting on any specific resources. Is there a way to
profile the function call to get an idea of what it is currently
executing within the function? All I could find in pg_stat_activity is
the function is running. I want to know what query/transaction within
the function is running. Is there a way to obtain that information?

This may give you some idea. I haven't touched or used it in many years,
but it might get you started:

https://github.com/wieck/plbacktrace

plpgsql_check has integrated tracer

https://github.com/okbob/plpgsql_check#tracer

Regards

Pavel

Show quoted text

Best Regards, Jan

PostgreSQL 15.2 on Linux.

Thanks.

Tiff

#4Tiffany Thang
tiffanythang@gmail.com
In reply to: Pavel Stehule (#3)
Re: Profiling a function call

Thanks, Jan and Pavel. I will check out the tracer.

Tiff

On Sun, May 21, 2023 at 7:43 AM Pavel Stehule <pavel.stehule@gmail.com>
wrote:

Show quoted text

ne 21. 5. 2023 v 13:30 odesílatel Jan Wieck <jan@wi3ck.info> napsal:

On 5/20/23 00:36, Tiffany Thang wrote:

Hi,
I have a function that has been executing for a long time and not
returning any results. Wait event=NULL so it seems like it is still
executing and not waiting on any specific resources. Is there a way to
profile the function call to get an idea of what it is currently
executing within the function? All I could find in pg_stat_activity is
the function is running. I want to know what query/transaction within
the function is running. Is there a way to obtain that information?

This may give you some idea. I haven't touched or used it in many years,
but it might get you started:

https://github.com/wieck/plbacktrace

plpgsql_check has integrated tracer

https://github.com/okbob/plpgsql_check#tracer

Regards

Pavel

Best Regards, Jan

PostgreSQL 15.2 on Linux.

Thanks.

Tiff