Batch Apex Flashcards Preview

Salesforce Data Architecture and Management Designer > Batch Apex > Flashcards

Flashcards in Batch Apex Deck (26)
Loading flashcards...
1
Q

Why should Batch Apex be used?

A

To run large jobs that would exceed normal processing limits

2
Q

Batch Apex is the best solution for what situation? Give an example

A

Processing a lot of records at once.

Data cleansing or archiving.

3
Q

What are two advantages of Batch Apex?

A

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

4
Q

What interface must be implemented in a batch class?

A

Database.batchable

5
Q

What three methods must be implemented in a batch class?

A

start
execute
finish

6
Q

What happens in the finish method of a batch class?

A

Post processing operations once all batches are executed.

7
Q

How many times is the finish method of a batch class called?

A

once

8
Q

What happens in the execute method of a batch class?

A

the actual processing for each batch of data.

9
Q

T/F - Batches of records are guaranteed to execute in the order they’re received from the start method

A

false

10
Q

What two classes that can be returned from the start method?

A

Iterable

QueryLocator

11
Q

How many records can be queried by a QueryLocator?

A

50 million

12
Q

T/F - the governor limits on the number of records returned is enforced with a queryLocator.

A

false

13
Q

What is a use case for a custom iterable class?

A

Looking through API results or pre-processing records prior to being passed into the execute method.

14
Q

How many times is the start method of a batch class called?

A

once

15
Q

How many times is the execute method of a batch class called?

A

Once for each set of 200 records processed by the batch.

16
Q

How many records can be processed by a batch at a time?

A

200

17
Q

What is the start method responsible for?

A

Collecting the records or objects to be passed into the execute method for processing.

18
Q

How is a batch class invoked?

A

Database.executeBatch

19
Q

How can the number of records processed in a batch be controlled?

A

the scope parameter of executeBatch

20
Q

What is a use case for the scope parameter?

A

Running into governor limits when executing the default batch size.

21
Q

What is created as a result of invoking a batch?

A

An AsyncApexJob record

22
Q

T/F- by default batches are stateful

A

false

23
Q

How many transactions are processed in a batch execution of 1000 records?

A

5

24
Q

How is a batch made stateful?

A

implementing the Database.Stateful interface

25
Q

Why is maintaining state in a batch class useful?

A

when counting or summarizing data across batch executions is necessary. Maintaining state does not clear class level variables across executions.

26
Q

T/F - it’s a good idea to use Batch Apex when there are 200 records or less.

A

false