Timeline for Why does it say my SOQL for loop returned 50,001 records when it broke the loop after 20k?
Current License: CC BY-SA 3.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 5, 2016 at 19:25 | comment | added | sfdcfox♦ | @Neo Yes-- the List method of the for-each SOQL query loop uses chunks of 200 records, while the non-list method tries to suck in all the records at once. | |
Jan 5, 2016 at 19:23 | comment | added | sfdcfox♦ |
@javanoob I tried to explain that in the first sentence-- the number of rows returned will be at most Limits.getLimitQueryRows()-Limits.getQueryRows()+1 according the logs. I suspect that salesforce is implicitly adding a LIMIT statement if you don't add one yourself.
|
|
Jan 5, 2016 at 18:59 | comment | added | javanoob | @sfdcfox Please ignore my above comment. Here is my latest question: Can you please explain why the query on line 9 returned 29800 rows but where as the same query on line 2 returned 5000 rows? | |
Jan 5, 2016 at 18:51 | comment | added | javanoob | @sfdcfox Did you forget to add WHERE clause for the query on line 9 because it is same as the query on line 2 but the number of rows returned are different(as per the logs you posted). Just wanted to point it out so that if any new guy reads this it might confuse him. As always thanks for your time! | |
Jan 5, 2016 at 18:32 | comment | added | Neo | @sfdcfox: I got it to stop giving me the error by changing my 'for(Account record:' to 'for(Account[] records:'. Thanks for your help! | |
Jan 5, 2016 at 18:02 | comment | added | sfdcfox♦ | @Neo Please take a look at the now completely revised answer. | |
Jan 5, 2016 at 18:02 | history | edited | sfdcfox♦ | CC BY-SA 3.0 |
added 576 characters in body
|
Jan 5, 2016 at 17:59 | comment | added | sfdcfox♦ | @Neo So... Actually, I found out I was wrong :( | |
Jan 5, 2016 at 17:58 | comment | added | mkorman | @Neo: you can use batch Apex... | |
Jan 5, 2016 at 17:57 | vote | accept | Neo | ||
Jan 5, 2016 at 17:57 | comment | added | Neo | Thanks for the quick, clear answer. Unfortunately, it's not what I was hoping to hear. I wish there were a good way to query huge groups of records at once. | |
Jan 5, 2016 at 17:45 | history | answered | sfdcfox♦ | CC BY-SA 3.0 |