pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: pgsql-general@postgresql.org
Subject: Re: relkind='p' has no pg_stat_user_tables
Date: Thu, 3 May 2018 11:15:19 -0700
Message-ID: <ba5ad25e-0585-aff7-3423-ec76f1f8ffb5@aklaver.com> (raw)
In-Reply-To: <20180503173855.GH9585@telsasoft.com>
References: <20180503162047.37k7km4dx62i6l4d@alvherre.pgsql>
	<0d1a3f8a-f6f9-4712-6b6c-174e64a38b48@aklaver.com>
	<20180503173855.GH9585@telsasoft.com>

On 05/03/2018 10:38 AM, Justin Pryzby wrote:
> On Thu, May 03, 2018 at 09:31:12AM -0700, Adrian Klaver wrote:
>> On 05/03/2018 09:20 AM, Alvaro Herrera wrote:
>>>> 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. ... "
>>>
>>> Yeah, but I think Justin has a valid question from the POV of the user:
>>> how can we figure out if we need to re-run analyze on a partitioned
>>> table, if the time of last analyze is not stored anywhere?
>>
>> I agree. The only thing I can think of is, that knowing :
>>
>> ANALYZE VERBOSE t;
>>
>> walks the inheritance tree, look at the pg_stat_user_tables for one of the
>> children for the last time analyzed.
> 
> I think I can make this work for my purposes:
> 
> SELECT MIN(GREATEST(last_analyze,last_autoanalyze))
> FROM pg_stat_user_tables psut
> JOIN pg_inherits i
> ON i.inhrelid=psut.relid
> WHERE i.inhparent=...
> 
> I was about to say that it's perhaps more correct for relkind='r' parents, too.
> 
> But actually, it looks like for relkind='p', ANALYZE populates stats on child
> tables in addition to the parent.  For relkind='r', the behavior (introduced in
> PG9.0 as I recall) is that ANALYZE on parent creates stats only for parent
> (both "inherited" stats including children, and "ONLY" stats for the
> potentially-nonempty parent).
> 
> I guess ability to update child tables' stats is a nice feature, but I'm
> surprised.  I wonder if that was a deliberate/documented change ?

I was with you until I got to the above. You seem to be comparing apples 
and oranges unless I am missing something.

The behavior for 'r' tables has not changed:

https://www.postgresql.org/docs/9.0/static/sql-analyze.html

https://www.postgresql.org/docs/10/static/sql-analyze.html


The 'p' type table does not appear until version 10:

https://www.postgresql.org/docs/9.6/static/catalog-pg-class.html

https://www.postgresql.org/docs/10/static/catalog-pg-class.html

so there is no past behavior to compare to.

> 
> Justin
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (10+ messages)  latest in thread

Message-ID: <ba5ad25e-0585-aff7-3423-ec76f1f8ffb5@aklaver.com>
Permalink:  ../ba5ad25e-0585-aff7-3423-ec76f1f8ffb5@aklaver.com/
Also on:    postgresql.org/message-id/ba5ad25e-0585-aff7-3423-ec76f1f8ffb5@aklaver.com

 · 

reply

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, alvherre@2ndquadrant.com
  Subject: Re: relkind='p' has no pg_stat_user_tables
  In-Reply-To: <ba5ad25e-0585-aff7-3423-ec76f1f8ffb5@aklaver.com>
  References: <20180503162047.37k7km4dx62i6l4d@alvherre.pgsql> <0d1a3f8a-f6f9-4712-6b6c-174e64a38b48@aklaver.com> <20180503173855.GH9585@telsasoft.com> <ba5ad25e-0585-aff7-3423-ec76f1f8ffb5@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