function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How many records we can iterate in for loop

Hi Guys,

Is there any limitiation for iterating the no of records in a for loop ? .

for loop with in for loop doing iteration for 10,000 records. is there any impact ?

There is no limit on the number of records that you can iterate using a For loop. This is restricted only by the size of collection that is being iterated (collection is so large that the system runs out of memory during processing).

Couple of years back there was a limit on number of statements executed in a single transaction - 
200,000 for Synchronous Apex and 1,000,000 for Asynchronous Apex. This limit has now been removed.

What you may run into is the maximum processing time allotted for a transaction - 
10 seconds for Synchronous Apex and 60 seconds for Asynchronous Apex.
Thank you Jayant.
If this is resolved, please do mark the question as Resolved and the most appropriate/helpful answer as the best answer :).
If none of the answers helped you significantly, please post the solution. You may also mark your solution as the best answer.