Re: How Do You Associate a Query With its Invoking Procedure?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Fd Habash <fmhabash(at)gmail(dot)com>
Cc: "pgsql-performance(at)lists(dot)postgresql(dot)org" <pgsql-performance(at)lists(dot)postgresql(dot)org>
Subject: Re: How Do You Associate a Query With its Invoking Procedure?
Date: 2018-09-14 16:33:56
Message-ID: CAKFQuwYRpgK8ZZWDd5rnGadbnL721W8wt_UouY99-JvGs2pTKw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Thu, Sep 13, 2018 at 12:49 PM, Fd Habash <fmhabash(at)gmail(dot)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.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Rick Otten 2018-09-14 17:14:12 Re: How Do You Associate a Query With its Invoking Procedure?
Previous Message Fred Habash 2018-09-14 15:38:12 Re: How Do You Associate a Query With its Invoking Procedure?