Re: Use pgBufferUsage for block reporting in analyze

From: Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Karina Litskevich <litskevichkarina(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Use pgBufferUsage for block reporting in analyze
Date: 2024-07-29 07:11:52
Message-ID: CAO6_XqrnqcLOZgR1sWpNCBwCBkUx3AmFgNtz5=KF2or7Z=bzjg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Jul 27, 2024 at 12:35 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
> An alternative idea would
> be to pass StringInfo to AcquireSampleRowsFunc() so that callback can
> write its messages there. This is somewhat similar to what we do in
> the EXPLAIN command (cf, ExplainPropertyText() etc). It could be too
> much but I think it could be better than writing logs in the single
> format.

I've tested this approach, it definitely looks better. I've added a
logbuf StringInfo to AcquireSampleRowsFunc which will receive the
logs. elevel was removed as it is not used anymore. Since everything
is in the same log line, I've removed the relation name in the acquire
sample functions.

For partitioned tables, I've also added the processed partition table
being sampled. The output will look like:

INFO: analyze of table "postgres.public.test_partition"
Sampling rows from child "public.test_partition_1"
pages: 5 of 5 scanned
tuples: 999 live tuples, 0 are dead; 999 tuples in sample, 999
estimated total tuples
Sampling rows from child "public.test_partition_2"
pages: 5 of 5 scanned
tuples: 1000 live tuples, 0 are dead; 1000 tuples in sample, 1000
estimated total tuples
avg read rate: 2.604 MB/s, avg write rate: 0.000 MB/s
...

For a file_fdw, the output will be:

INFO: analyze of table "postgres.public.pglog"
tuples: 60043 tuples; 30000 tuples in sample
avg read rate: 0.000 MB/s, avg write rate: 0.000 MB/s
...

Regards,
Anthonin

Attachment Content-Type Size
v4-0002-Output-buffer-and-wal-usage-with-verbose-analyze.patch application/octet-stream 5.9 KB
v4-0001-Use-pgBufferUsage-for-block-reporting-in-analyze.patch application/octet-stream 9.8 KB
v4-0003-Pass-StringInfo-logbuf-to-AcquireSampleFunc.patch application/octet-stream 13.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Zhijie Hou (Fujitsu) 2024-07-29 06:14:30 RE: Conflict detection and logging in logical replication