Yeah the complexity of the query is just too much. I don't have any off-hand advice. It looks like it would require a serious analysis of workflow and bugtracker data models.