Re: Per backend relation statistics tracking

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Per backend relation statistics tracking
Date: 2025-08-26 09:44:08
Message-ID: aK2B6Fn86NFWP73k@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Tue, Aug 26, 2025 at 06:38:41AM +0000, Bertrand Drouvot wrote:
> Hi,
>
> On Mon, Aug 25, 2025 at 08:28:04PM -0400, Andres Freund wrote:
> > I don't like that this basically doubles the overhead of keeping stats by
> > tracking everythign twice. The proper solution is to do that not in the hot
> > path (i.e. in scans), but when summarizing stats to be flushed to the shared
> > stats.
>
> I do agree, like when the relations stats are flushed then we do update the
> database ones too. I'll use the same approach in the next revision.

Something along the lines like in the attached (I'm just providing 0001 here,
will do the others if we agree on the proposal)?

Remark: We could avoid the new branch in pgstat_relation_flush_cb() if we split
tables and indexes stats, but I don't think that should be a blocker for per
backend relations stats.

Regards,

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

Attachment Content-Type Size
v2-0001-Adding-per-backend-relation-statistics-tracking.patch text/x-diff 6.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2025-08-26 09:44:59 Re: Report reorder buffer size
Previous Message Andrey Borodin 2025-08-26 09:40:03 [WiP] B-tree page merge during vacuum to reduce index bloat