| From: | Nyasha Chigwamba <nyasha(dot)chigwamba(at)voss-solutions(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | "pgsql-performance(at)lists(dot)postgresql(dot)org" <pgsql-performance(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: LATERAL subquery predicate pushdown: filter applied after JSON construction instead of inside join (PG 18) |
| Date: | 2026-02-23 10:52:05 |
| Message-ID: | CH0PR10MB49081B6CC0088E6533A890CFB46BA@CH0PR10MB4908.namprd10.prod.outlook.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-performance |
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 <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Sent: February 11, 2026 12:37 PM
To: Nyasha Chigwamba <nyasha(dot)chigwamba(at)voss-solutions(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org <pgsql-performance(at)lists(dot)postgresql(dot)org>
Subject: Re: LATERAL subquery predicate pushdown: filter applied after JSON construction instead of inside join (PG 18)
Nyasha Chigwamba <nyasha(dot)chigwamba(at)voss-solutions(dot)com> 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Lea Führer | 2026-02-23 14:18:19 | MERGE INTO... WHEN NOT MATCHED BY SOURCE index usage |
| Previous Message | Laurenz Albe | 2026-02-23 09:41:57 | Re: unstable query plan on pg 16,17,18 |