Re: STATISTICS retained in CREATE TABLE ... LIKE (INCLUDING ALL)? - Mailing list pgsql-hackers

From David Rowley
Subject Re: STATISTICS retained in CREATE TABLE ... LIKE (INCLUDING ALL)?
Date
Msg-id CAKJS1f9pL8+v4LDGiePWrUqkLHqvek5L54wW=Ba1fMKz8o0Pag@mail.gmail.com
Whole thread Raw
Responses Re: STATISTICS retained in CREATE TABLE ... LIKE (INCLUDING ALL)?
List pgsql-hackers
On 21 January 2018 at 19:21, David Rowley <david.rowley@2ndquadrant.com> wrote:
> On 20 January 2018 at 18:50, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Stephen Froehlich <s.froehlich@cablelabs.com> writes:
>>> Are custom statistics in PG10 retained in LIKE (INCLUDING ALL) or do I need to recreate the statistics by hand each
timeI 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.

This also required writing code allow statistics to be created without
a name. The code I added to choose the default name is in the form
<tablename>_<column1>_<column2>_stat. I'm sure someone will want
something else, but that's just what I've personally standardised on.
I'd also be fine with "stx" or "sta". Making this work required a bit
of shuffling of error checking in CreateStatistics() so that we
generate a name before complaining about any duplicate name.

I'm unsure if this should be categorised as a bug fix or a new feature.

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: [HACKERS] Parallel tuplesort (for parallel B-Tree index creation)
Next
From: Konstantin Knizhnik
Date:
Subject: Re: JIT compiling with LLVM v9.0