You need to sign in to do that
Don't have an account?
SOQL FOR loop and 500/10,000 row limit
I had thought that using a SOQL FOR loop would solve the problem around retrieving too many rows from a query, because it would return 200 at a time (implicit query/querymore).
However, I am getting the "too many rows back" error anyways, on the actual [soql-query] portion of the FOR loop.
Are we really limited to 500/10,000 rows back even on the [soql-query] term? If so, does anyone have a workaround to iterate through really large data sets?
We can use:
for (Account a : [Select id from account]){
…
}
as the example query. Assuming I have > 500/10,000 accounts, how I can iterate through them all?
Thanks!
Don
Bottom line, it seems that there is no way around the 10,000 sql row limit at this time.
Work around will have to be done to run 2 queries, probably with a “where” clause on names “a-m” “M-z” or something like that, then combine the results.
All Answers
SOQL query can return upto 10000 records. So this is limitation if you have to process large data sets.
Use Batch Apex that can process upto 50 million records in a single query.
You can find more info on batch apex in the Apex documentation.
if you have any further queries post them
Batch isn't going to help me here, because I need to iterate through this data set when its called as a webservice. The iteration needs to be real-time.
If you use the following syntax, you can only retrieve upto 1000 rows - any more and you'll get a runtime error:
If you use the following syntax however, you can retrieve upto 10,000 recods, in batches in 200 (the implicit query more pattern).
Bottom line, it seems that there is no way around the 10,000 sql row limit at this time.
Work around will have to be done to run 2 queries, probably with a “where” clause on names “a-m” “M-z” or something like that, then combine the results.