On Sat, Jun 03, 2023 at 12:48:37PM +0530, Satalabaha Postgres wrote: > Hi Listers, > > We would like to determine how long it takes for each SQL statement to > execute within a long-running procedure. I tried to see if > pg_stat_statements could offer any insight into the matter. But I was > unable to locate any. Is this even possible?
pg_stat_statements can tell you about queries executed inside a procedure, as long as you set pg_stat_statements.track = 'all':
> unable to locate any. Is this even possible? How can we also determine the > precise SQL execution plan used when a SQL is run from an application? The > query runs without issue when we try to execute it directly, but it takes > longer to run when an application is used.