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

From: Nitin Jadhav <nitinjadhavpostgres(at)gmail(dot)com>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Bruce Momjian <bruce(at)momjian(dot)us>, Hannu Krosing <hannuk(at)google(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Michael Paquier <michael(at)paquier(dot)xyz>, torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, Atsushi Torikoshi <atorik(at)gmail(dot)com>, Tatsuro Yamada <tatsuro(dot)yamada(dot)tf(at)nttcom(dot)co(dot)jp>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, 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: 2021-04-07 12:47:11
Message-ID: CAMm1aWZRcG2OsqcvDJVCoOeUjf_G2Mh=STUpmmMj+XG87Xx8sQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> On Tue, Apr 06, 2021 at 11:41:52AM -0400, Alvaro Herrera wrote:
> > On 2021-Apr-06, Nitin Jadhav wrote:
> >
> > > I have reviewed the code. Here are a few minor comments.
> > >
> > > 1.
> > > +void
> > > +pgstat_report_queryid(uint64 queryId, bool force)
> > > +{
> > > + volatile PgBackendStatus *beentry = MyBEEntry;
> > > +
> > > + if (!beentry)
> > > + return;
> > > +
> > > + /*
> > > + * if track_activities is disabled, st_queryid should already have
> been
> > > + * reset
> > > + */
> > > + if (!pgstat_track_activities)
> > > + return;
> > >
> > > The above two conditions can be clubbed together in a single condition.
> >
> > I wonder if it wouldn't make more sense to put the assignment *after* we
> > have checked the second condition.
> All other pgstat_report_* functions do the assignment before doing any
> test on
> beentry and/or pgstat_track_activities, I think we should keep this code
> consistent.

I agree about this.

Thanks and Regards,
Nitin Jadhav

On Tue, Apr 6, 2021 at 9:18 PM Julien Rouhaud <rjuju123(at)gmail(dot)com> wrote:

> On Tue, Apr 06, 2021 at 11:41:52AM -0400, Alvaro Herrera wrote:
> > On 2021-Apr-06, Nitin Jadhav wrote:
> >
> > > I have reviewed the code. Here are a few minor comments.
> > >
> > > 1.
> > > +void
> > > +pgstat_report_queryid(uint64 queryId, bool force)
> > > +{
> > > + volatile PgBackendStatus *beentry = MyBEEntry;
> > > +
> > > + if (!beentry)
> > > + return;
> > > +
> > > + /*
> > > + * if track_activities is disabled, st_queryid should already have
> been
> > > + * reset
> > > + */
> > > + if (!pgstat_track_activities)
> > > + return;
> > >
> > > The above two conditions can be clubbed together in a single condition.
> >
> > I wonder if it wouldn't make more sense to put the assignment *after* we
> > have checked the second condition.
>
> All other pgstat_report_* functions do the assignment before doing any
> test on
> beentry and/or pgstat_track_activities, I think we should keep this code
> consistent.
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2021-04-07 12:49:17 Re: Wired if-statement in gen_partprune_steps_internal
Previous Message Nitin Jadhav 2021-04-07 12:45:27 Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activity view?