Batch Apex Flashcards
Why should Batch Apex be used?
To run large jobs that would exceed normal processing limits
Batch Apex is the best solution for what situation? Give an example
Processing a lot of records at once.
Data cleansing or archiving.
What are two advantages of Batch Apex?
1 - Each transaction starts with a new set of governor limits.
2 - If one batch fails, all other successful batch transactions aren’t rolled back
What interface must be implemented in a batch class?
Database.batchable
What three methods must be implemented in a batch class?
start
execute
finish
What happens in the finish method of a batch class?
Post processing operations once all batches are executed.
How many times is the finish method of a batch class called?
once
What happens in the execute method of a batch class?
the actual processing for each batch of data.
T/F - Batches of records are guaranteed to execute in the order they’re received from the start method
false
What two classes that can be returned from the start method?
Iterable
QueryLocator
How many records can be queried by a QueryLocator?
50 million
T/F - the governor limits on the number of records returned is enforced with a queryLocator.
false
What is a use case for a custom iterable class?
Looking through API results or pre-processing records prior to being passed into the execute method.
How many times is the start method of a batch class called?
once
How many times is the execute method of a batch class called?
Once for each set of 200 records processed by the batch.