Batch Apex Flashcards

1
Q

Why should Batch Apex be used?

A

To run large jobs that would exceed normal processing limits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What interface must be implemented in a batch class?

A

Database.batchable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What three methods must be implemented in a batch class?

A

start
execute
finish

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What happens in the finish method of a batch class?

A

Post processing operations once all batches are executed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

once

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What happens in the execute method of a batch class?

A

the actual processing for each batch of data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

Iterable

QueryLocator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How many records can be queried by a QueryLocator?

A

50 million

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A

once

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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