Re: Add pg_stat_recovery system view

From: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
To: yangyz <1197620467(at)qq(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add pg_stat_recovery system view
Date: 2026-03-06 06:21:49
Message-ID: CABPTF7V6d-=qK0e5=PoVCvzDJEmc7NXVf5eOh=EA0zWYbootCA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Yuanzhuo,

Thanks for looking into it.

On Fri, Mar 6, 2026 at 1:48 PM yangyz <1197620467(at)qq(dot)com> wrote:

> I reviewed the patch you submitted and identified two issues.
>
> 1.In the Add pg_stat_recovery system view patch file, the documentation
> modification indicates that the lack of permissions only results in the
> inability
> to view a few specific columns. But the implementation of the code is:
>
> if (! has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS))
> PG_RETURN_NULL();
>
If there is no permission, return an empty line. This is inconsistent with
> the written document.
>

Yeah, this is a mismatch in the patch v3. However, it's been removed by
Michael in the commit. So it should be fine in HEAD.

> 2.In the function pg_stat_get_recovery(), the two arrays "Datum *values"
> and "bool *nulls" consist of a fixed set of seven elements, so there is no
> need for dynamic allocation.
>

For a single-row function with ~8–10 columns, saving one palloc is a
micro-optimization, not a major performance issue. I am not that sure of
the benefit it brings, still preparing a small patch to turn the palloc
into a fixed stack array.

--
Best,
Xuneng

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-03-06 06:30:17 Re: Add pg_stat_recovery system view
Previous Message Michael Paquier 2026-03-06 06:15:37 Re: Improve checks for GUC recovery_target_xid