Forum OpenACS Q&A: Response to Weird PostgreSQL SELECT processing

Posted by David Walker on
select p.placement_id from placements p, (select  
as warped_access from placement_log log where  
placement_id=177 group by placement_id) l where  
l.placement_id=p.placement_id and l.warped_access ;  

Try moving the function call into the select portion of a sub-query that is limited on placement_id. That way the function should only be executed for the placement_id(s) that are returned. Then refer to that alias in your outer query to limit on that.