Re: ToDo: show size of partitioned table - Mailing list pgsql-hackers

From Amit Langote
Subject Re: ToDo: show size of partitioned table
Date
Msg-id e40eb905-8fd5-dbee-a05c-824ba4516887@lab.ntt.co.jp
Whole thread Raw
In response to Re: ToDo: show size of partitioned table  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: ToDo: show size of partitioned table
List pgsql-hackers
Hi,

On 2019/04/08 12:59, Pavel Stehule wrote:
> ne 7. 4. 2019 v 21:13 odesílatel Alvaro Herrera <alvherre@2ndquadrant.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,
                                        forkNum);

    /*
     * 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?

Thanks,
Amit




pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: change password_encryption default to scram-sha-256?
Next
From: Noah Misch
Date:
Subject: Re: [HACKERS] Weaker shmem interlock w/o postmaster.pid