Optimize authorization query.