Re: ANALYZE ONLY

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Michael Harris <harmic(at)gmail(dot)com>
Cc: torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, postgres(at)jeltef(dot)nl, ilya(dot)evdokimov(at)tantorlabs(dot)com
Subject: Re: ANALYZE ONLY
Date: 2024-09-16 02:29:47
Message-ID: CACJufxEFOhe5FQqoYhatB=kRtc9aA5HzCVXnu_-tnv+31Jh2Hw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi.

in https://www.postgresql.org/docs/current/ddl-inherit.html
<<<
Commands that do database maintenance and tuning (e.g., REINDEX,
VACUUM) typically only work on individual, physical tables and do not
support recursing over inheritance hierarchies. The respective
behavior of each individual command is documented in its reference
page (SQL Commands).
<<<
does the above para need some tweaks?

in section, your patch output is
<<<<<<<<<
and table_and_columns is:
[ ONLY ] table_name [ * ] [ ( column_name [, ...] ) ]
<<<<<<<<<

ANALYZE ONLY only_parted*;
will fail.
Maybe we need a sentence saying ONLY and * are mutually exclusive?

>>>
If the table being analyzed has inheritance children, ANALYZE gathers
two sets of statistics: one on the rows of the parent table only, and
a second including rows of both the parent table and all of its
children. This second set of statistics is needed when planning
queries that process the inheritance tree as a whole. The child tables
themselves are not individually analyzed in this case.
>>>
is this still true for table inheritance.

for example:
drop table if exists only_inh_parent,only_inh_child;
CREATE TABLE only_inh_parent (a int , b INT) with (autovacuum_enabled = false);
CREATE TABLE only_inh_child () INHERITS (only_inh_parent) with
(autovacuum_enabled = false);
INSERT INTO only_inh_child(a,b) select g % 80, (g + 1) % 200 from
generate_series(1,1000) g;
select pg_table_size('only_inh_parent');

ANALYZE ONLY only_inh_parent;

here, will "ANALYZE ONLY only_inh_parent;" will have minimal "effects".
since the physical table only_inh_parent has zero storage.
but
select stadistinct,starelid::regclass,staattnum, stainherit
from pg_statistic
where starelid = ANY ('{only_inh_parent, only_inh_child}'::regclass[]);

output is
stadistinct | starelid | staattnum | stainherit
-------------+-----------------+-----------+------------
80 | only_inh_parent | 1 | t
-0.2 | only_inh_parent | 2 | t

I am not sure if this output and the manual description about table
inheritance is consistent.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alena Rybakina 2024-09-16 02:53:47 Re: POC, WIP: OR-clause support for indexes
Previous Message Paul A Jungwirth 2024-09-16 02:12:34 Re: SQL:2011 application time