Hi Tom, Thank you for this - much appreciated. Removing the ORDER BY LIMIT does change the query and after some further investigation, it looks like I also need to project the raw columns then apply the filters on the projected columns as a opposed to filtering on the constructed JSONB.
Regards, Nyasha ________________________________ From: Tom Lane <[email protected]> Sent: February 11, 2026 12:37 PM To: Nyasha Chigwamba <[email protected]> Cc: [email protected] <[email protected]> Subject: Re: LATERAL subquery predicate pushdown: filter applied after JSON construction instead of inside join (PG 18) Nyasha Chigwamba <[email protected]> writes: > Question: Can the planner push predicates on view columns into the underlying > LATERAL subqueries? It can, but it will not push them into a subquery with LIMIT, because that would potentially change the subquery result. I'd try to get rid of all those ORDER BY LIMIT bits in your view definition. That's generally considered an antipattern in SQL. It's definitely an optimization fence. regards, tom lane This communication is confidential and if not addressed to you and has been received in error, you must: (i) notify the sender immediately and delete the e-mail; and (ii) refrain from copying, printing, forwarding, publishing or disclosing the contents of the e-mail.
