Governor limits and Scope in Batch Apex
Governor limits and Scope in Batch Apex : Apex runs in an multitenant Environment, the Apex runtime engine strictly enforces Apex governor limits to ensure that Apex code or processes don’t monopolize shared resources. If any Apex code exceeds a limit, then Governor issues runtime exception that can not be handled. Governor limits and Scope in Batch Apex are as follows :
- Only one batch apex job’s start method can run at a run time in an organization.
- Upto 5 queued or active batch jobs are allowed for apex.
- The maximum number of batch apex method executions per a 24 hour period is 2,50,000.
- The batch apex start method can have up to 15 query cursors open at a time per user.
- A maximum 0f 50 million records can be returned in the Database.QueryLocator object.
- The Start, Execute and Finish method can implement up to 10 callouts each.
Note : If we have 1000 records with the scope of 200 records, then they are divided into 5 batches. So execute method is called 5 times, which means in every execute() we call 10 callouts. So in this scenario we call start () 10 callouts, execute() 50 callouts and finish() 10 callouts.
Batch Apex Limitations.
- Methods declared as future aren’t allowed in the classes that implement Database.batchable Interface.
- Methods declared as future can’t be called from Batch Apex class.
- For sharing recalculation, we recommend that the execute method delete and then recreate all Apex managed Sharing for the records in the batch.
- For each 10,000 AsyncApexJob records, Apex created one additional AsyncApexJob record of type Batch Apex works for internal use.