Re: Convincing STABLE functions to run once

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Dan Wells <dbw2(at)calvin(dot)edu>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Convincing STABLE functions to run once
Date: 2014-09-09 21:46:19
Message-ID: 735A8879-81B1-49A1-BCB8-13B78D081396@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 09 Sep 2014, at 17:23, Dan Wells <dbw2(at)calvin(dot)edu> wrote:

> I often have functions which are not truly immutable (they do something minor, like read in configuration information), but the functions themselves are fairly expensive, so I want them to run just once per query. At face value, I feel like STABLE should do what I want, but often it does not.

Assuming that the part that makes these functions expensive is not the reading of the configuration information, perhaps you can split your functions such that the expensive part goes into an IMMUTABLE function that takes those (STABLE) configuration values as input?

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Paquier 2014-09-10 00:19:56 Re: Crash in 9.4 Beta when partially collapsing left outer joins
Previous Message Jay at Verizon 2014-09-09 21:35:14 Re: Pgpool starting problem