Batch Apex Limitations
Here are some important limitations to keep in mind when using batch Apex:
1. Concurrent Jobs:
You can have up to 5 batch jobs queued or active at the same time.
2. Flex Queue:
The Apex flex queue can hold up to 100 batch jobs in a holding state.
3. Test Execution:
In a running test, you can submit a maximum of 5 batch jobs.
4. Method Executions:
The maximum number of batch Apex method executions per 24-hour period is 250,000.
However, if the number of user licenses in your org multiplied by 200 is greater than 250,000, that will be the limit.
This includes the start, execute, and finish methods of batch Apex, as well as other asynchronous Apex like Queueable Apex, scheduled Apex, and future methods.
You can check the available asynchronous Apex executions by making a request to the REST API limits resource.
5. License Types:
The license types that count towards the method execution limit include full Salesforce and Salesforce Platform user licenses, App Subscription user licenses, Chatter Only users, Identity users, and Company Communities users.
6. QueryLocator Limit:
The Database.QueryLocator object can handle a maximum of 50 million records.
If more than 50 million records are returned, the batch job will fail.
7. Scope Parameter:
If the start method returns a QueryLocator, the scope parameter of Database.executeBatch can have a maximum value of 2,000.
If set to a higher value, Salesforce will chunk the records into smaller batches.
If the start method returns an iterable, there is no upper limit on the scope parameter, but using a high number may have other limitations.
The optimal scope size is a factor of 2000.
8. Default Scope Size:
If no size is specified with the scope parameter, Salesforce will chunk the records into batches of 200.
Apex governor limits are reset for each execution of the execute method.
9. Callouts:
The start, execute, and finish methods can each implement up to 100 callouts.
10. Start Method Limit:
Only one batch Apex job's start method can run at a time in an org.
Jobs that haven’t started yet remain in the queue until they're started.
However, the execute methods of multiple batch Apex jobs can run in parallel.
11. FOR UPDATE:
Using the FOR UPDATE clause in SOQL queries to lock records during update is not applicable to Batch Apex.
12. Cursor Availability:
Cursors and related query results are available for 2 days, including results in nested queries.
For more information, refer to the API Query Cursor Limits.
By understanding these limitations, you can effectively use batch Apex in your Salesforce org.
Follow Us