Re: pgsql: autovacuum: handle analyze for partitioned tables

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Zhihong Yu <zyu(at)yugabyte(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: autovacuum: handle analyze for partitioned tables
Date: 2021-05-13 21:33:33
Message-ID: 20210513213333.GA31073@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

New version, a bit more ambitious. I think it's better to describe
behavior for partitioned tables ahead of inheritance. Also, in the
ANALYZE reference page I split the topic in two: in one single paragraph
we now describe what happens with manual analyze for partitioned tables
and inheritance hierarchies; we describe the behavior of autovacuum in
one separate paragraph for each type of hierarchy, since the differences
are stark.

I noticed that difference while verifying the behavior that I was to
document. If you look at ANALYZE VERBOSE output, it seems a bit
wasteful:

create table part (a int) partition by list (a);
create table part0 partition of part for values in (0);
create table part1 partition of part for values in (1);
create table part23 partition of part for values in (2, 3) partition by list (a);
create table part2 partition of part23 for values in (2);
create table part3 partition of part23 for values in (3);
insert into part select g%4 from generate_series(1, 50000000) g;

analyze verbose part;

INFO: analyzing "public.part" inheritance tree
INFO: "part1": scanned 7500 of 55310 pages, containing 1695000 live rows and 0 dead rows; 7500 rows in sample, 12500060 estimated total rows
INFO: "part2": scanned 7500 of 55310 pages, containing 1695000 live rows and 0 dead rows; 7500 rows in sample, 12500060 estimated total rows
INFO: "part3": scanned 7500 of 55310 pages, containing 1695000 live rows and 0 dead rows; 7500 rows in sample, 12500060 estimated total rows
INFO: "part4": scanned 7500 of 55310 pages, containing 1695000 live rows and 0 dead rows; 7500 rows in sample, 12500060 estimated total rows
INFO: analyzing "public.part1"
INFO: "part1": scanned 30000 of 55310 pages, containing 6779940 live rows and 0 dead rows; 30000 rows in sample, 12499949 estimated total rows
INFO: analyzing "public.part2"
INFO: "part2": scanned 30000 of 55310 pages, containing 6779940 live rows and 0 dead rows; 30000 rows in sample, 12499949 estimated total rows
INFO: analyzing "public.part34" inheritance tree
INFO: "part3": scanned 15000 of 55310 pages, containing 3390000 live rows and 0 dead rows; 15000 rows in sample, 12500060 estimated total rows
INFO: "part4": scanned 15000 of 55310 pages, containing 3389940 live rows and 0 dead rows; 15000 rows in sample, 12499839 estimated total rows
INFO: analyzing "public.part3"
INFO: "part3": scanned 30000 of 55310 pages, containing 6780000 live rows and 0 dead rows; 30000 rows in sample, 12500060 estimated total rows
INFO: analyzing "public.part4"
INFO: "part4": scanned 30000 of 55310 pages, containing 6780000 live rows and 0 dead rows; 30000 rows in sample, 12500060 estimated total rows
ANALYZE

--
Álvaro Herrera Valdivia, Chile
"The eagle never lost so much time, as
when he submitted to learn of the crow." (William Blake)

Attachment Content-Type Size
0001-update-docs-on-analyze-on-partitioned-tables.patch text/x-diff 5.6 KB

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2021-05-13 23:02:23 Re: pgsql: autovacuum: handle analyze for partitioned tables
Previous Message Bruce Momjian 2021-05-13 15:45:54 pgsql: doc: PG 14 release notes, adjust updates/deletes on partitions

Browse pgsql-hackers by date

  From Date Subject
Next Message Michail Nikolaev 2021-05-13 21:37:26 Re: [PATCH] Full support for index LP_DEAD hint bits on standby
Previous Message Robert Haas 2021-05-13 21:07:31 Re: Race condition in recovery?