You need to sign in to do that
Don't have an account?
niraj kumar 45
Too many query rows: 50001 in batch class
I am getting System.LimitException: Too many query rows: 50001 at line wher I am Iterating while (it.hasNext()).
I have user records more than 50000 so I am using querylocator but when I am iterating I am getting Too many query rows exception.
Need help regarding this.
below is my code.:(the below code is in execute method of the batch class)
string allUserQuery = 'Select Id,Name from User';
Database.QueryLocator q = Database.getQueryLocator(allUserQuery);
Database.QueryLocatorIterator it = q.iterator();
// Iterate over the records
while (it.hasNext())
{
UserRec.add((User)it.next());
}
I have user records more than 50000 so I am using querylocator but when I am iterating I am getting Too many query rows exception.
Need help regarding this.
below is my code.:(the below code is in execute method of the batch class)
string allUserQuery = 'Select Id,Name from User';
Database.QueryLocator q = Database.getQueryLocator(allUserQuery);
Database.QueryLocatorIterator it = q.iterator();
// Iterate over the records
while (it.hasNext())
{
UserRec.add((User)it.next());
}
Please check with below post from stack exchange community with same issue while using batch apex.This might be helpful for you to accelerate with the above requirement.
- http://salesforce.stackexchange.com/questions/15456/too-many-query-rows-50001
Kindly mark this post as solved if the information help's so that it gets removed from the unanswered queue and becomes a proper solution which results in helping others who are really in need of it.Best Regards,
Nagendra.P