Re: Avoid double lookup in pgstat_fetch_stat_tabentry() - Mailing list pgsql-hackers

From Bharath Rupireddy
Subject Re: Avoid double lookup in pgstat_fetch_stat_tabentry()
Date
Msg-id CALj2ACUC28N-aUrQJDVt3RrJhDWG56fg9M2w8ord_s-7rWh6kQ@mail.gmail.com
Whole thread Raw
In response to Avoid double lookup in pgstat_fetch_stat_tabentry()  ("Drouvot, Bertrand" <bertranddrouvot.pg@gmail.com>)
Responses Re: Avoid double lookup in pgstat_fetch_stat_tabentry()
List pgsql-hackers
On Fri, Nov 18, 2022 at 10:32 AM Drouvot, Bertrand
<bertranddrouvot.pg@gmail.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. 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.

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



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Assertion failure in SnapBuildInitialSnapshot()
Next
From: Peter Smith
Date:
Subject: Re: Perform streaming logical transactions by background workers and parallel apply