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

Posted by Jonathan Ellis on
I agree that a large amount of GROUP BY columns is ugly, but I don't think it slows things down. May want to test that.

However you can also wrap things in another subquery to force the planner to do what you want:

select * from (
    select p.placement_id
    from placements p, (select placement_id,count(*)
                        from placement_log log
                        where placement_id=177 group by placement_id) l 
    where l.placement_id=p.placement_id
) as q1
where warp_user_access(0,'placement',p.placement_id);