Re: [HACKERS] New partitioning - some feedback - Mailing list pgsql-hackers

From Amit Langote
Subject Re: [HACKERS] New partitioning - some feedback
Date
Msg-id 7030214b-6052-7391-c4ef-17fcca2e4bf2@lab.ntt.co.jp
Whole thread Raw
In response to Re: [HACKERS] New partitioning - some feedback  (Mark Kirkwood <mark.kirkwood@catalyst.net.nz>)
Responses Re: [HACKERS] New partitioning - some feedback
List pgsql-hackers
On 2017/07/08 14:12, Mark Kirkwood wrote:
> On 07/07/17 19:54, Michael Banck wrote:
>> On Fri, Jul 07, 2017 at 07:40:55PM +1200, Mark Kirkwood wrote:
>>> On 07/07/17 13:29, Amit Langote wrote:
>>>> Someone complained about this awhile back [1].  And then it came up again
>>>> [2], where Noah appeared to take a stance that partitions should be
>>>> visible in views / output of commands that list "tables".
>>>>
>>>> Although I too tend to prefer not filling up the \d output space by
>>>> listing partitions (pg_class.relispartition = true relations), there
>>>> wasn't perhaps enough push for creating a patch for that.  If some
>>>> committer is willing to consider such a patch, I can make one.
>>>
>>> Yeah, me too (clearly). However if the consensus is that all these
>>> partition
>>> tables *must* be shown in \d output, then I'd be happy if they were
>>> identified as such rather than just 'table' (e.g 'partition table').
>> +1.
>>
>> Or maybe just 'partition' is enough if 'partition table' would widen the
>> column output unnecessarily.
> 
> Yeah, that is probably better (and 'partition table' is potentially
> confusing as Robert pointed out).

So, it seems at least that showing "partition" as the Type of tables that
are actually partitions is preferable.  I created a patch (attached 0001)
that implements that.  It makes \d show any relations that have
relispartition = true as of type "partition" or "foreign partition".  With
the patch:

create table p (a int) partition by list (a);

-- regular table as partition
create table p1 partition of p for values in (1)

-- foreign table as partition
create foreign data wrapper dummy;
create server dummy foreign data wrapper dummy;
create foreign table p2 partition of p for values in (2) server dummy;

-- partitioned table as partition
create table p3 partition of p for values in (3) partition by list (a);

\d
             List of relations
 Schema | Name |       Type        | Owner
--------+------+-------------------+-------
 public | p    | table             | amit
 public | p1   | partition         | amit
 public | p2   | foreign partition | amit
 public | p3   | partition         | amit
(4 rows)

Also, there seems to be at least some preference for excluding partitions
by default from the \d listing.  Attached 0002 implements that.  To enable
showing partitions, the patch adds a new modifier '!' to \d (picked '!'
from Robert's email on this thread [1]).  With the patch:

\d
       List of relations
 Schema | Name | Type  | Owner
--------+------+-------+-------
 public | p    | table | amit
(1 row)

\d!
             List of relations
 Schema | Name |       Type        | Owner
--------+------+-------------------+-------
 public | p    | table             | amit
 public | p1   | partition         | amit
 public | p2   | foreign partition | amit
 public | p3   | partition         | amit
(4 rows)

\d!+
                         List of relations
 Schema | Name |       Type        | Owner |  Size   | Description
--------+------+-------------------+-------+---------+-------------
 public | p    | table             | amit  | 0 bytes |
 public | p1   | partition         | amit  | 0 bytes |
 public | p2   | foreign partition | amit  | 0 bytes |
 public | p3   | partition         | amit  | 0 bytes |
(4 rows)

Thanks,
Amit

[1]
https://www.postgresql.org/message-id/CA%2BTgmoYNPHFjY%2BObFF9%3DTbX%2BT6ez1FAU%2BsmGuXeoiOMasDc-0g%40mail.gmail.com

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment

pgsql-hackers by date:

Previous
From: Etsuro Fujita
Date:
Subject: Re: [HACKERS] Oddity in error handling of constraint violation inExecConstraints for partitioned tables
Next
From: Amit Langote
Date:
Subject: Re: [HACKERS] Oddity in error handling of constraint violation inExecConstraints for partitioned tables