Re: New partitioning - some feedback

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Mark Kirkwood <mark(dot)kirkwood(at)catalyst(dot)net(dot)nz>, Michael Banck <michael(dot)banck(at)credativ(dot)de>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: New partitioning - some feedback
Date: 2017-07-10 05:56:00
Message-ID: 7030214b-6052-7391-c4ef-17fcca2e4bf2@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Attachment Content-Type Size
0001-Show-foreign-partition-as-Type-in-d-output.patch text/plain 3.1 KB
0002-Exclude-partitions-by-default-from-the-the-psql-d-li.patch text/plain 10.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2017-07-10 06:31:56 Re: Oddity in error handling of constraint violation in ExecConstraints for partitioned tables
Previous Message Etsuro Fujita 2017-07-10 05:15:41 Re: Oddity in error handling of constraint violation in ExecConstraints for partitioned tables