Issue query perf improvements

Part of PyBossa/pybossa#881