Re: Avoiding evaluating functions twice.

From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: han(dot)holl(at)informationslogik(dot)nl
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Avoiding evaluating functions twice.
Date: 2005-10-04 21:58:13
Message-ID: 20051004215813.GG40138@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Tuesday 04 October 2005 17:25, Tom Lane wrote:
> > han(dot)holl(at)informationslogik(dot)nl writes:
> > > select expensive_function(table) from table
> > > where expensive_function(table) is not null;
> > >
> > > Is there a way to avoid that expensive_function is evaluated twice (if
> > > it's not null) ?
> >
> > You can do something like this:
> >
> > select f from
> > (select expensive_function(table) as f from table offset 0) ss
> > where f is not null;

Why the offset 0?
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-10-04 23:10:13 Re: [GENERAL] a bug, the bugs list, and how to break the website search.
Previous Message Matthew Terenzio 2005-10-04 21:18:56 Re: License question