Re: pg_relation_size on partitioned table

From: Japin Li <japinli(at)hotmail(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_relation_size on partitioned table
Date: 2022-03-27 03:05:58
Message-ID: MEYP282MB16695D8271CB88724722728FB61C9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Sat, 26 Mar 2022 at 22:16, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
> On Sat, Mar 26, 2022 at 11:35 AM Michael Paquier <michael(at)paquier(dot)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>
>

Thanks for all of you! The above code does what I want.

--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2022-03-27 03:37:12 Re: Is there any documentation on how to correctly create extensions in HA(primary-standby) setup?
Previous Message David G. Johnston 2022-03-26 23:56:37 Re: Document atthasmissing default optimization avoids verification table scan