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>, Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, mathias(at)brossard(dot)org, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: ToDo: show size of partitioned table
Date: 2018-12-18 07:49:07
Message-ID: ad3bd857-43cf-ab23-9645-681d59e7d9ef@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Thank you for updating the patch.

On 2018/12/17 17:48, Pavel Stehule wrote:
> new update of this patch

Documentation portion of this patch still contains some typos that I
mentioned before here:

https://www.postgresql.org/message-id/1c83bb5c-47cd-d796-226c-e95795b05551%40lab.ntt.co.jp

+ .. If the form <literal>\dP+</literal>
+ is used, the sum of size of related partitions (including the
+ table and indexes, if any) and a description
+ are also displayed.

+ ... If the form <literal>\dPi+</literal>
+ is used, the sum of size of related indexes and a description
+ are also displayed.

+ ... If the form <literal>\dPt+</literal>
+ is used, the sum of size of related tables and a description
+ are also displayed.

In all of the three hunks:

the sum of size of -> the sum of "sizes" of

and a description -> and associated description

> changes:
>
> 1. only root partitioned tables are displayed - you can see quickly total
> allocated space. It is not duplicated due nested partitions.

+1

If one wants to see a non-root partitioned table's details, they can use
\dP+ <pattern>.

> I can imagine new additional flag - line "n" nested - and then we can
> display nested partitioned tables with parent table info. Some like
>
> \dPt - show only root partition tables
> \dPnt or \dPtn - show root and nested partitioned tables

Too much complication maybe?

> 2. \dP without pattern shows root partitioned tables + total relation size.
> When pattern is defined, then shows tables and indexes + table size
>
> postgres=# \dP+
> List of partitioned relations
> ┌────────┬────────────┬───────┬────────┬─────────────┐
> │ Schema │ Name │ Owner │ Size │ Description │
> ╞════════╪════════════╪═══════╪════════╪═════════════╡
> │ public │ parent_tab │ pavel │ 120 kB │ │
> └────────┴────────────┴───────┴────────┴─────────────┘
> (1 row)
>
> postgres=# \dP+ *
> List of partitioned relations or indexes
> ┌────────┬──────────────┬───────┬───────────────────┬────────────┬───────┬─────────────┐
> │ Schema │ Name │ Owner │ Type │ Table │ Size │
> Description │
> ╞════════╪══════════════╪═══════╪═══════════════════╪════════════╪═══════╪═════════════╡
> │ public │ parent_index │ pavel │ partitioned index │ parent_tab │ 80 kB
> │ │
> │ public │ parent_tab │ pavel │ partitioned table │ │ 40 kB
> │ │
> └────────┴──────────────┴───────┴───────────────────┴────────────┴───────┴─────────────┘
> (2 rows)
>
> postgres=# \dP+ *index
> List of partitioned relations or indexes
> ┌────────┬──────────────┬───────┬───────────────────┬────────────┬───────┬─────────────┐
> │ Schema │ Name │ Owner │ Type │ Table │ Size │
> Description │
> ╞════════╪══════════════╪═══════╪═══════════════════╪════════════╪═══════╪═════════════╡
> │ public │ parent_index │ pavel │ partitioned index │ parent_tab │ 80 kB
> │ │
> └────────┴──────────────┴───────┴───────────────────┴────────────┴───────┴─────────────┘
> (1 row)

Looking at the patch:

+ if (pattern)
+ /* translator: objects_name is "indexes", "tables" or "relations" */
+ psql_error("Did not find any partitioned %s named \"%s\".\n",
+ objects_name,
+ pattern);
+ else
+ /* translator: object_name is "index", "table" or "relation" */
+ psql_error("Did not find any partitioned %s.\n",
+ object_name);

It seems that objects_name and object_name need to be swapped between the
if and else blocks, and so do /* translator: ... */ comments.

if (pattern)
/* translator: object_name is "index", "table" or "relation" */
psql_error(..., object_name);
else
/* translator: objects_name is "indexes", "tables" or "relations" */
psql_error(..., objects_name);

That is, it should say, "Did not find any partitioned index/table/relation
named "foo" and "Did not find any partitioned indexes/tables/relations".

Thanks,
Amit

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2018-12-18 07:59:05 Re: [HACKERS] Block level parallel vacuum
Previous Message Michael Paquier 2018-12-18 07:45:30 Re: Should new partitions inherit their tablespace from their parent?