Re: BUG #16521: n_distinct_inherited does not affect child partitions when set on main partition

From: Klaudie Willis <Klaudie(dot)Willis(at)protonmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #16521: n_distinct_inherited does not affect child partitions when set on main partition
Date: 2020-07-01 17:16:07
Message-ID: Y7I4lHv5Ms8rOZyXQ6gS3LG7kuhw4dCZVNZcbz6fHtGk4-mn1LRSFfEWmNt-C3amHkSYGSuLstm7brL9OD6HPL9X148AUyjewV2au9sHoaM=@protonmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Thanks for you thorough answer!

"n_distinct affects the statistics for the table itself, while n_distinct_inherited affects the statistics
gathered for the table plus its inheritance children."

I see that this text has multiple interpretations. I read it more like: while n_distinct_inherited affects the statistics gathered [by analyze] for the table plus [affects the statistics of] its inheritance children.

The core problem for me was that I had to set n_distinct manually on my individual partitions for the planner to choose a sane plan for queries on the declared partition. The data for a column was so skewed that the analyzers n_distinct was off by a factor of 1000X, which made all partitions do a table scan instead of index scan. In my mind, setting the declarative partition variable n_distinct_inherited would solve that; but obviously I am wrong on that.

Klaudie

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2020-07-02 03:16:27 BUG #16523: The wal logs fill the disk and are not cleaned up
Previous Message Tom Lane 2020-07-01 16:47:19 Re: [bug] Table not have typarray when created by single user mode