remove useless clauses in query. much faster now.