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

From Amit Langote
Subject Re: [HACKERS] New partitioning - some feedback
Date
Msg-id 7dfc13c5-d6b7-1ff1-4bef-d75d6d2f76d9@lab.ntt.co.jp
Whole thread Raw
In response to Re: [HACKERS] New partitioning - some feedback  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
On 2017/07/12 23:58, Alvaro Herrera wrote:
> Amit Langote wrote:
>> On 2017/07/11 13:34, Alvaro Herrera wrote:
>>> Robert Haas wrote:
>>>> On Mon, Jul 10, 2017 at 2:15 AM, Amit Langote
>>>> <Langote_Amit_f8@lab.ntt.co.jp> wrote:
>>>
>>>>> Actually, if \d had shown RELKIND_PARTITIONED_TABLE tables as of Type
>>>>> "partitioned table", we wouldn't need a separate flag for marking a table
>>>>> as having partitions.
>>>>
>>>> I think that is false.  Whether something is partitioned and whether
>>>> it is a partition are independent concerns.
>>>
>>> Maybe this discussion is easier if we differentiate "list tables" (\dt,
>>> or \d without a pattern) from "describe table" (\d with a name pattern).
>>
>> I think this discussion has mostly focused on "list tables" so far.
> 
> Yes, which I think is a mistake, because for some things you definitely
> need a list of partitions of the table in question.  And "describe
> table" can fulfill that role perfectly well, ISTM.

For a partitioned table, "describe table" (aka \d name_pattern) lists its
partitions showing for each partition its name and the partition bound.
"list tables/view/indexes/..." (aka \d[tvi...]) shows information about
the listed objects that one might want to see for partitions (such as the
schema, owner, size, description) and "describe table" doesn't provide
that about partitions as just mentioned.  So, it should be possible to
list partitions in some way.

>>> However, the "list tables"
>>> command \dt should definitely IMO not list partitions.
>>
>> Do you mean never?  Even if a modifier is specified?  In the patch I
>> proposed, \d! (or \d+ or \d++, if '!' turns out to be unpopular) will list
>> partitions, but \d or \dt won't.  That is, partitions are hidden by default.
> 
> I don't think there is any need for a single list of all partition of
> all tables -- is there?  I can't think of anything, but then I haven't
> been exposed very much to this feature yet.  For now, I lean towards "never".
> 
> (A different consideration is the use case of listing relation
> relfrozenxid/relminmxid ages, but that use case is already not fulfilled
> by psql metacommands so you still need custom catalog queries).

As I mentioned above, if we decide to hide partitions except when
"describing" the parent table, one would need custom queries even to see
schema, owner, etc. for partitions.

> I don't think \d! works terribly well as a mental model, but maybe
> that's just me.

It seems you're not alone.  Anyway, I'm starting to like Dean's advice [1]
on this matter.

Thanks,
Amit

[1]
https://www.postgresql.org/message-id/CAEZATCWcfFtsbKYcVyqUzoOsxkikQjpi_GdjZ_vL6RcX8iLEsg@mail.gmail.com




pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: [HACKERS] pg_stop_backup(wait_for_archive := true) on standby server
Next
From: Ashutosh Bapat
Date:
Subject: [HACKERS] Replacing lfirst() with lfirst_node() appropriately in planner.c