Issue query perf improvements

This can be done using cached_apps.get_n_tasks(app_id) right?