On Wed, Nov 27, 2024 at 5:45 PM Richard Guo <guofengli...@gmail.com> wrote: > I ended up using 'under the same lowest nulling outer join' to > keep consistent with the wording used elsewhere. Please see the > updated patch attached.
Commit e032e4c7d computes the nullingrel data for each leaf RTE, and we can leverage that to determine if the referenced rel is under the same lowest nulling outer join: we just need to check if the nullingrels of the subquery RTE are a subset of those of the lateral referenced rel. This eliminates the need to introduce lowest_nullable_side. Please see attached. > BTW, since commit cb8e50a4a, we've chosen not to wrap a non-var > expression if it contains Vars/PHVs of the pulled-up subquery and does > not contain non-strict constructs. I wonder if we can apply the same > optimization from this patch to non-var expressions: for a LATERAL > subquery, if a non-var expression contains Vars/PHVs of the > lowest_nullable_relids and does not contain non-strict constructs, it > could also escape being wrapped. Any thoughts? I still feel that we can apply a similar optimization to more complex non-var expressions. I plan to explore that in a separate patch. Thanks Richard
v6-0001-Avoid-unnecessary-wrapping-for-Vars-and-PHVs.patch
Description: Binary data