Re: how to evaluate a function only once for a query?

From: Richard Huxton <dev(at)archonet(dot)com>
To: Nicolae Mihalache <mache(at)abcpages(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: how to evaluate a function only once for a query?
Date: 2002-06-20 11:09:57
Message-ID: 200206201209.57040.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2002-06-20 12:17:16 Re: circular REFERENCES
Previous Message Dave Page 2002-06-20 11:07:05 foreign Key problem