What is the difference between Database.QueryLocator and Iterable in Batch Apex in Salesforce?

What is the difference between Database.QueryLocator and Iterable in Batch Apex in Salesforce?

Database.QueryLocator:

50 Million records can be returned.

Iterable<sObject>:

Governor limits will be enforced. So, we can use upto 50,000 records only. Else, exception will be thrown.

You can also use the iterable to create your own custom process for iterating through the list.

Leave a Reply