Re: Support reset of Shared objects statistics in "pg_stat_reset" function

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: Himanshu Upadhyaya <upadhyaya(dot)himanshu(at)gmail(dot)com>
Cc: b(dot)sadhu(at)gmail(dot)com, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Support reset of Shared objects statistics in "pg_stat_reset" function
Date: 2021-08-06 15:46:43
Message-ID: CAFiTN-v559pxL=GnRVzc7RVJe=s=VBtQJfHERFrb486wBpcEwQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Aug 6, 2021 at 8:53 PM Himanshu Upadhyaya
<upadhyaya(dot)himanshu(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2021-08-06 16:06:20 Re: Numeric x^y for negative x
Previous Message Himanshu Upadhyaya 2021-08-06 15:23:17 Re: Support reset of Shared objects statistics in "pg_stat_reset" function