Re: BUG #5611: SQL Function STABLE promoting to VOLATILE

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Brian Ceccarelli <bceccarelli(at)net32(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #5611: SQL Function STABLE promoting to VOLATILE
Date: 2010-08-11 15:32:52
Message-ID: AANLkTin3UGUxW++=mDRZqOeWe4siCYJiKUUdx0Lp3CLO@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Aug 11, 2010 at 11:01 AM, Brian Ceccarelli
<bceccarelli(at)net32(dot)com> wrote:
>     My complaint remains.  That inlined function f_return_ver_id_4() is a STABLE function, inlined or not.  Postgres now calls it multiple times during the transaction, even though the arguments to f_return_ver_id_4() have not changed.
>
>     STABLE no longer means STABLE.  This behavior is killing my performance.  I 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).

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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Brian Ceccarelli 2010-08-11 15:50:25 Re: BUG #5611: SQL Function STABLE promoting to VOLATILE
Previous Message Tom Lane 2010-08-11 15:18:26 Re: BUG #5611: SQL Function STABLE promoting to VOLATILE