pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Roman Konoval <rkonoval@gmail.com>
To: Fd Habash <fmhabash@gmail.com>
Cc: pgsql-performance@lists.postgresql.org <pgsql-performance@lists.postgresql.org>
Subject: Re: How Do You Associate a Query With its Invoking Procedure?
Date: Fri, 14 Sep 2018 20:18:55 +0200
Message-ID: <F79E3A5A-871A-43BB-A372-CA47263303CE@gmail.com> (raw)
In-Reply-To: <5b9abf54.1c69fb81.8e0e4.9e2d@mx.google.com>
References: <5b9abf54.1c69fb81.8e0e4.9e2d@mx.google.com>

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@gmail.com


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

view thread (7+ messages)  latest in thread

Message-ID: <F79E3A5A-871A-43BB-A372-CA47263303CE@gmail.com>
Permalink:  ../F79E3A5A-871A-43BB-A372-CA47263303CE@gmail.com/
Also on:    postgresql.org/message-id/F79E3A5A-871A-43BB-A372-CA47263303CE@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: rkonoval@gmail.com, fmhabash@gmail.com, pgsql-performance@lists.postgresql.org
  Subject: Re: How Do You Associate a Query With its Invoking Procedure?
  In-Reply-To: <F79E3A5A-871A-43BB-A372-CA47263303CE@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox