public inbox for [email protected]  
help / color / mirror / Atom feed
From: Nyasha Chigwamba <[email protected]>
To: Tom Lane <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: LATERAL subquery predicate pushdown: filter applied after JSON construction instead of inside join (PG 18)
Date: Mon, 23 Feb 2026 10:52:05 +0000
Message-ID: <CH0PR10MB49081B6CC0088E6533A890CFB46BA@CH0PR10MB4908.namprd10.prod.outlook.com> (raw)
In-Reply-To: <[email protected]>
References: <CH0PR10MB4908BD90B3C5155DF98D88A2B463A@CH0PR10MB4908.namprd10.prod.outlook.com>
	<[email protected]>

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.


view thread (3+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: LATERAL subquery predicate pushdown: filter applied after JSON construction instead of inside join (PG 18)
  In-Reply-To: <CH0PR10MB49081B6CC0088E6533A890CFB46BA@CH0PR10MB4908.namprd10.prod.outlook.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox