Re: BUG #19377: Query planner interesting behaviour

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: postgresql(at)juneidy(dot)wibowo(dot)au, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19377: Query planner interesting behaviour
Date: 2026-01-21 16:18:45
Message-ID: 2212449.1769012325@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

David Rowley <dgrowleyml(at)gmail(dot)com> writes:
> On Tue, 13 Jan 2026 at 21:57, PG Bug reporting form
> <noreply(at)postgresql(dot)org> wrote:
>> It's weird that in the first query postgres doesn't seem to treat
>> st_makevalid($0) as a constant and I think re-evaluate st_makevalue($0) for
>> every row. Is that an expected behaviour?

> Yes, it's expected. We don't do anything special to try and walk up
> function call chains of immutable functions for init plan parameters
> to push function calls down to the init plan. Perhaps something is
> possible here, but anyone proposing we change this would need to come
> armed with proof that it's safe to do this.

It would be a fairly hard sell, I think, because traditionally
PG users have understood that a scalar sub-SELECT like this is an
optimization fence. Pushing stuff across that fence is likely to
break some hand-optimized queries.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-01-21 16:57:01 Re: Revoke Connect Privilege from Database not working
Previous Message Tom Lane 2026-01-21 15:42:07 Re: BUG #19386: Unnecessary Sort in query plan for SELECT literal with ORDER BY