Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activityview? - Mailing list pgsql-hackers

From Julien Rouhaud
Subject Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activityview?
Date
Msg-id CAOBaU_aPixr3sj8Ov7o4eToOdA0f68ZV+Z4drn2LHn4QJTj8Tg@mail.gmail.com
Whole thread Raw
In response to Re: Feature improvement: can we add queryId forpg_catalog.pg_stat_activity view?  (Andres Freund <andres@anarazel.de>)
Responses Re: Feature improvement: can we add queryId forpg_catalog.pg_stat_activity view?
Re: Feature improvement: can we add queryId forpg_catalog.pg_stat_activity view?
List pgsql-hackers
On Thu, Aug 1, 2019 at 11:05 PM Andres Freund <andres@anarazel.de> wrote:
>
> I'm actually quite unconvinced that it's sensible to update the global
> value for nested queries. That'll mean e.g. the log_line_prefix and
> pg_stat_activity values are most of the time going to be bogus while
> nested, because the querystring that's associated with those will *not*
> be the value that the queryid corresponds to. elog.c uses
> debug_query_string to log the statement, which is only updated for
> top-level queries (outside of some exceptions like parallel workers for
> parallel queries in a function or stuff like that). And pg_stat_activity
> is also only updated for top level queries.

Having the nested queryid seems indeed quite broken for
log_line_prefix.  However having the nested queryid in
pg_stat_activity would be convenient to track what is a long stored
functions currently doing.  Maybe we could expose something like
top_level_queryid and current_queryid instead?



pgsql-hackers by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: The unused_oids script should have a reminder to use the8000-8999 OID range
Next
From: Konstantin Knizhnik
Date:
Subject: Re: [HACKERS] Cached plans and statement generalization