On 21 January 2018 at 19:21, David Rowley <david.row...@2ndquadrant.com> wrote: > On 20 January 2018 at 18:50, Tom Lane <t...@sss.pgh.pa.us> wrote: >> Stephen Froehlich <s.froehl...@cablelabs.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. 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
create_table_like_statistics_v1.patch
Description: Binary data