Re: Can this function be declared IMMUTABLE?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: beickhof(at)Lexmark(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Can this function be declared IMMUTABLE?
Date: 2007-08-28 17:40:32
Message-ID: 410.1188322832@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

beickhof(at)Lexmark(dot)com writes:
> Well, I am considering a function that does select from a table, but the
> table contents change extremely infrequently (the table is practically a
> list of constants). Would it be safe to declare the function IMMUTABLE
> provided that the table itself is endowed with a trigger that will drop
> and recreate the function any time the table contents are modified?

What you'd want to do is restart all existing sessions so that any plans
made using precomputed function values are discarded. The trigger you
suggest is fairly pointless because it will not cause regeneration of
plans.

I concur with Bill's remark that you should first determine if there's
a really substantial benefit to marking the function immutable rather
than merely stable.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-08-28 17:42:27 Re: 8.1.10 release?
Previous Message Tom Lane 2007-08-28 17:19:32 Re: Indexing Foreign Key Columns