Re: Invalid optimization of VOLATILE function in WHERE clause?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Florian Schoppmann <Florian(dot)Schoppmann(at)emc(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Invalid optimization of VOLATILE function in WHERE clause?
Date: 2012-09-19 17:26:37
Message-ID: 747.1348075597@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> It still seems like awfully weird behavior.

Why? The WHERE condition relates only to the output of the _stats
subquery, so why shouldn't it be evaluated there, rather than after
the join?

In a green field I might agree that we should de-optimize such cases,
but the problem with doing so is that it would totally destroy
performance for cases in which a user has defined a function that's
actually stable or immutable but they forgot to mark it so. If
VOLATILE weren't the default marking, such a change wouldn't be so
problematic ... but it is. Given that the behavior has been like
this since the late stone age, I'm not inclined to change it.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-09-19 17:47:31 Re: Re: [COMMITTERS] pgsql: Properly set relpersistence for fake relcache entries.
Previous Message Tom Lane 2012-09-19 17:17:17 Removal of AcceptInvalidationMessages broke things