From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Andrei Zubkov <zubkov(at)moonset(dot)ru> |
Cc: | Julien Rouhaud <rjuju123(at)gmail(dot)com>, 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-01 20:01:53 |
Message-ID: | 20220401200153.u33gbgt5i7knwko4@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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.
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2022-04-01 20:25:44 | Re: Can we automatically add elapsed times to tap test log? |
Previous Message | Andrei Zubkov | 2022-04-01 19:47:02 | Re: [PATCH] Tracking statements entry timestamp in pg_stat_statements |