Re: BUG #19861: Self-join elimination drops a VOLATILE predicate and changes the query result

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Manu <manuelreyesbravo(at)gmail(dot)com>, Tender Wang <tndrwang(at)gmail(dot)com>, Richard Guo <guofenglinux(at)gmail(dot)com>, idrissaajalloh(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19861: Self-join elimination drops a VOLATILE predicate and changes the query result
Date: 2026-12-06 03:55:17
Message-ID: CALdSSPg1HrUfX_oavDVxa+ikvq__qAgZgTS8=JKH4zrasyxb2Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sun, 6 Dec 2026 at 08:03, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Manu <manuelreyesbravo(at)gmail(dot)com> writes:
> > I also tried a narrower fix: keep a duplicate qual when it contains
> > volatile functions (one condition at the list_member() test in
> > fixup_selfjoin_quals()). It drops no qual, but about 2300 cases
> > still differ in how many times or in which order the function runs,
> > so I think v3's approach is the right one.
>
> I want to push back hard against the idea that we promise anything
> about "how many times or in which order" qual clauses run; see the
> explicit documentation to the contrary in [1]. Given that, I'm
> quite prepared to dismiss this complaint as not a bug at all.
> I'm also very doubtful that SJE is the only source of effects
> of this kind.

Yeah, I want to drop my objection from [0]. For volatile functions,
number of calls should not prevent optimizations

[0] https://www.postgresql.org/message-id/CALdSSPgFzGF2oxJF5OxjoaKe82JqA7T1w9Sb8A_9UrqEzjErCQ%40mail.gmail.com

--
Best regards,
Kirill Reshke

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-12-06 04:08:09 Re: BUG #19861: Self-join elimination drops a VOLATILE predicate and changes the query result
Previous Message Tom Lane 2026-12-06 03:03:16 Re: BUG #19861: Self-join elimination drops a VOLATILE predicate and changes the query result