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

Collapse
Posted by David Walker on
  
select p.placement_id from placements p, (select  
placement_id,count(*),warp_user_access(0,'placement',p.placement_id)  
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.