I would like to be able to say: SELECT url,score_a(text, CAST('term' AS TEXT)) AS score FROM articles WHERE score > 0 ORDER BY score DESC; This returns: ERROR: Attribute 'score' not found. The following works: SELECT url,score_a(text, CAST('term' AS TEXT)) AS score FROM articles WHERE score_a(text, CAST('term' AS TEXT)) > 0 ORDER BY score DESC; Doesn't seem efficient to me? Or are the results from score_a cached somehow? score_a is a (rather computation-intensive :-) PL/Perl function which returns an integer. I am using PostgreSQL 7.0 -- Eric Jain