Re: How Do You Associate a Query With its Invoking Procedure? - Mailing list pgsql-performance

From David G. Johnston
Subject Re: How Do You Associate a Query With its Invoking Procedure?
Date
Msg-id CAKFQuwYRpgK8ZZWDd5rnGadbnL721W8wt_UouY99-JvGs2pTKw@mail.gmail.com
Whole thread Raw
In response to How Do You Associate a Query With its Invoking Procedure?  (Fd Habash <fmhabash@gmail.com>)
Responses Re: How Do You Associate a Query With its Invoking Procedure?
List pgsql-performance
On Thu, Sep 13, 2018 at 12:49 PM, Fd Habash <fmhabash@gmail.com> wrote:

In API function may invoke 10 queries. Ideally, I would like to know what queries are invoked by it and how long each took.

 

I’m using pg_stat_statement. I can see the API function statement, but how do I deterministically identify all queries invoked by it?


pg_stat_statement is a global tracker that throws away execution context, in this case the process id, needed to track the level of detail you desire.  I think the best you can do is log all statements and durations to the log file and parse that.

For the "what queries are invoked by it" you can just read the source code...

As there is no canned solution to provide the answer you seek the final solution you come up with will be influenced by your access patterns, specific needs, and (in)ability to write C code (though maybe there is an extension out there you could leverage...).

David J.

pgsql-performance by date:

Previous
From: Fred Habash
Date:
Subject: Re: How Do You Associate a Query With its Invoking Procedure?
Next
From: Rick Otten
Date:
Subject: Re: How Do You Associate a Query With its Invoking Procedure?