Re: ANALYZE ONLY - Mailing list pgsql-hackers

From jian he
Subject Re: ANALYZE ONLY
Date
Msg-id CACJufxEFOhe5FQqoYhatB=kRtc9aA5HzCVXnu_-tnv+31Jh2Hw@mail.gmail.com
Whole thread Raw
In response to ANALYZE ONLY  (Michael Harris <harmic@gmail.com>)
List 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.



pgsql-hackers by date:

Previous
From: Paul A Jungwirth
Date:
Subject: Re: SQL:2011 application time
Next
From: Alena Rybakina
Date:
Subject: Re: POC, WIP: OR-clause support for indexes