Optimized filtering by goals