Re: STATISTICS retained in CREATE TABLE ... LIKE (INCLUDING ALL)?

From: "Tels" <nospam-pg-abuse(at)bloodgate(dot)com>
To: "David Rowley" <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Stephen Froehlich" <s(dot)froehlich(at)cablelabs(dot)com>, "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>, "Tomas Vondra" <tomas(dot)vondra(at)2ndquadrant(dot)com>, "Alvaro Herrera" <alvherre(at)2ndquadrant(dot)com>
Subject: Re: STATISTICS retained in CREATE TABLE ... LIKE (INCLUDING ALL)?
Date: 2018-01-26 11:03:08
Message-ID: f31257654fd0e5954b6bc315ec8187bf.squirrel@sm.webmail.pair.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-novice

Moin,

On Fri, January 26, 2018 2:30 am, David Rowley wrote:
> On 21 January 2018 at 19:21, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
> wrote:
>> On 20 January 2018 at 18:50, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Stephen Froehlich <s(dot)froehlich(at)cablelabs(dot)com> writes:
>>>> Are custom statistics in PG10 retained in LIKE (INCLUDING ALL) or do I
>>>> need to recreate the statistics by hand each time I create a new
>>>> table?
>>>
>>> LIKE doesn't know about those, no. Perhaps it should.
>>
>> Agreed. ALL does not mean MOST.
>
> (Moving to -hackers)
>
> The attached implements this.
>
> Looking at "LIKE ALL" in more detail in the docs it claims to be
> equivalent to "INCLUDING DEFAULTS INCLUDING IDENTITY INCLUDING
> CONSTRAINTS INCLUDING INDEXES INCLUDING STORAGE INCLUDING COMMENTS",
> so it didn't seem right to magically have LIKE ALL include something
> that there's no option to include individually, so I added INCLUDING
> STATISTICS.

Note sure if someone want's to exclude statistics, but it is good that one
can. So +1 from me.

Looking at the patch, at first I thought the order was sorted and you
swapped STORAGE and STATISTICS by accident. But then, it seems the order
is semi-random. Should that list be sorted or is it already sorted by some
criteria that I don't see?

- <literal>INCLUDING DEFAULTS INCLUDING IDENTITY INCLUDING
CONSTRAINTS INCLUDING INDEXES INCLUDING STORAGE INCLUDING
COMMENTS</literal>.
+ <literal>INCLUDING DEFAULTS INCLUDING IDENTITY INCLUDING
CONSTRAINTS INCLUDING INDEXES INCLUDING STORAGE INCLUDING STATISTICS
INCLUDING COMMENTS</literal>.

Best wishes,

Tels

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2018-01-26 11:25:59 Re: [HACKERS] MERGE SQL Statement for PG11
Previous Message Emre Hasegeli 2018-01-26 10:07:52 Re: Redefining inet_net_ntop

Browse pgsql-novice by date

  From Date Subject
Next Message Garry Chen 2018-01-26 18:39:27 syntax error on Function return setoff
Previous Message David Rowley 2018-01-26 07:30:52 Re: STATISTICS retained in CREATE TABLE ... LIKE (INCLUDING ALL)?