On Fri, Dec 27, 2024 at 1:16 PM Richard Guo <guofengli...@gmail.com> wrote: > I'm wondering if we also need to strip out the nullingrels from the > expression in examine_variable(). I tried doing so and noticed a plan > diff in regression test join.sql.
Here is an updated patch that implements this change, and also moves the removal of the nullingrels within grouping expressions from estimate_num_groups to add_unique_group_var. I'm not quite sure how this change affects the exprs_known_equal call in add_unique_group_var, possibly making it even less precise (it is alreay somewhat fuzzy, as we do not provide a valid opfamily). However, I think it should be fine for estimation purposes. Moreover, in many cases, such as with groupClause, distinctClause, and WindowClause's PARTITION BY clauses, we have already removed any items that can be proven redundant. Regarding the back-patch, this patch is a bug fix, which suggests it should be back-patched. However, it also changes some plans by fixing the cost estimation. Does anyone know what our usual approach is in this situation? Thanks Richard
v2-0001-Ignore-nullingrels-when-looking-up-statistics.patch
Description: Binary data