Things to Remember while working with Batch Apex:
- Use Batch Apex only if you have more than one batch of records else use Queueable Apex.
- You can query up to 50 million records with the QueryLocator object which bypasses the governor limit for the total number of records retrieved by SOQL queries.
- Every transaction starts with a new set of governor limits.
- If one batch fails to process successfully, all other successful batch transactions aren’t rolled back.
- The default batch size is 200 records.
- Batches of records are not guaranteed to execute in the order they are received from the start method.
- If invoking a batch job from Trigger, need to take care that trigger won’t add more batch jobs than the limit.
- Test methods can execute only one batch total, so the number of records inserted in test class should be less than the batch size of 200.