Re: [PATCH] Tracking statements entry timestamp in pg_stat_statements

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Andrei Zubkov <zubkov(at)moonset(dot)ru>, Greg Stark <stark(at)mit(dot)edu>, "Anton A(dot) Melnikov" <aamelnikov(at)inbox(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Tracking statements entry timestamp in pg_stat_statements
Date: 2022-04-02 07:24:56
Message-ID: 20220402072456.buplg3iytxg6wyt5@jrouhaud
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Apr 01, 2022 at 01:01:53PM -0700, Andres Freund wrote:
> Hi,
>
> On 2022-04-01 22:47:02 +0300, Andrei Zubkov wrote:
> > + entry = (pgssEntry *) hash_search(pgss_hash, &key, HASH_FIND, NULL);
> > +
> > + if (entry) {
> > + /* Found */
> > + if (minmax_only) {
> > + /* When requested reset only min/max statistics of an entry */
> > + entry_counters = &entry->counters;
> > + for (int kind = 0; kind < PGSS_NUMKIND; kind++)
> > + {
> > + entry_counters->max_time[kind] = 0;
> > + entry_counters->min_time[kind] = 0;
> > + }
> > + entry->minmax_stats_since = stats_reset;
> > + }
> > + else
> > + {
> > + /* Remove the key otherwise */
> > + hash_search(pgss_hash, &entry->key, HASH_REMOVE, NULL);
> > + num_remove++;
> > + }
> > + }
>
> It seems decidedly not great to have four copies of this code. It was already
> not great before, but this patch makes the duplicated section go from four
> lines to 20 or so.

+1

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2022-04-02 07:33:44 Re: Skipping logical replication transactions on subscriber side
Previous Message Julien Rouhaud 2022-04-02 07:21:50 Re: [PATCH] Tracking statements entry timestamp in pg_stat_statements