Re: Tips for re-using function results within single insert

From: Richard Huxton <dev(at)archonet(dot)com>
To: cgg007(at)yahoo(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: Tips for re-using function results within single insert
Date: 2002-09-23 11:45:32
Message-ID: 200209231245.32139.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Friday 20 Sep 2002 5:52 pm, Chris Gamache wrote:
> This would be nice to be able to do...
>
> insert into test_table (a,b) select random()::text as "myrandom",
> encode("myrandom",'base64');

Well, I'd be tempted to write a wrapper function tagged as "iscachable" and
call it with a parameter of the current transaction-id (see docs on trigger
functions) or current time (the one from now() which doesn't change per
transaction). If this gives you grief, try a standard constant.

This means PG will cache results as long as the parameter doesn't change, in
this case for the duration of the transaction.

HTH

- Richard Huxton

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Aaron Held 2002-09-23 13:24:38 Re: Monitoring a Query
Previous Message am 2002-09-23 08:02:04 output format for dates