Re: [patch] Have psql's \d+ indicate foreign partitions - Mailing list pgsql-hackers

From Ian Lawrence Barwick
Subject Re: [patch] Have psql's \d+ indicate foreign partitions
Date
Msg-id CAB8KJ=iwzbEz2HR9EhNxQLVhMk2G_OYtQPJ9V=jWLadseggrOA@mail.gmail.com
Whole thread Raw
In response to Re: [patch] Have psql's \d+ indicate foreign partitions  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [patch] Have psql's \d+ indicate foreign partitions
List pgsql-hackers
2022年11月6日(日) 1:39 Tom Lane <tgl@sss.pgh.pa.us>:
>
> Michael Paquier <michael@paquier.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

pgsql-hackers by date:

Previous
From: "Daniel Westermann (DWE)"
Date:
Subject: pg_upgrade, tables_with_oids.txt -> tables_with_oids.sql?
Next
From: Justin Pryzby
Date:
Subject: Re: Improve logging when using Huge Pages