Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activity view?

From: Julien Rouhaud <julien(dot)rouhaud(at)free(dot)fr>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Evgeny Efimkin <efimkin(at)yandex-team(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activity view?
Date: 2019-11-29 08:39:09
Message-ID: CAOBaU_Z-aXmCStY1DumXo_fbc3eAMwUYw2QjV8NpAS6DVc7J6A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 29, 2019 at 7:21 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Fri, Nov 29, 2019 at 03:19:49PM +0900, Michael Paquier wrote:
> > On Wed, Nov 13, 2019 at 12:53:09PM +0100, Julien Rouhaud wrote:
> >> I'd really like to have the queryid function available through SQL,
> >> but I think that this specific case wouldn't work very well for
> >> pg_stat_statements' approach as it's working with oid. The query
> >> string in pg_stat_activity is the user provided one rather than a
> >> fully-qualified version, so in order to get that query's queryid, you
> >> need to know the exact search_path in use in that backend, and that's
> >> not something available.
> >
> > Yeah.. So, we have a patch marked as ready for committer here, and it
> > seems to me that we have a couple of issues to discuss more about
> > first particularly this query ID of 0. Again, do others have more
> > any input to offer?

I just realized that with current infrastructure it's not possible to
display a utility queryid. We need to recognize utility to not
process the counters twice (once in processUtility, once in the
underlying executor), so we don't provide a queryid for utility
statements in parse analysis. Current magic value 0 has the side
effect of showing an invalid queryid for all utilty statements, and
using a magic value different from 0 will just always display that
magic value. We could instead add another field in the Query and
PlannedStmt structs, say "int queryid_flags", that extensions could
use for their needs?

> And while on it, the latest patch does not apply, so a rebase is
> needed here.

Yep, I noticed that this morning. I already rebased the patch
locally, I'll send a new version with new modifications when we reach
an agreement on the utility issue.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Luis Carril 2019-11-29 08:40:38 Re: Option to dump foreign data in pg_dump
Previous Message Yugo Nagata 2019-11-29 08:33:28 Re: Implementing Incremental View Maintenance