Re: [patch] Have psql's \d+ indicate foreign partitions

From: Ian Lawrence Barwick <barwick(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [patch] Have psql's \d+ indicate foreign partitions
Date: 2022-11-06 12:23:01
Message-ID: CAB8KJ=iwzbEz2HR9EhNxQLVhMk2G_OYtQPJ9V=jWLadseggrOA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2022年11月6日(日) 1:39 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>
> Michael Paquier <michael(at)paquier(dot)xyz> writes:
> > On Mon, Oct 24, 2022 at 09:44:18PM +0900, Ian Lawrence Barwick wrote:
> >> Recently I have been working a lot with partitioned tables which contain a mix
> >> of local and foreign partitions, and find it would be very useful to be able to
> >> easily obtain an overview of which partitions are foreign and where they are
> >> located.
>
> > Hmm. I am not sure that we should add this much amount of
> > information, particularly for the server bits.
>
> FWIW, I am also in favor of adding ", FOREIGN" but no more.
> My concern is that as submitted, the patch greatly increases
> the cost of the underlying query by adding two more catalogs
> to the join. I don't think imposing such a cost on everybody
> (whether they use foreign partitions or not) is worth that. But
> we can add ", FOREIGN" for free since we have the relkind anyway.

Fair enough, make sense.

Revised version added per suggestions, which produces output like this:

postgres=# \d+ parttest
Partitioned table "public.parttest"
Column | Type | Collation | Nullable | Default | Storage |
Compression | Stats target | Description
--------+---------+-----------+----------+---------+----------+-------------+--------------+-------------
id | integer | | not null | | plain |
| |
val1 | text | | | | extended |
| |
val2 | text | | | | extended |
| |
Partition key: HASH (id)
Partitions: parttest_10_0 FOR VALUES WITH (modulus 10, remainder 0),
parttest_10_1 FOR VALUES WITH (modulus 10, remainder
1), FOREIGN,
parttest_10_2 FOR VALUES WITH (modulus 10, remainder 2),
parttest_10_3 FOR VALUES WITH (modulus 10, remainder
3), FOREIGN,
parttest_10_4 FOR VALUES WITH (modulus 10, remainder 4),
parttest_10_5 FOR VALUES WITH (modulus 10, remainder
5), FOREIGN,
parttest_10_6 FOR VALUES WITH (modulus 10, remainder 6),
parttest_10_7 FOR VALUES WITH (modulus 10, remainder
7), FOREIGN,
parttest_10_8 FOR VALUES WITH (modulus 10, remainder 8),
parttest_10_9 FOR VALUES WITH (modulus 10, remainder 9), FOREIGN

Regards

Ian Barwick

Attachment Content-Type Size
psql-slash-d-plus-show-foreign-partitions.v2.patch text/x-patch 7.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2022-11-06 13:04:26 Re: Improve logging when using Huge Pages
Previous Message Daniel Westermann (DWE) 2022-11-06 08:48:03 pg_upgrade, tables_with_oids.txt -> tables_with_oids.sql?