postgresql7.1
select category_id, count(com.object_id), min(trans.name)
from categories
natural left join category_object_map com
natural join category_trees
natural join category_translations trans
where tree_id = :tree_id
and trans.locale = :default_locale
and acs_permission__permission_p(com.object_id, :user_id, 'read')
group by category_id