Re: how to evaluate a function only once for a query? - Mailing list pgsql-general

From Richard Huxton
Subject Re: how to evaluate a function only once for a query?
Date
Msg-id 200206201209.57040.dev@archonet.com
Whole thread Raw
In response to how to evaluate a function only once for a query?  (Nicolae Mihalache <mache@abcpages.com>)
List pgsql-general
On Thursday 20 Jun 2002 11:40 am, Nicolae Mihalache wrote:

> However, when I do a query like:
> "select * from mytable where time<timevalue('something')" I see that my
> function is evaluated once for each row in mytable. The problem is that
> it will return each time the same value (because the argument is
> constant)

Try marking the function "iscachable" when you define it - it's designed for
exactly this situation and says that for any fixed argument your function
will return a fixed result.. I don't use pltcl but I believe that works
regardless of the function language. See the manuals for CREATE FUNCTION for
further details.

- Richard Huxton

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: database size
Next
From: Peter Dimov
Date:
Subject: Re: URGENT: Performance tuning