You must keep in mind several important limits of Batch Apex:
Future methods are not allowed anywhere in Batch Apex.
Batch jobs are always run as the system user, so they have permission to read and write all data in the organization.
The maximum heap size in Batch Apex is 12MB.
Calling out to external systems using the HTTP
object or webservice
methods is limited to one for each invocation of start
, execute
, and finish
. To enable your batch process to call out, make sure the code implements the Database.AllowsCallouts
interface in addition to the standard Database.Batchable
interface.
Transactions (the execute
method) run under the same governor limits as any Apex code. If you have intensive work to do in your execute
method and worry about exceeding the governor limits when presented with the default 200 records per transaction, reduce the number of records using the optional scope
parameter of the Database.executeBatch
method.
The maximum number of queued or active batch jobs within an entire Salesforce organization is five. Attempting to run another job beyond the five raises a runtime error. For this reason, you should tightly control the number of batch jobs that are submitted. For example, submitting a batch from a trigger is generally a bad idea if you can avoid it. In a trigger, you can quickly exceed the maximum number of batch jobs.
3.17.79.3