Re: ToDo: show size of partitioned table

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Justin Pryzby <pryzby(at)telsasoft(dot)com>, Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, Michael Paquier <michael(at)paquier(dot)xyz>, mathias(at)brossard(dot)org, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: ToDo: show size of partitioned table
Date: 2019-04-08 06:38:51
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 2019/04/08 12:59, Pavel Stehule wrote:
> ne 7. 4. 2019 v 21:13 odesílatel Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
> napsal:
>> Added to the docs, and pushed.
> Thank you very much

Thank you Alvaro for pushing this to completion. Also, thank you Justin
and Pavel for reviewing it till the last minute.

Looks pretty good in my testing so far.

>> I couldn't resist tweaking the ORDER BY clause, too. I think listing
>> all tables first, followed by all indexes, and sorting by parent in each
>> category, is much easier to read. (Maybe this can use additional
>> tweaking, but it's a minor thing anyway -- for example putting together
>> all indexes that correspond to some particular table?)
>> I noticed that \d never seems to use pg_total_relation_size, so toast
>> size is never shown. I did likewise here too and used pg_table_size
>> everywhere. I'm not 100% sure this is the most convenient thing. Maybe
>> we need yet another column, and/or yet another flag ...?
> I prefer some flag - both raw size and total size has sense, but another
> column will be less readable

I noticed that the size shown in the output of both \dP+ and \dPt+ does
include toast relation sizes of (leaf) partitions, because
pg_table_size(), which is used by all the queries that
listPartitionedTables sends to the server, does:

* heap size, including FSM and VM
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
size += calculate_relation_size(&(rel->rd_node), rel->rd_backend,

* Size of toast relation
if (OidIsValid(rel->rd_rel->reltoastrelid))
size += calculate_toast_table_size(rel->rd_rel->reltoastrelid);

>> Also, I think the new \dP should gain a new flag (maybe "l") to make it
>> list leaf tables/indexes too with their local sizes, and remove those
>> from the standard \d listing.
> +1

+1 to the idea. Perhaps we'd need to post this in a separate thread to
highlight what may be a substantive change to \d's output?


In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2019-04-08 06:41:41 Re: [HACKERS] Weaker shmem interlock w/o
Previous Message Michael Paquier 2019-04-08 06:38:26 Re: change password_encryption default to scram-sha-256?