From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: pgsql-general@postgresql.org
Subject: Re: relkind='p' has no pg_stat_user_tables
Date: Thu, 3 May 2018 09:18:20 -0700
Message-ID: <3b48b9a9-8eec-398d-bf13-86ae8ce93237@aklaver.com> (raw)
In-Reply-To: <20180503154545.GG9585@telsasoft.com>
References: <20180503141430.GA28019@telsasoft.com>
<5e1e8ccf-da3d-5277-df77-a2bbaa714592@aklaver.com>
<20180503154545.GG9585@telsasoft.com>
On 05/03/2018 08:45 AM, Justin Pryzby wrote:
> On Thu, May 03, 2018 at 07:44:24AM -0700, Adrian Klaver wrote:
>> On 05/03/2018 07:14 AM, Justin Pryzby wrote:
>>> I (finally) realized that my script for ANALYZEing parents of table hierarchies
>>> every month or so was looping around the same parent tables every night due to
>>> no stats for date of last last analysis.
>>
>> Would help to see the script.
>
> I reproduced it more simply than the 300 line script:
>
> postgres=# CREATE TABLE t(i int)PARTITION BY RANGE(i);
> postgres=# CREATE TABLE t1 PARTITION OF t FOR VALUES FROM (1) TO (9);
> postgres=# INSERT INTO t1 VALUES(1),(2);
> postgres=# ANALYZE VERBOSE t;
I would say the answer lies below from above command:
test_(postgres)# ANALYZE VERBOSE t;
INFO: analyzing "public.t" inheritance tree
INFO: "t1": scanned 1 of 1 pages, containing 2 live rows and 0 dead
rows; 2 rows in sample, 2 estimated total rows
INFO: analyzing "public.t1"
INFO: "t1": scanned 1 of 1 pages, containing 2 live rows and 0 dead
rows; 2 rows in sample, 2 estimated total rows
ANALYZE
and from here:
https://www.postgresql.org/docs/10/static/sql-createtable.html
"A partitioned table is divided into sub-tables (called partitions),
which are created using separate CREATE TABLE commands. The partitioned
table is itself empty. A data row inserted into the table is routed to a
partition based on the value of columns or expressions in the partition
key. ... "
test_(postgres)# select * from only t;
i
---
(0 rows)
Table t is just a pointer to the child tables and only the bulk
statistics as shown in pg_statistic are maintained.
> postgres=# SELECT * FROM pg_stat_user_tables WHERE relname='t';
> (0 rows)
> postgres=# SELECT 1 FROM pg_statistic WHERE starelid='t'::regclass;
> ?column? | 1
>
> Justin
>
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, pryzby@telsasoft.com
Subject: Re: relkind='p' has no pg_stat_user_tables
In-Reply-To: <3b48b9a9-8eec-398d-bf13-86ae8ce93237@aklaver.com>
References: <20180503141430.GA28019@telsasoft.com> <5e1e8ccf-da3d-5277-df77-a2bbaa714592@aklaver.com> <20180503154545.GG9585@telsasoft.com> <3b48b9a9-8eec-398d-bf13-86ae8ce93237@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox