Re: pg_(total_)relation_size and partitioned tables - Mailing list pgsql-hackers

From David Rowley
Subject Re: pg_(total_)relation_size and partitioned tables
Date
Msg-id CAKJS1f86CjuW7-6QaXKPZLtcVCMo=ocprNdSk+dcvbpPyXMxtQ@mail.gmail.com
Whole thread Raw
In response to Re: pg_(total_)relation_size and partitioned tables  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: pg_(total_)relation_size and partitioned tables
List pgsql-hackers
On 29 December 2017 at 08:03, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
> Here is another idea.  If we had a function
>
> pg_partition_root(regclass) returns regclass
>
> (returning itself for non-partitioned relations), then users can easily
> construct queries to get the results they want in different shapes, e.g.,
>
> select pg_partition_root(c.oid), c.relname, pg_table_size(c.oid)
>   from pg_class c
>   order by 1
>
> select pg_partition_root(c.oid), sum(pg_table_size(c.oid))
>   from pg_class c
>   group by 1

That seems much nicer. I assume "root" would mean the top level
partitioned table. If so, would we also want
pg_partition_parent(regclass)? Or maybe something to control the
number of "levels-up" the function would run for. If we had that then
maybe -1 could mean "go until you find a table with no parent".

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: [HACKERS] replace GrantObjectType with ObjectType
Next
From: Alvaro Herrera
Date:
Subject: Re: [HACKERS] Proposal: Local indexes for partitioned table