Re: optimiser STABLE vs. temp table was: HOWTO caching data across function calls: temporary tables, cursor? - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: optimiser STABLE vs. temp table was: HOWTO caching data across function calls: temporary tables, cursor?
Date
Msg-id 20080401163225.GB4336@svana.org
Whole thread Raw
In response to Re: optimiser STABLE vs. temp table was: HOWTO caching data across function calls: temporary tables, cursor?  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
Responses still on techniques to cache table slices was: optimiser STABLE vs. temp table  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
List pgsql-general
On Tue, Apr 01, 2008 at 06:06:35PM +0200, Ivan Sergio Borgonovo wrote:
> Would you please be so kind to rephrase:
>
> http://www.postgresql.org/docs/8.1/interactive/xfunc-volatility.html

<snip>

> I can't understand how it can call a function a single time and avoid
> to cache the result.
> Is it limited to a single statement?

Yes, it's limited to a single statememnt. Let's say hypothetically
postgres could optimise:

select f() + f();

to

select 2*f();

It would have to optimised so it only calls the function once yet at no
time does it "cache" the result in the usual sense.

Does this helps,
>   select into bau cetti from stablefunc(sameparam);
>
>   select into bingo t.bongo from stablefunc(sameparam) as s
>     join sometable t on s.cetti=t.cetti;
>
> will call stablefunc 2 times?

Yes.

> So... then any pointer to some places where I could learn some
> caching techniques if STABLE doesn't do the trick?

Anything persistnat usually needs to be in a table. If it's a really
small amount you could use the global namespace in pl/perl or similar in
other languages.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Attachment

pgsql-general by date:

Previous
From: Ivan Sergio Borgonovo
Date:
Subject: Re: optimiser STABLE vs. temp table was: HOWTO caching data across function calls: temporary tables, cursor?
Next
From: Tom Lane
Date:
Subject: Re: Getting weird pg_tblspc error, has anyone seen this before?