Re: pg_relation_size on partitioned table - Mailing list pgsql-hackers

From Bharath Rupireddy
Subject Re: pg_relation_size on partitioned table
Date
Msg-id CALj2ACVJwqwTeOGVr+pyLt3+=Rcn6uHAkBy=BoRQm5J4=ZJ=fw@mail.gmail.com
Whole thread Raw
In response to Re: pg_relation_size on partitioned table  (Michael Paquier <michael@paquier.xyz>)
Responses Re: pg_relation_size on partitioned table
List pgsql-hackers
On Sat, Mar 26, 2022 at 11:35 AM Michael Paquier <michael@paquier.xyz> wrote:
>
> On Fri, Mar 25, 2022 at 08:52:40PM +0800, Japin Li wrote:
> > Could we provide a function to get the total size of the partition table
> > though the partitioned table name?  Maybe we can extend
> > the pg_relation_size() to get the total size of partition tables through
> > the partitioned table name.
>
> There are already many replies on this thread, but nobody has
> mentioned pg_partition_tree() yet, so here you go.  You could use that
> in combination with pg_relation_size() to get the whole size of a tree
> depending on your needs.

Yeah. The docs have a note on using it for finding partitioned table size:

   <para>
    For example, to check the total size of the data contained in a
    partitioned table <structname>measurement</structname>, one could use the
    following query:
<programlisting>
SELECT pg_size_pretty(sum(pg_relation_size(relid))) AS total_size
  FROM pg_partition_tree('measurement');
</programlisting>
   </para>

Regards,
Bharath Rupireddy.



pgsql-hackers by date:

Previous
From: Bharath Rupireddy
Date:
Subject: Re: Remove an unused function GetWalRcvWriteRecPtr
Next
From: vignesh C
Date:
Subject: Re: Identify missing publications from publisher while create/alter subscription.