Re: Avoid double lookup in pgstat_fetch_stat_tabentry()

From: "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Avoid double lookup in pgstat_fetch_stat_tabentry()
Date: 2022-11-18 10:09:43
Message-ID: 2e4a0ae1-2696-9f0c-301c-2330e447133f@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 11/18/22 7:06 AM, Bharath Rupireddy wrote:
> On Fri, Nov 18, 2022 at 10:32 AM Drouvot, Bertrand
> <bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
>>
>> Hi hackers,
>>
>> Please find attached a patch proposal to avoid 2 calls to
>> pgstat_fetch_stat_tabentry_ext() in pgstat_fetch_stat_tabentry() in case
>> the relation is not a shared one and no statistics are found.
>>
>> Thanks Andres for the suggestion done in [1].
>>
>> [1]:
>> https://www.postgresql.org/message-id/20221116201202.3k74ajawyom2c3eq%40awork3.anarazel.de
>
> +1. The patch LGTM.

Thanks for looking at it!

> However, I have a suggestion to simplify it
> further by getting rid of the local variable tabentry and just
> returning pgstat_fetch_stat_tabentry_ext(IsSharedRelation(relid),
> relid);. Furthermore, the pgstat_fetch_stat_tabentry() can just be a
> static inline function.
Good point. While at it, why not completely get rid of
pgstat_fetch_stat_tabentry_ext(), like in v2 the attached?

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v2-0001-pgstat_fetch_stat_tabentry-avoid_double_lookup.patch text/plain 11.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2022-11-18 10:25:00 Re: when the startup process doesn't (logging startup delays)
Previous Message Pavel Stehule 2022-11-18 09:41:35 Re: Patch: Global Unique Index