On Fri, Feb 04, 2022 at 04:29:19PM -0500, Tom Lane wrote: > > + A previous bug fix disabled building of extended statistics for > > + old-style inheritance trees, but any existing statistics data was > > + not removed, and that data would become more and more out-of-date > > + over time. Adjust the planner to ignore such data. Extended > > + statistics for the individual child tables are still built and used, > > + however. > > > The issue here isn't that old stats were never updated. For inheritance, > > they > > *were* updated with non-inherited stats (for SELECT FROM ONLY). But then > > "SELECT FROM tbl*" used the stats anyway... > > I'm confused about this bit. Are we still building bogus stats for > inheritance parents, or has that stopped?
To make a long story long: - before 859b3003de, an ERROR occurred when a stats object was created on an inheritance parent. - To avoid the error, 859b3003de changed to no longer build "whole tree" stats on the table heirarchy. Non-inheried stats were still collected. - However, the stats were *also* applied to inherited queries (FROM tbl*). 36c4bc6 stops applying stats that shouldn't be applied (and doesn't change their collection during ANALYZE). 20b9fa3 then changes to collect inherited stats on partitioned tables, since they have no non-inherited stats, and since extended stats on partitioned tables were intended to work since v10, and did work until 859b3003de stopped collecting them. In back branches, pg_statistic has inherited stats for partitioned tables, and non-inherited stats otherwise. -- Justin