You need to sign in to do that
Don't have an account?

Why am I getting 'Too Many Query Row' error even when I used Limit on my SOQL query?
Hi,
I have a set of unique email address that are stored in a SET. Based on that SET of emails, I want to query all the LEads in the system with that email address. Here is an example of my code.
Note: I have more than 50,000 leads in the system so I used query in a for loop
Why would I be getting a 'Too Many query row' error if the query is in the for loop paramater list? What am I doing wrong to be hitting the 50,000 query row governor limit?
If 'email' is bigger than the total number of leads in the system, would that cause an issue? What alternative methods can I use?
I have a set of unique email address that are stored in a SET. Based on that SET of emails, I want to query all the LEads in the system with that email address. Here is an example of my code.
Note: I have more than 50,000 leads in the system so I used query in a for loop
Set<String> email = new Set<String>(); //some logic is performed //at the end of the logic, email has about 10,000 records For(Lead curLead : [Select Id, Name, Email From Lead Where Email IN: email]){ //some logic performed }//end for loop
Why would I be getting a 'Too Many query row' error if the query is in the for loop paramater list? What am I doing wrong to be hitting the 50,000 query row governor limit?
If 'email' is bigger than the total number of leads in the system, would that cause an issue? What alternative methods can I use?
thanks,
learn apex basics at forcexplore | http://www.forcexplore.com/2014/07/get-current-record-parameters-in.html
All Answers
thanks,
learn apex basics at forcexplore | http://www.forcexplore.com/2014/07/get-current-record-parameters-in.html
Hi,
You are getting this error because its violating the Governor limit.
So inspite of processing the records, one by one, you can go for batches.
Earlier it was recommended to use 200 in a go, but now salesforce has incressed the limit to 1000.
U can go for this.
let me know, if this solution worked for ur scenario.
:)
How can I process them in batches in a schedulable apex class?
The filter I am using is 'where email IN: email' where email is a SET 10,000 strings. The query should return at max 10,000 records or less as far as my understanding of SOQl queries. I have about 2000 leads in the system, so could it also cause an error where the filter (SET of emails in this case) is greater than the number of Leads in the system?