Re: Use pgBufferUsage for block reporting in analyze - Mailing list pgsql-hackers

From Anthonin Bonnefoy
Subject Re: Use pgBufferUsage for block reporting in analyze
Date
Msg-id CAO6_XqrJbuCmpONY1jHqW4G699xtAO-LxRP=WFdBnm-g-p3fKA@mail.gmail.com
Whole thread Raw
In response to Re: Use pgBufferUsage for block reporting in analyze  (Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>)
Responses Re: Use pgBufferUsage for block reporting in analyze
List pgsql-hackers
On Tue, Jul 30, 2024 at 9:21 AM Anthonin Bonnefoy
<anthonin.bonnefoy@datadoghq.com> wrote:
> A possible change would be to pass an inh flag when an acquirefunc is
> called from acquire_inherited_sample_rows. The acquirefunc could then
> use an alternative log format to append to logbuf. This way, we could
> have a more compact format for partitioned tables.

I've just tested this, the result isn't great as it creates an
inconsistent output

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

Maybe the best approach is to always use the compact form?

INFO:  analyze of table "postgres.public.test_partition"
"test_partition_1": scanned 5 of 5 pages, containing 999 live tuples
and 0 dead tuples; 999 tuples in sample, 999 estimated total tuples
"test_partition_2": scanned 5 of 5 pages, containing 1000 live tuples
and 0 dead tuples; 1000 tuples in sample, 1000 estimated total tuples
avg read rate: 1.953 MB/s, avg write rate: 0.000 MB/s
...
INFO:  analyze of table "postgres.public.test_partition_1"
"test_partition_1": scanned 5 of 5 pages, containing 999 live tuples
and 0 dead tuples; 999 tuples in sample, 999 estimated total tuples
avg read rate: 0.000 MB/s, avg write rate: 0.000 MB/s

I've updated the patchset with those changes. 0004 introduces the
StringInfo logbuf so we can output logs as a single log and during
ANALYZE VERBOSE while using the compact form.

Regards,
Anthonin

Attachment

pgsql-hackers by date:

Previous
From: Kirill Reshke
Date:
Subject: Lack of possibility to specify CTAS TAM
Next
From: Pavel Stehule
Date:
Subject: Re: proposal: schema variables