Re: ToDo: show size of partitioned table

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ToDo: show size of partitioned table
Date: 2018-07-23 11:46:30
Message-ID: CAFj8pRDMWPgijpt_vPj1t702PgLG4Ls2NCf+rEcb+qGPpossmg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

I am sending a prototype of patch. Now, it calculates size of partitioned
tables with recursive query. When any more simple method will be possible,
the size calculation will be changed.

postgres=# \dt+
List of relations
+--------+------------+-------+-------+---------+-------------+
| Schema | Name | Type | Owner | Size | Description |
+--------+------------+-------+-------+---------+-------------+
| public | data | table | pavel | 0 bytes | |
| public | data_2016 | table | pavel | 15 MB | |
| public | data_2017 | table | pavel | 15 MB | |
| public | data_other | table | pavel | 11 MB | |
+--------+------------+-------+-------+---------+-------------+
(4 rows)

postgres=# \dP+
List of partitioned tables
+--------+------+-------+-------+-------------+
| Schema | Name | Owner | Size | Description |
+--------+------+-------+-------+-------------+
| public | data | pavel | 42 MB | |
+--------+------+-------+-------+-------------+
(1 row)

Regards

Pavel

p.s. Another patch can be replacement of relation type from "table" to
"partitioned table"

postgres=# \dt+
List of relations
+--------+------------+-------------------+-------+---------+-------------+
| Schema | Name | Type | Owner | Size | Description |
+--------+------------+-------------------+-------+---------+-------------+
| public | data | partitioned table | pavel | 0 bytes | |
| public | data_2016 | table | pavel | 15 MB | |
| public | data_2017 | table | pavel | 15 MB | |
| public | data_other | table | pavel | 11 MB | |
+--------+------------+-------------------+-------+---------+-------------+
(4 rows)

A patch is simple for this case

diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index c3bdf8555d..491e58eb29 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3490,8 +3490,8 @@ listTables(const char *tabtypes, const char *pattern,
bool verbose, bool showSys
gettext_noop("sequence"),
gettext_noop("special"),
gettext_noop("foreign table"),
- gettext_noop("table"), /* partitioned table */
- gettext_noop("index"), /* partitioned index */
+ gettext_noop("partitioned table"), /* partitioned
table */
+ gettext_noop("partitioned index"), /* partitioned
index */
gettext_noop("Type"),
gettext_noop("Owner"));

Attachment Content-Type Size
psql-dP-initial.patch text/x-patch 7.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2018-07-23 11:47:44 Re: pgbench: improve --help and --version parsing
Previous Message Amit Kapila 2018-07-23 11:36:11 Re: [bug fix] Produce a crash dump before main() on Windows