On Tue, 2012-04-24 at 12:10 +0200, Thomas Kellerer wrote:
> Rafal Pietrak, 24.04.2012 09:02:
> >
> > is not an option, since the function is *very* expensive (multiple join
> > of large tables - inventories, history, etc).
> >
> > Is there a syntax workaround that I could possibly use to get the effect
> > of launching my_function just once?
>
> With 9.1 you could probably achieve this using a writeable CTE.
>
> Although I have to admit I don't really understand what your function is returning.
> Does the function return a result set or scalar values?
>
Basically, it's at shopping cart update.
It ranks updated an item with costommer rating of that item with respect
to other orders and current stock (so that when the cart is only
presented, the values are there, precomputted on update). There is more
then one value to precompute, so the function returns a set of values.
(earlier I only needed to precompute just one value and everything was
so easy then... :).
Could you pls give me an example of how the "writeable CTE"? This does
not ring a bell here.
-R