On Tue, Oct 6, 2026 at 9:30 PM Richard Guo <[email protected]> wrote: > I think we can just remove the T_DistinctExpr case from > expr_is_nonnullable(). An alternative is that we keep it, but only > when the operator is a btree equality operator, as such an operator > must not return NULL for non-null inputs. This keeps the optimization > for nearly all real-world cases.
I'm not sure. expr_is_nonnullable() doesn't look like an appealing place to do being catalog lookups. I see that var_is_nonnullable() does do catalog lookups when source == NOTNULL_SOURCE_CATALOG, which strikes me as not great (and why does it test has_subclass() before rte->relkind?!). But I'd be inclined to use a conditional rule only if we can base it on information that we already have cached in some planner data structure, and not if we'd have to look it up in the catalog. -- Robert Haas Databricks
