The query works fine and the output is presently stored in the instane variables like avgGoTime etc. A new performance problem has shown up i.e. the query is too expensive, so try running it on a background service.