Re: referring to computed values from the select list in the where and order clauses

From: Richard Huxton <dev(at)archonet(dot)com>
To: Stephen Howard <stephen(at)thunkit(dot)com>, "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: referring to computed values from the select list in the where and order clauses
Date: 2004-03-01 09:21:32
Message-ID: 200403010921.32427.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday 01 March 2004 01:04, Stephen Howard wrote:
> I've got a moderately complex function defined which i then want to be
>
> able to test the value of, as well as select the value:
>
> select id, vector_cosine(document,'[ qw( foo,bar,baz )]') as threshold
> from search_vectorspace where threshold > 0 order by threshold desc;

Can't be done that way, I'm afraid. The aliasing is defined as occuring after
the where clause has been evaluated.

However, you can mark functions as immutable/stable/volatile which can allow
PG to cache the query results. See the manuals (CREATE FUNCTION) for details.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2004-03-01 09:56:03 Re: referring to computed values from the select list in the where and order clauses
Previous Message Shridhar Daithankar 2004-03-01 06:36:58 Re: PostgreSQL insert speed tests