Re: BUG #5611: SQL Function STABLE promoting to VOLATILE - Mailing list pgsql-bugs

From Robert Haas
Subject Re: BUG #5611: SQL Function STABLE promoting to VOLATILE
Date
Msg-id AANLkTin3UGUxW++=mDRZqOeWe4siCYJiKUUdx0Lp3CLO@mail.gmail.com
Whole thread Raw
In response to Re: BUG #5611: SQL Function STABLE promoting to VOLATILE  (Brian Ceccarelli <bceccarelli@net32.com>)
Responses Re: BUG #5611: SQL Function STABLE promoting to VOLATILE  (Brian Ceccarelli <bceccarelli@net32.com>)
List pgsql-bugs
On Wed, Aug 11, 2010 at 11:01 AM, Brian Ceccarelli
<bceccarelli@net32.com> wrote:
> =A0 =A0 My complaint remains. =A0That inlined function f_return_ver_id_4(=
) is a STABLE function, inlined or not. =A0Postgres now calls it multiple t=
imes during the transaction, even though the arguments to f_return_ver_id_4=
() have not changed.
>
> =A0 =A0 STABLE no longer means STABLE. =A0This behavior is killing my per=
formance. =A0I am getting 500% to 30000% increase in latency.

We've never guaranteed that, and almost certainly never will.  Marking
a function STABLE means that the planner is *allowed to assume* that
the results won't change for a given set of arguments, not that it is
*required to prevent* it from being called multiple times with the
same set of arguments.

You can certainly prevent the function from being inlined, though
(perhaps, by writing it in PL/pgsql).

--=20
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #5611: SQL Function STABLE promoting to VOLATILE
Next
From: Brian Ceccarelli
Date:
Subject: Re: BUG #5611: SQL Function STABLE promoting to VOLATILE