+ Start a Discussion

too many query rows error :50001

I have a batch apex class that is running into Too many query rows limit exception. There is only 1 SOQL query inside my execute method that returns around 5000 rows. But after looking at the debug logs, it seems that records returning by SOQL query are getting cumulatively added in different batch executions. So after 10 iterations of batch executions, my batch class gets terminated because cumulative number of 'Total # of query rows' returned are more than 50K records.


As per my knowledge, dIfferent executions of batch class (execute method) should reset the governor limits but its not happening here.


Please respond if anyone has ever faced this issue.