On Fri, Aug 6, 2021 at 8:53 PM Himanshu Upadhyaya
<upadhyaya.himanshu@gmail.com> wrote:
>
> Hi Sadhu,
>
> Patch working as expected with shared tables, just one Minor comment on the patch.
> + if (!dbentry)
> + return;
> +
> + /*
> + * We simply throw away all the shared table entries by recreating new
> + * hash table for them.
> + */
> + if (dbentry->tables != NULL)
> + hash_destroy(dbentry->tables);
> + if (dbentry->functions != NULL)
> + hash_destroy(dbentry->functions);
> +
> + dbentry->tables = NULL;
> + dbentry->functions = NULL;
> +
> + /*
> + * This creates empty hash tables for tables and functions.
> + */
> + reset_dbentry_counters(dbentry);
>
> We already have the above code for non-shared tables, can we restrict duplicate code?
> one solution I can think of, if we can have a list with two elements and iterate each element with
> these common steps?
Another idea could be that instead of putting this logic in
pgstat_recv_resetcounter(), we can have this logic in pg_stat_reset()
or maybe in pgstat_reset_counters(). So now
pgstat_recv_resetcounter() logic remain the same and I think that
logic is much cleaner i.e. whatever dobid it got in the message it
will reset stat for that dboid.
So now, if it depends upon the logic of the callers that what they
want to do so in this case pgstat_recv_resetcounter(), can send two
messages one for MyDatabaseOid which it is already doing, and another
message for the InvalidOid.
--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com