Re: Immutable function WAY slower than Stable function?

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Immutable function WAY slower than Stable function?
Date: 2018-08-07 18:53:12
Message-ID: 5257764C-551F-458A-896D-EDA75FD77F13@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> On Aug 7, 2018, at 11:42, Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com> wrote:
> I assume that's "for all users and all sessions," but either in theory or in practice is there a limit to how long a stale value might persist? And, if you were to drop and recreate a function with the same name & parameters, would it start fresh at that point? And is there a way to flush any caching? (It's surely best to just declare Stable, but I'm wondering about cases that might have _very_ infrequently-changed values.)

Well, the extreme case is an IMMUTABLE function used to create an expression index; then, the value lasts as long as the index does. The best way to think of an IMMUTABLE is that it is a pure function, unchanged by system state. (This is one of the reasons that datetime-related functions are often STABLE rather than IMMUTABLE, due to time zone changes.)

--
-- Christophe Pettus
xof(at)thebuild(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2018-08-07 18:59:07 Re: Immutable function WAY slower than Stable function?
Previous Message Ken Tanzer 2018-08-07 18:42:51 Re: Immutable function WAY slower than Stable function?