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

From: Roman Konoval <rkonoval(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 18:18:55
Message-ID: F79E3A5A-871A-43BB-A372-CA47263303CE@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

If you can change the application then one option is to set application_name so that it contains API function name. This should happen before the first call in API function hits the database. After the API function finishes it should reset application_name.

Then you can enable logging of all queries and set the format to include application_name parameter. This way every query is logged and each log entry has an application name.

Several things to keep in mind:
1. logging everything may affect performance
2. application_name is 64 chars by default

Regards,
Roman Konoval
rkonoval(at)gmail(dot)com

> On Sep 13, 2018, at 21:49, 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?
>
>
> ----------------
> Thank you

In response to

Browse pgsql-performance by date

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